Skip to content

Commit

Permalink
Fix bug affecting REBOOT_WHEN_IDLE hosts (#1153)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DiegoTavares authored Jul 8, 2022
1 parent de10306 commit 132569b
Showing 1 changed file with 26 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void handleHostReport(HostReport report, boolean isBoot) {
rhost.getLoad(), new Timestamp(rhost.getBootTime() * 1000l),
rhost.getAttributesMap().get("SP_OS"));

changeHardwareState(host, report.getHost().getState());
changeHardwareState(host, report.getHost().getState(), isBoot);
changeNimbyState(host, report.getHost());

/**
Expand Down Expand Up @@ -304,46 +304,45 @@ else if (!dispatchSupport.isCueBookable(host)) {
*
* If a host pings in with a different hardware state than what
* is currently in the DB, the state is updated. If the hardware
* state is Rebooting RebootWhenIdle, then state can only be
* state is Rebooting or RebootWhenIdle, then state can only be
* updated with a boot report. If the state is Repair, then state is
* never updated via RQD.
*
* @param host
* @param reportState
* @param isBoot
*/
private void changeHardwareState(DispatchHost host,
HardwareState reportState) {
HardwareState reportState, boolean isBoot) {

/*
* If the states are the same there is no reason
* to do this update.
*/

// If the states are the same there is no reason to do this update.
if (host.hardwareState.equals(reportState)) {
return;
}

/*
* Do not change the state of the host if its in a
* repair state. Removing the repair state must
* be done manually.
*/
if (host.hardwareState.equals(HardwareState.REPAIR)) {
return;
}
switch (host.hardwareState) {
case DOWN:
hostManager.setHostState(host, HardwareState.UP);
host.hardwareState = HardwareState.UP;
break;
case REBOOTING:
case REBOOT_WHEN_IDLE:
// Rebooting hosts only change to UP when processing a boot report
if (isBoot) {
hostManager.setHostState(host, HardwareState.UP);
host.hardwareState = HardwareState.UP;
}
break;
case REPAIR:
// Do not change the state of the host if its in a repair state.
break;
default:
hostManager.setHostState(host, reportState);
host.hardwareState = reportState;
break;

/*
* Hosts in these states always change to Up.
*/
if (reportState.equals(HardwareState.UP) && EnumSet.of(HardwareState.DOWN,
HardwareState.REBOOTING,
HardwareState.REBOOT_WHEN_IDLE).contains(host.hardwareState)) {
hostManager.setHostState(host, HardwareState.UP);
}
else {
hostManager.setHostState(host, reportState);
}

host.hardwareState = reportState;
}

/**
Expand Down

0 comments on commit 132569b

Please sign in to comment.