issue 9365: prevent multiple update of PVR

Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
Lyndon-Li
2025-10-29 14:17:54 +08:00
parent 0d7ef85f98
commit 31a7236c7d
2 changed files with 9 additions and 2 deletions

View File

@@ -92,12 +92,18 @@ func newRestorer(
_, _ = pvrInformer.AddEventHandler(
cache.ResourceEventHandlerFuncs{
UpdateFunc: func(_, obj any) {
pvr := obj.(*velerov1api.PodVolumeRestore)
UpdateFunc: func(oldObj, newObj any) {
pvr := newObj.(*velerov1api.PodVolumeRestore)
pvrOld := oldObj.(*velerov1api.PodVolumeRestore)
if pvr.GetLabels()[velerov1api.RestoreUIDLabel] != string(restore.UID) {
return
}
if pvr.Status.Phase == pvrOld.Status.Phase {
return
}
if pvr.Status.Phase == velerov1api.PodVolumeRestorePhaseCompleted || pvr.Status.Phase == velerov1api.PodVolumeRestorePhaseFailed || pvr.Status.Phase == velerov1api.PodVolumeRestorePhaseCanceled {
r.resultsLock.Lock()
defer r.resultsLock.Unlock()