mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-28 10:45:44 +00:00
Fix schedule reconciler to compare SkipImmediately and LastSkipped by value (#10490)
Run the E2E test on kind / setup-test-matrix (push) Failing after 3s
e2e-test-kind.yaml / extract (push) Failing after 6s
Run the E2E test on kind / get-go-version (push) Failing after 7s
Run the E2E test on kind / build (push) Skipped
Run the E2E test on kind / run-e2e-test (push) Skipped
push.yml / extract (push) Failing after 6s
Scorecard supply-chain security / Scorecard analysis (push) Skipped
Main CI / get-go-version (push) Failing after 7s
Main CI / Build (push) Skipped
Run the E2E test on kind / setup-test-matrix (push) Failing after 3s
e2e-test-kind.yaml / extract (push) Failing after 6s
Run the E2E test on kind / get-go-version (push) Failing after 7s
Run the E2E test on kind / build (push) Skipped
Run the E2E test on kind / run-e2e-test (push) Skipped
push.yml / extract (push) Failing after 6s
Scorecard supply-chain security / Scorecard analysis (push) Skipped
Main CI / get-go-version (push) Failing after 7s
Main CI / Build (push) Skipped
* Fix schedule reconciler to compare SkipImmediately and LastSkipped by value The reconciler compared spec.skipImmediately (*bool) and status.lastSkipped (*metav1.Time) between the live object and its DeepCopy by pointer, so both checks always reported a change once the fields were set, and every reconcile issued a redundant Patch. Compare by value instead (ptr.Equal / equality.Semantic.DeepEqual) and add a regression test pinning that the skip-once flip persists with exactly one patch, later reconciles of persisted state patch zero times, and an explicit false is a no-op. Signed-off-by: HeonJe LEE <lhjnano@gmail.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: lyndon-li <98304688+Lyndon-Li@users.noreply.github.com> --------- Signed-off-by: HeonJe LEE <lhjnano@gmail.com> Signed-off-by: lyndon-li <98304688+Lyndon-Li@users.noreply.github.com> Co-authored-by: lyndon-li <98304688+Lyndon-Li@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot Autofix powered by AI
lyndon-li
parent
e164dc5984
commit
f40112aedf
@@ -24,10 +24,12 @@ import (
|
||||
"github.com/cockroachdb/errors"
|
||||
cron "github.com/netresearch/go-cron"
|
||||
"github.com/sirupsen/logrus"
|
||||
equality "k8s.io/apimachinery/pkg/api/equality"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
clocks "k8s.io/utils/clock"
|
||||
"k8s.io/utils/ptr"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
bld "sigs.k8s.io/controller-runtime/pkg/builder"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
@@ -149,12 +151,12 @@ func (c *scheduleReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
|
||||
errStringArr = append(errStringArr, fmt.Sprintf("phase to %s", schedule.Status.Phase))
|
||||
}
|
||||
// update spec.SkipImmediately if it's changed
|
||||
if original.Spec.SkipImmediately != schedule.Spec.SkipImmediately {
|
||||
if !ptr.Equal(original.Spec.SkipImmediately, schedule.Spec.SkipImmediately) {
|
||||
scheduleNeedsPatch = true
|
||||
errStringArr = append(errStringArr, fmt.Sprintf("spec.skipImmediately to %v", schedule.Spec.SkipImmediately))
|
||||
}
|
||||
// update status if it's changed
|
||||
if original.Status.LastSkipped != schedule.Status.LastSkipped {
|
||||
if !equality.Semantic.DeepEqual(original.Status.LastSkipped, schedule.Status.LastSkipped) {
|
||||
scheduleNeedsPatch = true
|
||||
errStringArr = append(errStringArr, fmt.Sprintf("last skipped to %v", schedule.Status.LastSkipped))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user