mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-20 14:17:07 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user