Skip to content

Commit

Permalink
feat(v2 upgrade/scheduler): disable v2 replica scheduling when node i…
Browse files Browse the repository at this point in the history
…s being lively upgraded

Longhorn 9104

Signed-off-by: Derek Su <[email protected]>
  • Loading branch information
derekbit committed Dec 15, 2024
1 parent 35a6d99 commit 2f47877
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions scheduler/replica_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (rcs *ReplicaScheduler) ScheduleReplica(replica *longhorn.Replica, replicas
// - MultiError for non-fatal errors encountered.
// - Error for any fatal errors encountered.
func (rcs *ReplicaScheduler) FindDiskCandidates(replica *longhorn.Replica, replicas map[string]*longhorn.Replica, volume *longhorn.Volume) (map[string]*Disk, util.MultiError, error) {
nodesInfo, err := rcs.getNodeInfo()
nodesInfo, err := rcs.getNodeInfo(volume.Spec.DataEngine)
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -489,7 +489,7 @@ func filterDisksWithMatchingReplicas(disks map[string]*Disk, replicas map[string
return disks
}

func (rcs *ReplicaScheduler) getNodeInfo() (map[string]*longhorn.Node, error) {
func (rcs *ReplicaScheduler) getNodeInfo(dataEngine longhorn.DataEngineType) (map[string]*longhorn.Node, error) {
nodeInfo, err := rcs.ds.ListNodes()
if err != nil {
return nil, err
Expand All @@ -511,6 +511,14 @@ func (rcs *ReplicaScheduler) getNodeInfo() (map[string]*longhorn.Node, error) {
if nodeSchedulableCondition.Status != longhorn.ConditionStatusTrue {
continue
}

if types.IsDataEngineV2(dataEngine) {
dataEngineUpgradeRequestedCondition := types.GetCondition(node.Status.Conditions, longhorn.NodeConditionTypeDataEngineUpgradeRequested)
if dataEngineUpgradeRequestedCondition.Status != longhorn.ConditionStatusTrue {
continue
}
}

if !node.Spec.AllowScheduling {
continue
}
Expand Down Expand Up @@ -573,7 +581,7 @@ func (rcs *ReplicaScheduler) CheckAndReuseFailedReplica(replicas map[string]*lon

replicas = filterActiveReplicas(replicas)

allNodesInfo, err := rcs.getNodeInfo()
allNodesInfo, err := rcs.getNodeInfo(volume.Spec.DataEngine)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 2f47877

Please sign in to comment.