-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Support pause/unpause schedules #5279
Conversation
4700db8
to
8cb7bbc
Compare
Codecov Report
@@ Coverage Diff @@
## main #5279 +/- ##
==========================================
- Coverage 40.84% 40.80% -0.05%
==========================================
Files 234 236 +2
Lines 20260 20349 +89
==========================================
+ Hits 8276 8303 +27
- Misses 11383 11444 +61
- Partials 601 602 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@ywk253100 |
@@ -89,6 +89,11 @@ func (c *scheduleReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c | |||
return ctrl.Result{}, errors.Wrapf(err, "error getting schedule %s", req.String()) | |||
} | |||
|
|||
if schedule.Spec.Paused { |
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.
There is already status.Phase SchedulePhaseEnabled
providing similar functionality.
I know the purpose of the phase is used to indicate schedule is validated, but it's still a little confusing, and I think schedule controller's status checking logic needs modification. Maybe some refactoring is also needed.
log.Info("the schedule is paused, skip") | ||
return ctrl.Result{}, nil | ||
} | ||
|
||
if schedule.Status.Phase != "" && | ||
schedule.Status.Phase != velerov1.SchedulePhaseNew && | ||
schedule.Status.Phase != velerov1.SchedulePhaseEnabled { |
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.
By this condition checking code, if a schedule is marked as FailedValidation
, it will not be handled anymore.
To me, this seems not right. Invalid schedule should have a chance for modification.
@@ -89,6 +89,11 @@ func (c *scheduleReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c | |||
return ctrl.Result{}, errors.Wrapf(err, "error getting schedule %s", req.String()) | |||
} | |||
|
|||
if schedule.Spec.Paused { | |||
log.Info("the schedule is paused, skip") |
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.
To me, I think this checking can be put into PeriodicalEnqueueSource
fitlerFuncs.
If the schedule is in pending state, no updating should be reasonable.
I also put the generated backup state checking into fitler functions, maybe it should be put into reconcile function, because not handling schedule that has backup in progress could be a surprise for user.
4633466
to
c5631c1
Compare
@@ -284,35 +282,18 @@ func (b *backupSyncReconciler) SetupWithManager(mgr ctrl.Manager) error { | |||
mgr.GetClient(), | |||
&velerov1api.BackupStorageLocationList{}, | |||
backupSyncReconcilePeriod, | |||
kube.PeriodicalEnqueueSourceOption{ | |||
OrderFunc: backupSyncSourceOrderFunc, |
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.
OrderFunc shouldn't be removed.
c5631c1
to
c9254d2
Compare
@@ -62,6 +62,10 @@ func TestReconcileOfSchedule(t *testing.T) { | |||
name: "schedule with phase FailedValidation triggers no backup", | |||
schedule: newScheduleBuilder(velerov1api.SchedulePhaseFailedValidation).Result(), | |||
}, | |||
{ | |||
name: "paused schedule triggers no backup", | |||
schedule: newScheduleBuilder(velerov1api.SchedulePhase("")).Result(), |
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.
The paused
is not set in the test case.
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.
The pause cannot be tested easily in UT after moving the check logic into pridicate, I have remove this line and we'll cover the test in the E2E
c9254d2
to
ef6652a
Compare
Support pause/unpause schedule Fixes vmware-tanzu#2363 Signed-off-by: Wenkai Yin(尹文开) <[email protected]>
ef6652a
to
4b9dbfa
Compare
Support pause/unpause schedule
Fixes #2363
Signed-off-by: Wenkai Yin(尹文开) [email protected]
Thank you for contributing to Velero!
Please add a summary of your change
Does your change fix a particular issue?
Fixes #(issue)
Please indicate you've done the following:
/kind changelog-not-required
as a comment on this pull request.site/content/docs/main
.