From d315d012a46ee9dd23484a2c386dd2267764fc76 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 23 Jun 2023 07:44:18 -0700 Subject: [PATCH] decom: during multiple pool decom preserve current pool status (#17491) removal of completed pools must retain pool status of other pools in draining, to resume any remaining draining operations. --- cmd/erasure-server-pool-decom.go | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/cmd/erasure-server-pool-decom.go b/cmd/erasure-server-pool-decom.go index 1b0ae30cc..8f76cf448 100644 --- a/cmd/erasure-server-pool-decom.go +++ b/cmd/erasure-server-pool-decom.go @@ -461,22 +461,34 @@ func (z *erasureServerPools) Init(ctx context.Context) error { if !update { z.poolMeta = meta } else { - meta = poolMeta{} // to update write poolMeta fresh. + newMeta := poolMeta{} // to update write poolMeta fresh. // looks like new pool was added we need to update, // or this is a fresh installation (or an existing // installation with pool removed) - meta.Version = poolMetaVersion + newMeta.Version = poolMetaVersion for idx, pool := range z.serverPools { - meta.Pools = append(meta.Pools, PoolStatus{ + var skip bool + for _, currentPool := range meta.Pools { + // Preserve any current pool status. + if currentPool.CmdLine == pool.endpoints.CmdLine { + newMeta.Pools = append(newMeta.Pools, currentPool) + skip = true + break + } + } + if skip { + continue + } + newMeta.Pools = append(newMeta.Pools, PoolStatus{ CmdLine: pool.endpoints.CmdLine, ID: idx, LastUpdate: UTCNow(), }) } - if err = meta.save(ctx, z.serverPools); err != nil { + if err = newMeta.save(ctx, z.serverPools); err != nil { return err } - z.poolMeta = meta + z.poolMeta = newMeta } pools := meta.returnResumablePools() @@ -1103,7 +1115,9 @@ func (z *erasureServerPools) Decommission(ctx context.Context, indices ...int) e } for _, idx := range indices { - go z.doDecommissionInRoutine(ctx, idx) + // decommission all pools serially one after + // the other. + z.doDecommissionInRoutine(ctx, idx) } // Successfully started decommissioning.