From 4e9592850dee9855c259626c3bd309eb30b4a2cc Mon Sep 17 00:00:00 2001 From: Ramon Figueiredo Date: Thu, 27 Jul 2023 11:04:24 -0700 Subject: [PATCH] Prevent booking frames on hosts with full MCP - 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 --- .../spcue/dispatcher/HostReportHandler.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/cuebot/src/main/java/com/imageworks/spcue/dispatcher/HostReportHandler.java b/cuebot/src/main/java/com/imageworks/spcue/dispatcher/HostReportHandler.java index 9a888e3c8..37c7179a4 100644 --- a/cuebot/src/main/java/com/imageworks/spcue/dispatcher/HostReportHandler.java +++ b/cuebot/src/main/java/com/imageworks/spcue/dispatcher/HostReportHandler.java @@ -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, @@ -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()); /** @@ -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); } @@ -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."; @@ -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) {