Skip to content

Commit 4ce4a48

Browse files
authored
Merge pull request #9376 from Lyndon-Li/release-1.17
issue 9365: prevent multiple update of PVR
2 parents 3ae7183 + ec7fe10 commit 4ce4a48

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix issue #9365, prevent fake completion notification due to multiple update of single PVR

pkg/podvolume/restorer.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,18 @@ func newRestorer(
9292

9393
_, _ = pvrInformer.AddEventHandler(
9494
cache.ResourceEventHandlerFuncs{
95-
UpdateFunc: func(_, obj any) {
96-
pvr := obj.(*velerov1api.PodVolumeRestore)
95+
UpdateFunc: func(oldObj, newObj any) {
96+
pvr := newObj.(*velerov1api.PodVolumeRestore)
97+
pvrOld := oldObj.(*velerov1api.PodVolumeRestore)
98+
9799
if pvr.GetLabels()[velerov1api.RestoreUIDLabel] != string(restore.UID) {
98100
return
99101
}
100102

103+
if pvr.Status.Phase == pvrOld.Status.Phase {
104+
return
105+
}
106+
101107
if pvr.Status.Phase == velerov1api.PodVolumeRestorePhaseCompleted || pvr.Status.Phase == velerov1api.PodVolumeRestorePhaseFailed || pvr.Status.Phase == velerov1api.PodVolumeRestorePhaseCanceled {
102108
r.resultsLock.Lock()
103109
defer r.resultsLock.Unlock()

0 commit comments

Comments
 (0)