Skip to content

Commit 132569b

Browse files
authored
Fix bug affecting REBOOT_WHEN_IDLE hosts (#1153)
When a host marked as REBOOT_WHEN_IDLE was still reporting a running frame, it would automatically revert the host's status to UP. The logic has been fixed to only trigger the status update on boot reports.
1 parent de10306 commit 132569b

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

cuebot/src/main/java/com/imageworks/spcue/dispatcher/HostReportHandler.java

+26-27
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public void handleHostReport(HostReport report, boolean isBoot) {
155155
rhost.getLoad(), new Timestamp(rhost.getBootTime() * 1000l),
156156
rhost.getAttributesMap().get("SP_OS"));
157157

158-
changeHardwareState(host, report.getHost().getState());
158+
changeHardwareState(host, report.getHost().getState(), isBoot);
159159
changeNimbyState(host, report.getHost());
160160

161161
/**
@@ -304,46 +304,45 @@ else if (!dispatchSupport.isCueBookable(host)) {
304304
*
305305
* If a host pings in with a different hardware state than what
306306
* is currently in the DB, the state is updated. If the hardware
307-
* state is Rebooting RebootWhenIdle, then state can only be
307+
* state is Rebooting or RebootWhenIdle, then state can only be
308308
* updated with a boot report. If the state is Repair, then state is
309309
* never updated via RQD.
310310
*
311311
* @param host
312312
* @param reportState
313+
* @param isBoot
313314
*/
314315
private void changeHardwareState(DispatchHost host,
315-
HardwareState reportState) {
316+
HardwareState reportState, boolean isBoot) {
316317

317-
/*
318-
* If the states are the same there is no reason
319-
* to do this update.
320-
*/
318+
319+
// If the states are the same there is no reason to do this update.
321320
if (host.hardwareState.equals(reportState)) {
322321
return;
323322
}
324323

325-
/*
326-
* Do not change the state of the host if its in a
327-
* repair state. Removing the repair state must
328-
* be done manually.
329-
*/
330-
if (host.hardwareState.equals(HardwareState.REPAIR)) {
331-
return;
332-
}
324+
switch (host.hardwareState) {
325+
case DOWN:
326+
hostManager.setHostState(host, HardwareState.UP);
327+
host.hardwareState = HardwareState.UP;
328+
break;
329+
case REBOOTING:
330+
case REBOOT_WHEN_IDLE:
331+
// Rebooting hosts only change to UP when processing a boot report
332+
if (isBoot) {
333+
hostManager.setHostState(host, HardwareState.UP);
334+
host.hardwareState = HardwareState.UP;
335+
}
336+
break;
337+
case REPAIR:
338+
// Do not change the state of the host if its in a repair state.
339+
break;
340+
default:
341+
hostManager.setHostState(host, reportState);
342+
host.hardwareState = reportState;
343+
break;
333344

334-
/*
335-
* Hosts in these states always change to Up.
336-
*/
337-
if (reportState.equals(HardwareState.UP) && EnumSet.of(HardwareState.DOWN,
338-
HardwareState.REBOOTING,
339-
HardwareState.REBOOT_WHEN_IDLE).contains(host.hardwareState)) {
340-
hostManager.setHostState(host, HardwareState.UP);
341345
}
342-
else {
343-
hostManager.setHostState(host, reportState);
344-
}
345-
346-
host.hardwareState = reportState;
347346
}
348347

349348
/**

0 commit comments

Comments
 (0)