controller: Avoid using engine status during live upgrade
Since the status fields will be unset during live upgrade. Using
the replica mode map in the engine status to distinguish the old
replicas may leed to an empty result.
Longhorn 2805
@@ -2240,10 +2240,8 @@ func (vc *VolumeController) upgradeEngineForVolume(v *longhorn.Volume, e *longho
dataPathToNewReplica := map[string]*longhorn.Replica{}
for _, r := range rs {
dataPath := types.GetReplicaDataPath(r.Spec.DiskPath, r.Spec.DataDirectoryName)
- if r.Spec.EngineImage == v.Status.CurrentImage && r.Status.CurrentState == types.InstanceStateRunning {
- if mode, exists := e.Status.ReplicaModeMap[r.Name]; exists && mode == types.ReplicaModeRW {
+ if r.Spec.EngineImage == v.Status.CurrentImage && r.Status.CurrentState == types.InstanceStateRunning && r.Spec.HealthyAt != "" {
dataPathToOldRunningReplica[dataPath] = r
- }
} else if r.Spec.EngineImage == v.Spec.EngineImage {
dataPathToNewReplica[dataPath] = r
} else {
