-
Notifications
You must be signed in to change notification settings - Fork 247
Scheduled BundleDeployments experimental version #4184
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
5c444fe
to
474182e
Compare
Refers to: rancher#3726 Signed-off-by: Xavi Garcia <xavi.garcia@suse.com>
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.
Thanks for this \o/
Leaving a few comments, happy to discuss!
Signed-off-by: Xavi Garcia <xavi.garcia@suse.com>
// changes to cluster labels that occurred since the last reconciliation | ||
// are included. The controller's watchers only trigger reconciles for | ||
// clusters that are already part of a schedule. | ||
clusters, err := matchingClusters(ctx, c.Matcher, c.client, c.Schedule.Namespace) |
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.
Let's discuss, as I think I understand the change you made, but not how it relates to my initial comment 😅
Signed-off-by: Xavi Garcia <xavi.garcia@suse.com>
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 :)
This PR adds the ability to control whether a
BundleDeployment
can or cannot be installed, based on defined Schedules.A new CRD,
Schedule
, is introduced. It defines time intervals during which Clusters—selected via label selectors—are allowed to accept new deployments.An example
Schedule
would look like this:This would allow new deployments to be installed every 5 minutes (at second 0) for a duration of 1 minute, and it would apply to all clusters located in the fleet-default namespace that have the label env=dev.
When a
Schedule
is applied, the controller evaluates whichCluster
s match the defined selectors. For all matchingCluster
s, theStatus.Scheduled
field is set to true.This field indicates that the
Cluster
is governed by aSchedule
, meaning no newBundleDeployment
s will be applied to it unless theStatus.ActiveSchedule
field — also newly introduced — is explicitly set to true.The
Status.ActiveSchedule
field is set to true at the moment aSchedule
begins execution and remains true for the duration defined in theSchedule
’s specification.The mechanism used to prevent an Agent from applying a
BundleDeployment
while aSchedule
is active mirrors the existing implementation of the "Pause" feature.The controller actively monitors changes to any
Cluster
that is part of an existingSchedule
. If aCluster
's labels or name are modified, the controller re-evaluates and updates the affectedSchedule
’s target set accordingly.Additionally, when a
Schedule
begins execution, the controller performs a fresh evaluation to detect newly matchingCluster
s or exclude any that no longer meet the criteria.The set of
Cluster
s associated with aSchedule
is computed either at the time ofSchedule
creation, upon modification of theSchedule
, or at the start of its execution.📅 Schedule Execution Implementation
The execution logic for the Schedule has been implemented as follows:
quartz.NewRunOnceTrigger
is created.quartz.NewRunOnceTrigger
is created for the defined duration, and theStarted
property is set totrue
.Started
property is set back tofalse
.The reason for avoiding
quartz.NewCronTriggerWithLoc
is to prevent jobs from remaining in the scheduler indefinitely and to allow more precise control over job execution — both start time and duration.The goal is to minimize potential race conditions, especially in edge cases where a job is scheduled to begin very close to the end of a previous execution.
A constraint has also been introduced to ensure that the minimum viable execution duration is at least 1 second, after computing feasibility relative to the execution start time.
That is, there must be at least 1 second between consecutive execution start times.
This further helps reduce race conditions, since starting an execution involves multiple API calls to the Kubernetes API server.
To enable it, set the following environment variable:
🔧 Pending Work
clusters
field, anticipating future support for other resources likeGitRepos
, where polling or Bundle updates could be paused.BundleDeployment
is ready but did not deploy because the Cluster is scheduled and not active?Refers to: #3726
Additional Information
Checklist
fleet-docs repository.