From 38bbef7ec1e945eef626bf6f638cbb0ec4dbe20b Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 16 Feb 2021 04:16:46 -0800 Subject: [PATCH] avoid nil --- weed/shell/command_volume_balance.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/weed/shell/command_volume_balance.go b/weed/shell/command_volume_balance.go index 9fa915ea4..f5fdf2216 100644 --- a/weed/shell/command_volume_balance.go +++ b/weed/shell/command_volume_balance.go @@ -205,7 +205,10 @@ type CapacityFunc func(*master_pb.DataNodeInfo) int func capacityByMaxVolumeCount(diskType types.DiskType) CapacityFunc { return func(info *master_pb.DataNodeInfo) int { - diskInfo := info.DiskInfos[string(diskType)] + diskInfo, found := info.DiskInfos[string(diskType)] + if !found { + return 0 + } return int(diskInfo.MaxVolumeCount) } }