Skip to content

Commit

Permalink
Fix bug two active engine when volume migrating
Browse files Browse the repository at this point in the history
Only switch the new engine to active if we finish cleaning up
the extra engines

longhorn-6642

Signed-off-by: Phan Le <phan.le@suse.com>
  • Loading branch information
PhanLe1010 authored and David Ko committed Sep 19, 2023
1 parent 57ee711 commit eb1602c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions controller/volume_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3807,6 +3807,8 @@ func (c *VolumeController) processMigration(v *longhorn.Volume, es map[string]*l
}
}

currentEngine.Spec.Active = true

// cleanupCorruptedOrStaleReplicas() will take care of old replicas
if err := c.switchActiveReplicas(rs, func(r *longhorn.Replica, engineName string) bool {
return r.Spec.EngineName == engineName
Expand Down
8 changes: 6 additions & 2 deletions datastore/longhorn.go
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,12 @@ func GetCurrentEngineAndExtras(v *longhorn.Volume, es map[string]*longhorn.Engin
if currentEngine == nil {
logrus.Warnf("failed to directly pick up the current one from multiple engines for volume %v, fall back to detect the new current engine, "+
"current node %v, desire node %v", v.Name, v.Status.CurrentNodeID, v.Spec.NodeID)
return GetNewCurrentEngineAndExtras(v, es)
newCurrentEngine, extras, err := GetNewCurrentEngineAndExtras(v, es)
if err != nil {
return nil, nil, err
}
newCurrentEngine.Spec.Active = true
return newCurrentEngine, extras, nil
}
return
}
Expand All @@ -988,7 +993,6 @@ func GetNewCurrentEngineAndExtras(v *longhorn.Volume, es map[string]*longhorn.En
return nil, nil, fmt.Errorf("BUG: found the second new active engine %v besides %v", e.Name, currentEngine.Name)
}
currentEngine = e
currentEngine.Spec.Active = true
} else {
extras = append(extras, e)
}
Expand Down

0 comments on commit eb1602c

Please sign in to comment.