Skip to content

Commit

Permalink
fix(replica-auto-balance): loop when node has no schedulable disk
Browse files Browse the repository at this point in the history
ref: 6508

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
  • Loading branch information
c3y1huang authored and David Ko committed Dec 7, 2023
1 parent 266210f commit d4700d3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions datastore/longhorn.go
Original file line number Diff line number Diff line change
Expand Up @@ -2480,11 +2480,24 @@ func filterReadyNodes(nodes map[string]*longhorn.Node) map[string]*longhorn.Node
})
}

// filterSchedulableNodes returns only the nodes that are ready
// filterSchedulableNodes returns only the nodes that are ready and have at least one schedulable disk
func filterSchedulableNodes(nodes map[string]*longhorn.Node) map[string]*longhorn.Node {
return filterNodes(nodes, func(node *longhorn.Node) bool {
nodeSchedulableCondition := types.GetCondition(node.Status.Conditions, longhorn.NodeConditionTypeSchedulable)
return nodeSchedulableCondition.Status == longhorn.ConditionStatusTrue
if nodeSchedulableCondition.Status != longhorn.ConditionStatusTrue {
return false
}

for _, disk := range node.Spec.Disks {
if disk.EvictionRequested {
continue
}

if disk.AllowScheduling {
return true
}
}
return false
})
}

Expand Down

0 comments on commit d4700d3

Please sign in to comment.