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
|
||||
}
|
||||
|
||||
// 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 {
|
||||
for _, state := range states {
|
||||
switch strings.ToLower(state) {
|
||||
case "allocated":
|
||||
return schema.NodeStateAllocated
|
||||
case "reserved":
|
||||
return schema.NodeStateReserved
|
||||
case "idle":
|
||||
return schema.NodeStateIdle
|
||||
case "down":
|
||||
return schema.NodeStateDown
|
||||
case "mixed":
|
||||
return schema.NodeStateMixed
|
||||
stateSet := make(map[string]bool, len(states))
|
||||
for _, s := range states {
|
||||
stateSet[strings.ToLower(s)] = true
|
||||
}
|
||||
|
||||
switch {
|
||||
case stateSet["allocated"]:
|
||||
return schema.NodeStateAllocated
|
||||
case stateSet["reserved"]:
|
||||
return schema.NodeStateReserved
|
||||
case stateSet["idle"]:
|
||||
return schema.NodeStateIdle
|
||||
case stateSet["down"]:
|
||||
return schema.NodeStateDown
|
||||
case stateSet["mixed"]:
|
||||
return schema.NodeStateMixed
|
||||
}
|
||||
|
||||
return schema.NodeStateUnknown
|
||||
|
||||
Reference in New Issue
Block a user