Skip to content

Conversation

0xavi0
Copy link
Contributor

@0xavi0 0xavi0 commented Oct 9, 2025

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 the
    fleet-docs repository.

0xavi0 added 2 commits October 9, 2025 10:31
Signed-off-by: Xavi Garcia <xavi.garcia@suse.com>
Signed-off-by: Xavi Garcia <xavi.garcia@suse.com>
@0xavi0 0xavi0 force-pushed the fix-schedule-update-reset-active branch from 686a16f to b96fe35 Compare October 9, 2025 09:15
@0xavi0 0xavi0 self-assigned this Oct 9, 2025
@0xavi0 0xavi0 added this to Fleet Oct 9, 2025
@0xavi0 0xavi0 added this to the v2.13.0 milestone Oct 9, 2025
@0xavi0 0xavi0 marked this pull request as ready for review October 9, 2025 09:35
@0xavi0 0xavi0 requested a review from a team as a code owner October 9, 2025 09:35
k8sclient client.Client,
cluster, namespace string,
scheduledExpected, flaggedAsScheduledExpected bool) {
scheduledExpected, flaggedAsScheduledExpected, activeScheduleExpected bool) {
Copy link
Contributor

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})

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// when this function is called is either because we're updating a
// This function is called either because we're updating a

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed as suggested

Copy link
Contributor

@p-se p-se left a 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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@kkaempf kkaempf moved this to 👀 In review in Fleet Oct 13, 2025
Signed-off-by: Xavi Garcia <xavi.garcia@suse.com>
@0xavi0 0xavi0 force-pushed the fix-schedule-update-reset-active branch from acd19b6 to 237c907 Compare October 13, 2025 12:45
@0xavi0 0xavi0 requested a review from weyfonk October 13, 2025 12:47
@0xavi0 0xavi0 merged commit d3aac3a into rancher:main Oct 13, 2025
47 of 51 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Fleet Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants