mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-30 11:46:16 +00:00
Fix switch case ordering bug in filterBackupOwnerReferences (#10161)
* Fix switch case ordering in filterBackupOwnerReferences (Issue #10160) When client.Get returns a transient (non-NotFound) error, the previous case ordering caused the UID mismatch case to fire against a zero-value struct, silently dropping the owner reference and logging a misleading 'mismatched UIDs' warning instead of the intended error log. Fix: move the general error handler before the UID mismatch check so it is evaluated while err is still relevant. The UID check now only runs when err == nil (i.e. the Schedule was successfully fetched). Also add a test case that injects a transient Get error via the fake client interceptor to verify the owner reference is preserved. Signed-off-by: aftab <aftab123215@gmail.com> * Add changelog for #10160 Signed-off-by: aftab <aftab123215@gmail.com> --------- Signed-off-by: aftab <aftab123215@gmail.com>
This commit is contained in:
@@ -271,11 +271,11 @@ func (b *backupSyncReconciler) filterBackupOwnerReferences(ctx context.Context,
|
||||
case err != nil && apierrors.IsNotFound(err):
|
||||
log.Warnf("Removing missing schedule ownership reference %s/%s from backup", backup.Namespace, v.Name)
|
||||
continue
|
||||
case err != nil && !apierrors.IsNotFound(err):
|
||||
log.WithError(errors.WithStack(err)).Error("Error finding schedule ownership reference, keeping schedule on backup")
|
||||
case schedule.UID != v.UID:
|
||||
log.Warnf("Removing schedule ownership reference with mismatched UIDs. Expected %s, got %s", v.UID, schedule.UID)
|
||||
continue
|
||||
case err != nil && !apierrors.IsNotFound(err):
|
||||
log.WithError(errors.WithStack(err)).Error("Error finding schedule ownership reference, keeping schedule on backup")
|
||||
}
|
||||
default:
|
||||
log.Warnf("Unable to check ownership reference for unknown kind, %s", v.Kind)
|
||||
|
||||
Reference in New Issue
Block a user