From 64e803b136cf0233d2d23442862b70be23076a80 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 6 Sep 2024 06:20:19 -0700 Subject: [PATCH] fix: avoid waiting on rebalance metadata (#20392) rebalance metadata is good to have only, if it cannot be loaded when starting MinIO for some reason we can possibly ignore it and move on and let user start rebalance again if needed. --- cmd/erasure-server-pool-decom.go | 11 ++++------- cmd/erasure-server-pool-rebalance.go | 19 +++++++------------ 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/cmd/erasure-server-pool-decom.go b/cmd/erasure-server-pool-decom.go index 1a82e1005..fda8401c6 100644 --- a/cmd/erasure-server-pool-decom.go +++ b/cmd/erasure-server-pool-decom.go @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2023 MinIO, Inc. +// Copyright (c) 2015-2024 MinIO, Inc. // // This file is part of MinIO Object Storage stack // @@ -490,14 +490,11 @@ const ( // in 'pool.bin', this is eventually used for decommissioning the pool. func (z *erasureServerPools) Init(ctx context.Context) error { // Load rebalance metadata if present - err := z.loadRebalanceMeta(ctx) - if err != nil { - return fmt.Errorf("failed to load rebalance data: %w", err) + if err := z.loadRebalanceMeta(ctx); err == nil { + // Start rebalance routine if we can reload rebalance metadata. + z.StartRebalance() } - // Start rebalance routine - z.StartRebalance() - meta := poolMeta{} if err := meta.load(ctx, z.serverPools[0], z.serverPools); err != nil { return err diff --git a/cmd/erasure-server-pool-rebalance.go b/cmd/erasure-server-pool-rebalance.go index 749cf4605..38d68de0e 100644 --- a/cmd/erasure-server-pool-rebalance.go +++ b/cmd/erasure-server-pool-rebalance.go @@ -110,19 +110,14 @@ var errRebalanceNotStarted = errors.New("rebalance not started") func (z *erasureServerPools) loadRebalanceMeta(ctx context.Context) error { r := &rebalanceMeta{} - err := r.load(ctx, z.serverPools[0]) - if err != nil { - if errors.Is(err, errConfigNotFound) { - return nil - } - return err + if err := r.load(ctx, z.serverPools[0]); err == nil { + z.rebalMu.Lock() + z.rebalMeta = r + z.updateRebalanceStats(ctx) + z.rebalMu.Unlock() + } else if !errors.Is(err, errConfigNotFound) { + rebalanceLogIf(ctx, fmt.Errorf("failed to load rebalance metadata, continue to restart rebalance as needed: %w", err)) } - - z.rebalMu.Lock() - z.rebalMeta = r - z.updateRebalanceStats(ctx) - z.rebalMu.Unlock() - return nil }