Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

fix(shell): volumeServer.evacuate no longer panics on a nil volume (#9587)

Chris Lu4385b86bf1a6
diff --git a/weed/shell/command_volume_server_evacuate.go b/weed/shell/command_volume_server_evacuate.go
index cd636e9e87..e8a9b885af 100644
--- a/weed/shell/command_volume_server_evacuate.go
+++ b/weed/shell/command_volume_server_evacuate.go
@@ -136,7 +136,10 @@ func (c *commandVolumeServerEvacuate) evacuateNormalVolumes(commandEnv *CommandE
}
}
volumeReplicas, _ := collectVolumeReplicaLocations(c.topologyInfo)
- for _, vol := range diskInfo.VolumeInfos {
+ // A successful move calls adjustAfterMove, which removes the volume from
+ // this disk's VolumeInfos in place. Iterate over a snapshot so removals
+ // don't leave nil holes in the slice we are ranging over.
+ for _, vol := range slices.Clone(diskInfo.VolumeInfos) {
hasMoved, err := moveAwayOneNormalVolume(commandEnv, volumeReplicas, vol, thisNode, otherNodes, applyChange)
if err != nil {
fmt.Fprintf(writer, "move away volume %d from %s: %v\n", vol.Id, volumeServer, err)