-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: cron removed on module change #3512
Conversation
69863ae
to
fc03977
Compare
Can you describe the actual change here? Or preferably, add comments to the PR. The code doesn't make sense to me on the face of it, but that's probably because I don't understand the problem. |
fc03977
to
7fe8e20
Compare
I added some comments. Basically you see the 'added' message for the new deployment before you see the 'removed' message. The code the way it was would end up deleting a modules cron jobs when the old module was removed. |
backend/cron/service.go
Outdated
@@ -78,6 +78,7 @@ func run(ctx context.Context, verbClient CallClient, changes chan *ftlv1.PullSch | |||
logger := log.FromContext(ctx).Scope("cron") | |||
// Map of cron jobs for each module. | |||
cronJobs := map[string][]cronJob{} | |||
currentDeploymentForModule := map[string]string{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I don't understand is that it looks like keys are never removed from this map?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, that was an oversight, fixed. It would not have caused any actual issues in practice, unless you added and removed a huge number of modules.
7fe8e20
to
13136c3
Compare
switch resp.ChangeType { | ||
case ftlv1.DeploymentChangeType_DEPLOYMENT_REMOVED: | ||
// We see the new state of the module before we see the removed deployment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see, that makes sense. Though if it's immediately ADDED, this shouldn't actually stop cron jobs from working as the ticket describes right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is ADDED then REMOVED, so we first get a message with the new cron schema, then get a message that the old one is removed. With the code the way it currently is all the cron jobs after the first deployment basically get removed immediately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should fix the underlying issue and reverse the order of the updates, rather than add hacks to work around it.
The order of the updates is correct though, both deployments are running for a while for rolling deployments, and canaries will only make this worse. |
13136c3
to
d059442
Compare
@@ -100,13 +100,18 @@ func Start(ctx context.Context, config Config, pullSchemaClient PullSchemaClient | |||
newState.protoSchema.Modules = append(newState.protoSchema.Modules, resp.Schema) | |||
} | |||
} else if existing != nil { | |||
// We see the new state of the module before we see the removed deployment. | |||
// We only want to actually remove if it was not replaced by a new deployment. | |||
if !resp.ModuleRemoved { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah nice.
fixes #3503