Skip to content

Commit 3069cc6

Browse files
committed
add control cmd
1 parent 053cbd0 commit 3069cc6

File tree

4 files changed

+43
-18
lines changed

4 files changed

+43
-18
lines changed

internal/cinfo/cinfo.go

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,44 @@ func Query() util.CraneCmdError {
4646
resourceStateList = append(resourceStateList, protos.CranedResourceState_CRANE_MIX)
4747
case "alloc":
4848
resourceStateList = append(resourceStateList, protos.CranedResourceState_CRANE_ALLOC)
49-
case "down":
50-
resourceStateList = append(resourceStateList, protos.CranedResourceState_CRANE_DOWN)
51-
case "none":
52-
controlStateList = append(controlStateList, protos.CranedControlState_CRANE_NONE)
53-
case "drain":
54-
controlStateList = append(controlStateList, protos.CranedControlState_CRANE_DRAIN)
49+
case "sleeped":
50+
resourceStateList = append(resourceStateList, protos.CranedResourceState_CRANE_SLEEPED)
51+
case "shutdown":
52+
resourceStateList = append(resourceStateList, protos.CranedResourceState_CRANE_SHUTDOWN)
53+
case "waking":
54+
resourceStateList = append(resourceStateList, protos.CranedResourceState_CRANE_WAKING_UP)
55+
case "preparing_sleep":
56+
resourceStateList = append(resourceStateList, protos.CranedResourceState_CRANE_PREPARING_SLEEP)
57+
case "poweringup":
58+
resourceStateList = append(resourceStateList, protos.CranedResourceState_CRANE_POWERING_UP)
59+
case "shuttingdown":
60+
resourceStateList = append(resourceStateList, protos.CranedResourceState_CRANE_SHUTTING_DOWN)
61+
case "unknown":
62+
resourceStateList = append(resourceStateList, protos.CranedResourceState_CRANE_UNKNOWN)
5563
default:
5664
log.Errorf("Invalid state given: %s.\n", FlagFilterCranedStates[i])
5765
return util.ErrorCmdArg
5866
}
5967
}
68+
69+
serviceUnavailableStateList := []protos.CranedResourceState{
70+
protos.CranedResourceState_CRANE_SLEEPED,
71+
protos.CranedResourceState_CRANE_SHUTDOWN,
72+
protos.CranedResourceState_CRANE_WAKING_UP,
73+
protos.CranedResourceState_CRANE_PREPARING_SLEEP,
74+
protos.CranedResourceState_CRANE_POWERING_UP,
75+
protos.CranedResourceState_CRANE_SHUTTING_DOWN,
76+
protos.CranedResourceState_CRANE_UNKNOWN,
77+
}
78+
6079
if len(resourceStateList) == 0 {
6180
if FlagFilterRespondingOnly {
6281
resourceStateList = append(resourceStateList, protos.CranedResourceState_CRANE_IDLE, protos.CranedResourceState_CRANE_MIX, protos.CranedResourceState_CRANE_ALLOC)
6382
} else if FlagFilterDownOnly {
64-
resourceStateList = append(resourceStateList, protos.CranedResourceState_CRANE_DOWN)
83+
resourceStateList = append(resourceStateList, serviceUnavailableStateList...)
6584
} else {
66-
resourceStateList = append(resourceStateList, protos.CranedResourceState_CRANE_IDLE, protos.CranedResourceState_CRANE_MIX, protos.CranedResourceState_CRANE_ALLOC, protos.CranedResourceState_CRANE_DOWN)
85+
resourceStateList = append(resourceStateList, protos.CranedResourceState_CRANE_IDLE, protos.CranedResourceState_CRANE_MIX, protos.CranedResourceState_CRANE_ALLOC)
86+
resourceStateList = append(resourceStateList, serviceUnavailableStateList...)
6787
}
6888
}
6989
if len(controlStateList) == 0 {

plugin/energy/energy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (p EnergyPlugin) CreateCgroupHook(ctx *api.PluginContext) {
131131
log.Infof("CreateCgroupHook received for cgroup: %s", req.Cgroup)
132132

133133
boundGPUs := getBoundGPUs(req.Resource, globalMonitor.config.Monitor.GPUType)
134-
globalMonitor.monitor.UpdateTaskCount(true)
134+
globalMonitor.monitor.NodeMonitor.UpdateTaskCount(true)
135135
globalMonitor.monitor.TaskMonitor.Start(req.TaskId, req.Cgroup, boundGPUs)
136136
}
137137

@@ -143,7 +143,7 @@ func (p EnergyPlugin) DestroyCgroupHook(ctx *api.PluginContext) {
143143
}
144144

145145
log.Infof("DestroyCgroupHook received for cgroup: %s", req.Cgroup)
146-
globalMonitor.monitor.UpdateTaskCount(false)
146+
globalMonitor.monitor.NodeMonitor.UpdateTaskCount(false)
147147
globalMonitor.monitor.TaskMonitor.Stop(req.TaskId)
148148
}
149149

plugin/energy/pkg/monitor/monitor.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,3 @@ func (sm *Monitor) Close() {
6868
sm.NodeMonitor.Close()
6969
sm.TaskMonitor.Close()
7070
}
71-
72-
func (sm *Monitor) UpdateTaskCount(increment bool) {
73-
sm.NodeMonitor.UpdateTaskCount(increment)
74-
}

protos/PublicDefs.proto

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,19 @@ enum PartitionState {
7979
}
8080

8181
enum CranedResourceState {
82-
CRANE_IDLE = 0;
83-
CRANE_MIX = 1;
84-
CRANE_ALLOC = 2;
85-
CRANE_DOWN = 3;
82+
// Running
83+
CRANE_IDLE = 0;
84+
CRANE_ALLOC = 1;
85+
CRANE_MIX = 2;
86+
87+
// Not Running
88+
CRANE_SLEEPED = 3;
89+
CRANE_SHUTDOWN = 4;
90+
CRANE_WAKING_UP = 5;
91+
CRANE_PREPARING_SLEEP = 6;
92+
CRANE_POWERING_UP = 7;
93+
CRANE_SHUTTING_DOWN = 8;
94+
CRANE_UNKNOWN = 9;
8695
}
8796

8897
enum CranedControlState {

0 commit comments

Comments
 (0)