From 8995d127d041d3b19d97c1d158c1cd9abf18f89f Mon Sep 17 00:00:00 2001 From: Eric Weber Date: Wed, 13 Dec 2023 13:22:45 -0600 Subject: [PATCH] Don't start migrating when a replica will start to rebuild Longhorn 6961 Signed-off-by: Eric Weber --- controller/volume_controller.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/controller/volume_controller.go b/controller/volume_controller.go index 28a890a2fd..24bbdc782a 100644 --- a/controller/volume_controller.go +++ b/controller/volume_controller.go @@ -3947,6 +3947,10 @@ func (c *VolumeController) prepareReplicasAndEngineForMigration(v *longhorn.Volu case longhorn.ReplicaModeRW: currentAvailableReplicas[dataPath] = r case "": + if _, ok := currentEngine.Spec.ReplicaAddressMap[r.Name]; ok { + log.Debugf("Need to revert rather than starting migration since the current replica %v is already in the engine spec, which means it may start rebuilding", r.Name) + return false, true, nil + } log.Warnf("Running replica %v wasn't added to engine, will ignore it and continue migration", r.Name) default: log.Warnf("Unexpected mode %v for the current replica %v, will ignore it and continue migration", currentEngine.Status.ReplicaModeMap[r.Name], r.Name)