From 141f662734b56ac08f96ebd28552a8002002c124 Mon Sep 17 00:00:00 2001 From: chrislu Date: Fri, 1 Jul 2022 12:16:18 -0700 Subject: [PATCH] edge case checking when volume server does not have capacity to balance fix https://github.com/chrislusf/seaweedfs/issues/3257 --- weed/shell/command_volume_balance.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/weed/shell/command_volume_balance.go b/weed/shell/command_volume_balance.go index 462143e25..8619ad99e 100644 --- a/weed/shell/command_volume_balance.go +++ b/weed/shell/command_volume_balance.go @@ -259,6 +259,10 @@ func balanceSelectedVolume(commandEnv *CommandEnv, diskType types.DiskType, volu slices.SortFunc(nodesWithCapacity, func(a, b *Node) bool { return a.localVolumeRatio(capacityFunc) < b.localVolumeRatio(capacityFunc) }) + if len(nodesWithCapacity) == 0 { + fmt.Printf("no volume server found with capacity for %s", diskType.ReadableString()) + return nil + } fullNode := nodesWithCapacity[len(nodesWithCapacity)-1] var candidateVolumes []*master_pb.VolumeInformationMessage for _, v := range fullNode.selectedVolumes {