mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-08-16 04:06:06 +00:00
Fix schedule reconciler aliasing server-wide skipImmediately default (#10242)
e2e-test-kind.yaml / extract (push) Failing after 5s
Run the E2E test on kind / get-go-version (push) Failing after 6s
Run the E2E test on kind / build (push) Skipped
Run the E2E test on kind / setup-test-matrix (push) Successful in 3s
Run the E2E test on kind / run-e2e-test (push) Skipped
push.yml / extract (push) Failing after 6s
Main CI / get-go-version (push) Failing after 7s
Main CI / Build (push) Skipped
e2e-test-kind.yaml / extract (push) Failing after 5s
Run the E2E test on kind / get-go-version (push) Failing after 6s
Run the E2E test on kind / build (push) Skipped
Run the E2E test on kind / setup-test-matrix (push) Successful in 3s
Run the E2E test on kind / run-e2e-test (push) Skipped
push.yml / extract (push) Failing after 6s
Main CI / get-go-version (push) Failing after 7s
Main CI / Build (push) Skipped
When a Schedule has no explicit spec.skipImmediately, the reconciler assigned &c.skipImmediately directly into the Schedule's spec pointer. The subsequent write-through-pointer (*ptr = false) mutated the reconciler's own shared field, silently disabling --schedule-skip-immediately for every schedule reconciled afterward for the life of the process. Fix: copy the value into a fresh bool before taking its address. Adds TestReconcileDoesNotCorruptReconcilerSkipImmediately, which reconciles two schedules against one reconciler instance and asserts the shared default is preserved. Signed-off-by: Prajwal <percy38621@gmail.com>
This commit is contained in:
@@ -111,7 +111,11 @@ func (c *scheduleReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
|
||||
original := schedule.DeepCopy()
|
||||
|
||||
if schedule.Spec.SkipImmediately == nil {
|
||||
schedule.Spec.SkipImmediately = &c.skipImmediately
|
||||
// Copy the value rather than aliasing &c.skipImmediately: c is a long-lived
|
||||
// singleton reconciler, and the block below can write through this pointer,
|
||||
// which would otherwise mutate the reconciler's shared default field.
|
||||
skipImmediately := c.skipImmediately
|
||||
schedule.Spec.SkipImmediately = &skipImmediately
|
||||
}
|
||||
if schedule.Spec.SkipImmediately != nil && *schedule.Spec.SkipImmediately {
|
||||
*schedule.Spec.SkipImmediately = false
|
||||
|
||||
Reference in New Issue
Block a user