Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion pkg/podvolume/backupper.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,28 @@
return
}

statusChangedToFinal := true
existObj, exist, err := b.pvbIndexer.Get(pvb)
if err == nil && exist {
existPVB, ok := existObj.(*velerov1api.PodVolumeBackup)
// the PVB in the indexer is already in final status, no need to call WaitGroup.Done()
if ok && (existPVB.Status.Phase == velerov1api.PodVolumeBackupPhaseCompleted ||
existPVB.Status.Phase == velerov1api.PodVolumeBackupPhaseFailed) {
statusChangedToFinal = false
}

Check warning on line 184 in pkg/podvolume/backupper.go

View check run for this annotation

Codecov / codecov/patch

pkg/podvolume/backupper.go#L183-L184

Added lines #L183 - L184 were not covered by tests
}

// the Indexer inserts PVB directly if the PVB to be updated doesn't exist
if err := b.pvbIndexer.Update(pvb); err != nil {
log.WithError(err).Errorf("failed to update PVB %s/%s in indexer", pvb.Namespace, pvb.Name)
}
b.wg.Done()

// call WaitGroup.Done() once only when the PVB changes to final status the first time.
// This avoid the cases that the handler gets multiple update events whose PVBs are all in final status
// which causes panic with "negative WaitGroup counter" error
if statusChangedToFinal {
b.wg.Done()
}
},
},
)
Expand Down
Loading