-
Notifications
You must be signed in to change notification settings - Fork 247
Fixes schedule update reset active #4209
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
Conversation
Signed-off-by: Xavi Garcia <xavi.garcia@suse.com>
Signed-off-by: Xavi Garcia <xavi.garcia@suse.com>
686a16f
to
b96fe35
Compare
k8sclient client.Client, | ||
cluster, namespace string, | ||
scheduledExpected, flaggedAsScheduledExpected bool) { | ||
scheduledExpected, flaggedAsScheduledExpected, activeScheduleExpected bool) { |
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.
nit: I think creating a struct containing these 3 booleans would make the calls above a bit easier to read.
Example:
type expected struct{
job bool
statusScheduled bool
statusActiveSchedule bool
}
... and, since these fields would be visible on the calling line, this function could be renamed to e.g. checkState
// before
checkClusterIsScheduled(scheduler, k8sclient, "test-cluster4", "default", true, true, false)
// after
checkState(scheduler, k8sclient, "test-cluster4", "default", expected{job:true, statusScheduled: true, statusActiveSchedule: true})
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.
changed as suggested
cluster.Status.ActiveSchedule = false | ||
} | ||
|
||
// when this function is called is either because we're updating a |
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.
// when this function is called is either because we're updating a | |
// This function is called either because we're updating a |
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.
changed as suggested
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.
lgtm
} | ||
|
||
func updateScheduledClusters(ctx context.Context, scheduler quartz.Scheduler, c client.Client, clustersNew []string, clustersOld []string, namespace string) error { | ||
// first look for clusters that are not scheduled yet and flag them as scheduled |
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.
Is this comment still up-to-date?
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.
I've deleted the comment because now the code is obvious.
Signed-off-by: Xavi Garcia <xavi.garcia@suse.com>
acd19b6
to
237c907
Compare
There was a bug in the recently merged Scheduling PR.
The bug consists of applying a label to the Schedule that initially matches all clusters, and then, while the Schedule is active, changing the target so that it matches fewer clusters.
The clusters that remained as targets would stay in the ActiveSchedule state, which is incorrect, since modifying the Schedule should reset it and set its status to not active.
Follow-up to #4184.
Related to #3726.
Additional Information
Checklist
[ ] I have updated the documentation via a pull request in thefleet-docs repository.