Skip to content

Commit

Permalink
Prevent booking frames on hosts with full MCP
Browse files Browse the repository at this point in the history
- Call env.getRequiredProperty("dispatcher.min_bookable_free_mcp_kb", Long.class) inside the method changeHardwareState() to fetch this value instead of passing it as a function parameter. Fetching properties should be cheap.
- Code refactoring to log messages when the host is not bookable
  • Loading branch information
ramonfigueiredo committed Jul 27, 2023
1 parent 0706d46 commit 4e95928
Showing 1 changed file with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ public void handleHostReport(HostReport report, boolean isBoot) {

DispatchHost host;
RenderHost rhost = report.getHost();
Long minBookableFreeMCP = env.getRequiredProperty("dispatcher.min_bookable_free_mcp_kb", Long.class);
try {
host = hostManager.findDispatchHost(rhost.getName());
hostManager.setHostStatistics(host,
Expand All @@ -169,8 +168,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(), isBoot, report.getHost().getFreeMcp(),
minBookableFreeMCP);
changeHardwareState(host, report.getHost().getState(), isBoot, report.getHost().getFreeMcp());
changeNimbyState(host, report.getHost());

/**
Expand Down Expand Up @@ -235,7 +233,14 @@ public void handleHostReport(HostReport report, boolean isBoot) {
}
}

if (host.idleCores < Dispatcher.CORE_POINTS_RESERVED_MIN) {
// The minimum amount of free space in the MCP directory to book a host
Long minBookableFreeMCP = env.getRequiredProperty("dispatcher.min_bookable_free_mcp_kb", Long.class);

if (minBookableFreeMCP != -1 && report.getHost().getFreeMcp() < minBookableFreeMCP) {
msg = String.format("%s doens't have enough free space in the /mcp directory, %dMB needs %dMB",
host.name, (report.getHost().getFreeMcp()/1024), (minBookableFreeMCP/1024));
}
else if (host.idleCores < Dispatcher.CORE_POINTS_RESERVED_MIN) {
msg = String.format("%s doesn't have enough idle cores, %d needs %d",
host.name, host.idleCores, Dispatcher.CORE_POINTS_RESERVED_MIN);
}
Expand All @@ -245,11 +250,7 @@ else if (host.idleMemory < Dispatcher.MEM_RESERVED_MIN) {
}
else if (report.getHost().getFreeMem() < CueUtil.MB512) {
msg = String.format("%s doens't have enough free system mem, %d needs %d",
host.name, report.getHost().getFreeMem(), Dispatcher.MEM_RESERVED_MIN);
}
else if (minBookableFreeMCP != -1 && report.getHost().getFreeMcp() < minBookableFreeMCP) {
msg = String.format("%s doens't have enough free space in the /mcp directory, %dMB needs %dMB",
host.name, (report.getHost().getFreeMcp()/1024), (minBookableFreeMCP/1024));
host.name, report.getHost().getFreeMem(), Dispatcher.MEM_RESERVED_MIN);
}
else if(!host.hardwareState.equals(HardwareState.UP)) {
msg = host + " is not in the Up state.";
Expand Down Expand Up @@ -343,10 +344,11 @@ else if (!dispatchSupport.isCueBookable(host)) {
* @param reportState
* @param isBoot
* @param freeMcp
* @param minBookableFreeMCP: The minimum amount of free space in the MCP directory to book a host
*/
private void changeHardwareState(DispatchHost host, HardwareState reportState, boolean isBoot, long freeMcp,
Long minBookableFreeMCP) {
private void changeHardwareState(DispatchHost host, HardwareState reportState, boolean isBoot, long freeMcp) {

// The minimum amount of free space in the MCP directory to book a host
Long minBookableFreeMCP = env.getRequiredProperty("dispatcher.min_bookable_free_mcp_kb", Long.class);

// Prevent cue frames from booking on hosts with full MCP directories
if (minBookableFreeMCP != -1) {
Expand Down

0 comments on commit 4e95928

Please sign in to comment.