mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-03-20 23:07:29 +01:00
Change dtermineState to enforce priority order
Make exception if node is idle + down, then final state is idle Entire-Checkpoint: 92c797737df8
This commit is contained in:
@@ -34,21 +34,26 @@ func metricListToNames(metricList map[string]*schema.Metric) []string {
|
|||||||
return names
|
return names
|
||||||
}
|
}
|
||||||
|
|
||||||
// this routine assumes that only one of them exists per node
|
// determineState resolves multiple states to a single state using priority order:
|
||||||
|
// allocated > reserved > idle > down > mixed.
|
||||||
|
// Exception: if both idle and down are present, idle is returned.
|
||||||
func determineState(states []string) schema.SchedulerState {
|
func determineState(states []string) schema.SchedulerState {
|
||||||
for _, state := range states {
|
stateSet := make(map[string]bool, len(states))
|
||||||
switch strings.ToLower(state) {
|
for _, s := range states {
|
||||||
case "allocated":
|
stateSet[strings.ToLower(s)] = true
|
||||||
return schema.NodeStateAllocated
|
}
|
||||||
case "reserved":
|
|
||||||
return schema.NodeStateReserved
|
switch {
|
||||||
case "idle":
|
case stateSet["allocated"]:
|
||||||
return schema.NodeStateIdle
|
return schema.NodeStateAllocated
|
||||||
case "down":
|
case stateSet["reserved"]:
|
||||||
return schema.NodeStateDown
|
return schema.NodeStateReserved
|
||||||
case "mixed":
|
case stateSet["idle"]:
|
||||||
return schema.NodeStateMixed
|
return schema.NodeStateIdle
|
||||||
}
|
case stateSet["down"]:
|
||||||
|
return schema.NodeStateDown
|
||||||
|
case stateSet["mixed"]:
|
||||||
|
return schema.NodeStateMixed
|
||||||
}
|
}
|
||||||
|
|
||||||
return schema.NodeStateUnknown
|
return schema.NodeStateUnknown
|
||||||
|
|||||||
Reference in New Issue
Block a user