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

adjustAfterMove now removes the moved volume from the source disk's
VolumeInfos in place: it swaps the entry with the last one and nils the
tail. evacuateNormalVolumes ranges directly over that same slice, so the
niled tail slot is later read as a nil *VolumeInformationMessage and the
move attempt panics on vol.DiskType.

Iterate over a snapshot of the slice so in-place removals during a move
cannot leave nil holes in the loop.
This commit is contained in:
Chris Lu
2026-05-20 10:27:00 -07:00
committed by GitHub
parent c00aa90990
commit 4385b86bf1
+4 -1
View File
@@ -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)