File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ https://velero.io/docs/v1.16/
1313https://velero.io/docs/v1.16/upgrade-to-1.16/
1414
1515### All Changes
16+ * Call WaitGroup.Done() once only when PVB changes to final status the first time to avoid panic (#8940 , @ywk253100 )
1617 * Add VolumeSnapshotContent into the RIA and the mustHave resource list. (#8926 , @blackpiglet )
1718 * Warn for not found error in patching managed fields (#8916 , @sseago )
1819 * Fix issue 8878, relief node os deduction error checks (#8911 , @Lyndon-Li )
Original file line number Diff line number Diff line change @@ -173,11 +173,28 @@ func newBackupper(
173173 return
174174 }
175175
176+ statusChangedToFinal := true
177+ existObj , exist , err := b .pvbIndexer .Get (pvb )
178+ if err == nil && exist {
179+ existPVB , ok := existObj .(* velerov1api.PodVolumeBackup )
180+ // the PVB in the indexer is already in final status, no need to call WaitGroup.Done()
181+ if ok && (existPVB .Status .Phase == velerov1api .PodVolumeBackupPhaseCompleted ||
182+ existPVB .Status .Phase == velerov1api .PodVolumeBackupPhaseFailed ) {
183+ statusChangedToFinal = false
184+ }
185+ }
186+
176187 // the Indexer inserts PVB directly if the PVB to be updated doesn't exist
177188 if err := b .pvbIndexer .Update (pvb ); err != nil {
178189 log .WithError (err ).Errorf ("failed to update PVB %s/%s in indexer" , pvb .Namespace , pvb .Name )
179190 }
180- b .wg .Done ()
191+
192+ // call WaitGroup.Done() once only when the PVB changes to final status the first time.
193+ // This avoid the cases that the handler gets multiple update events whose PVBs are all in final status
194+ // which causes panic with "negative WaitGroup counter" error
195+ if statusChangedToFinal {
196+ b .wg .Done ()
197+ }
181198 },
182199 },
183200 )
You can’t perform that action at this time.
0 commit comments