From 0c6ac77008f4a98de4b61abff7c424f767c03188 Mon Sep 17 00:00:00 2001 From: chrislu Date: Fri, 21 Nov 2025 17:39:20 -0800 Subject: [PATCH] accurate error message --- weed/shell/command_ec_rebuild.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/weed/shell/command_ec_rebuild.go b/weed/shell/command_ec_rebuild.go index f9e3afdcc..79acebff1 100644 --- a/weed/shell/command_ec_rebuild.go +++ b/weed/shell/command_ec_rebuild.go @@ -164,6 +164,7 @@ func (erb *ecRebuilder) selectAndReserveRebuilder(collection string, volumeId ne var bestNode *EcNode var bestSlotsNeeded int var maxAvailableSlots int + var minSlotsNeeded int = erasure_coding.TotalShardsCount // Start with maximum possible for _, node := range erb.ecNodes { localShards := erb.countLocalShards(node, collection, volumeId) slotsNeeded := erasure_coding.TotalShardsCount - localShards @@ -175,6 +176,10 @@ func (erb *ecRebuilder) selectAndReserveRebuilder(collection string, volumeId ne maxAvailableSlots = node.freeEcSlot } + if slotsNeeded < minSlotsNeeded { + minSlotsNeeded = slotsNeeded + } + if node.freeEcSlot >= slotsNeeded { if bestNode == nil || node.freeEcSlot > bestNode.freeEcSlot { bestNode = node @@ -184,8 +189,8 @@ func (erb *ecRebuilder) selectAndReserveRebuilder(collection string, volumeId ne } if bestNode == nil { - return nil, 0, fmt.Errorf("no node has sufficient free slots for volume %d (need %d slots, max available: %d)", - volumeId, erasure_coding.TotalShardsCount, maxAvailableSlots) + return nil, 0, fmt.Errorf("no node has sufficient free slots for volume %d (need at least %d slots, max available: %d)", + volumeId, minSlotsNeeded, maxAvailableSlots) } // Reserve slots only for non-local shards