From 71c95ad0d02111c7c472b1cd5dc16e985d816420 Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Wed, 18 Jan 2023 17:24:23 -0800 Subject: [PATCH] Signal stop-rebalance to all rebalancing pools (#16438) --- cmd/erasure-server-pool-rebalance.go | 1 + cmd/notification.go | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/cmd/erasure-server-pool-rebalance.go b/cmd/erasure-server-pool-rebalance.go index d4f57b008..c23c10d83 100644 --- a/cmd/erasure-server-pool-rebalance.go +++ b/cmd/erasure-server-pool-rebalance.go @@ -353,6 +353,7 @@ func (z *erasureServerPools) rebalanceBuckets(ctx context.Context, poolIdx int) z.rebalMu.Lock() z.rebalMeta.PoolStats[poolIdx].Info.Status = rebalStopped z.rebalMeta.PoolStats[poolIdx].Info.EndTime = now + z.rebalMeta.cancel = nil // remove the already used context.CancelFunc z.rebalMu.Unlock() rebalDone = true diff --git a/cmd/notification.go b/cmd/notification.go index 93db127ba..8be8557f5 100644 --- a/cmd/notification.go +++ b/cmd/notification.go @@ -649,6 +649,15 @@ func (sys *NotificationSys) StopRebalance(ctx context.Context) { logger.LogIf(logger.SetReqInfo(ctx, reqInfo), nErr.Err) } } + + objAPI := newObjectLayerFn() + if objAPI == nil { + logger.LogIf(ctx, errServerNotInitialized) + return + } + if pools, ok := objAPI.(*erasureServerPools); ok { + pools.StopRebalance() + } } // LoadRebalanceMeta notifies all peers to load rebalance.bin from object layer.