wait on parallel decom to complete before returning (#14764)

without this wait there is a potential for some objects
that are in actively being decommissioned would cancel,
however the decommission status might wrongly conclude
this as "Complete".

To avoid this make sure to add waitgroups on the parallel
workers, allowing parallel copies to complete fully before
we return.
This commit is contained in:
Harshavardhana 2022-04-18 13:26:29 -07:00 committed by GitHub
parent c526fa9119
commit 7e248fc0ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -603,6 +603,7 @@ func (z *erasureServerPools) decommissionPool(ctx context.Context, idx int, pool
decommissionEntry := func(entry metaCacheEntry) {
defer func() {
<-parallelWorkers
wg.Done()
}()
if entry.isDir() {
return
@ -719,12 +720,14 @@ func (z *erasureServerPools) decommissionPool(ctx context.Context, idx int, pool
reportNotFound: false,
agreed: func(entry metaCacheEntry) {
parallelWorkers <- struct{}{}
wg.Add(1)
go decommissionEntry(entry)
},
partial: func(entries metaCacheEntries, nAgreed int, errs []error) {
entry, ok := entries.resolve(&resolver)
if ok {
parallelWorkers <- struct{}{}
wg.Add(1)
go decommissionEntry(*entry)
}
},