Skip to content

Commit

Permalink
Prevent booking frames on hosts with full temporary directory
Browse files Browse the repository at this point in the history
- Code refactoring
- Change comments, variables and methods reference from "mcp" to "temporary directory" or "TempDir"
  • Loading branch information
ramonfigueiredo committed Jul 27, 2023
1 parent 4e95928 commit 04ec106
Show file tree
Hide file tree
Showing 35 changed files with 97 additions and 97 deletions.
6 changes: 3 additions & 3 deletions cuebot/src/main/java/com/imageworks/spcue/dao/HostDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ public interface HostDao {
void updateHostState(HostInterface host, HardwareState state);

/**
* updates a host with the passed free Mcp
* updates a host with the passed free temporary directory
*
* @param host
* @param freeMcp
* @param freeTempDir
*/
void updateHostFreeMcp(HostInterface host, Long freeMcp);
void updateHostFreeTempDir(HostInterface host, Long freeTempDir);

/**
* returns a full host detail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,10 @@ public void updateHostState(HostInterface host, HardwareState state) {
}

@Override
public void updateHostFreeMcp(HostInterface host, Long freeMcp) {
public void updateHostFreeTempDir(HostInterface host, Long freeTempDir) {
getJdbcTemplate().update(
"UPDATE host_stat SET int_mcp_free=? WHERE pk_host=?",
freeMcp, host.getHostId());
freeTempDir, host.getHostId());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ public class HostReportHandler {
@Autowired
private CommentManager commentManager;
// Comment constants
private static final String SUBJECT_COMMENT_FULL_MCP_DIR = "Host set to REPAIR for not having enough storage " +
"space on /mcp";
private static final String SUBJECT_COMMENT_FULL_TEMP_DIR = "Host set to REPAIR for not having enough storage " +
"space on the temporary directory (mcp)";
private static final String CUEBOT_COMMENT_USER = "cuebot";

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

// 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);
// The minimum amount of free space in the temporary directory to book a host
Long minBookableFreeTempDir = env.getRequiredProperty("dispatcher.min_bookable_free_temp_dir_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));
if (minBookableFreeTempDir != -1 && report.getHost().getFreeMcp() < minBookableFreeTempDir) {
msg = String.format("%s doens't have enough free space in the temporary directory (mcp), %dMB needs %dMB",
host.name, (report.getHost().getFreeMcp()/1024), (minBookableFreeTempDir/1024));
}
else if (host.idleCores < Dispatcher.CORE_POINTS_RESERVED_MIN) {
msg = String.format("%s doesn't have enough idle cores, %d needs %d",
Expand Down Expand Up @@ -329,51 +329,51 @@ else if (!dispatchSupport.isCueBookable(host)) {
* never updated via RQD.
*
*
* Prevent cue frames from booking on hosts with full MCP directories.
* Prevent cue frames from booking on hosts with full temporary directories.
*
* Change host state to REPAIR or UP according the amount of free space
* in the /mcp directory:
* in the temporary directory:
* - Set the host state to REPAIR, when the amount of free space in the
* /mcp directory is less than the minimum required. Add a comment with
* subject: "Action required. Host status = Repair. Reason: Full /mcp directory".
* - Set the host state to UP, when the amount of free space in the /mcp directory
* temporary directory is less than the minimum required. Add a comment with
* subject: SUBJECT_COMMENT_FULL_TEMP_DIR
* - Set the host state to UP, when the amount of free space in the temporary directory
* is greater or equals to the minimum required and the host has a comment with
* subject: "Action required. Host status = Repair. Reason: Full /mcp directory".
* subject: SUBJECT_COMMENT_FULL_TEMP_DIR
*
* @param host
* @param reportState
* @param isBoot
* @param freeMcp
* @param freeTempDir
*/
private void changeHardwareState(DispatchHost host, HardwareState reportState, boolean isBoot, long freeMcp) {
private void changeHardwareState(DispatchHost host, HardwareState reportState, boolean isBoot, long freeTempDir) {

// 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);
// The minimum amount of free space in the temporary directory to book a host
Long minBookableFreeTempDir = env.getRequiredProperty("dispatcher.min_bookable_free_temp_dir_kb", Long.class);

// Prevent cue frames from booking on hosts with full MCP directories
if (minBookableFreeMCP != -1) {
if (host.hardwareState == HardwareState.UP && freeMcp < minBookableFreeMCP) {
// Prevent cue frames from booking on hosts with full temporary directories
if (minBookableFreeTempDir != -1) {
if (host.hardwareState == HardwareState.UP && freeTempDir < minBookableFreeTempDir) {

// Insert a comment indicating that the Host status = Repair with reason = Full /mcp directory
// Insert a comment indicating that the Host status = Repair with reason = Full temporary directory
CommentDetail c = new CommentDetail();
c.subject = SUBJECT_COMMENT_FULL_MCP_DIR;
c.subject = SUBJECT_COMMENT_FULL_TEMP_DIR;
c.user = CUEBOT_COMMENT_USER;
c.timestamp = null;
c.message = "Host " + host.getName() + " marked as REPAIR. The current amount of free space in /mcp is " +
(freeMcp/1024) + "MB. It must have at least " + (minBookableFreeMCP/1024) +
"MB of free space in /mcp";
c.message = "Host " + host.getName() + " marked as REPAIR. The current amount of free space in the " +
"temporary directory (mcp) is " + (freeTempDir/1024) + "MB. It must have at least "
+ (minBookableFreeTempDir/1024) + "MB of free space in temporary directory";
commentManager.addComment(host, c);

// Set the host state to REPAIR
hostManager.setHostState(host, HardwareState.REPAIR);
host.hardwareState = HardwareState.REPAIR;

return;
} else if (host.hardwareState == HardwareState.REPAIR && freeMcp >= minBookableFreeMCP) {
// Check if the host with REPAIR status has comments with subject=SUBJECT_COMMENT_FULL_MCP_DIR and
} else if (host.hardwareState == HardwareState.REPAIR && freeTempDir >= minBookableFreeTempDir) {
// Check if the host with REPAIR status has comments with subject=SUBJECT_COMMENT_FULL_TEMP_DIR and
// user=CUEBOT_COMMENT_USER and delete the comments, if they exists
boolean commentsDeleted = commentManager.deleteCommentByHostUserAndSubject(host,
CUEBOT_COMMENT_USER, SUBJECT_COMMENT_FULL_MCP_DIR);
CUEBOT_COMMENT_USER, SUBJECT_COMMENT_FULL_TEMP_DIR);

if (commentsDeleted) {
// Set the host state to UP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ public interface HostManager {
void setHostState(HostInterface host, HardwareState state);

/**
* Updates the freeMcp of a host.
* Updates the free temporary directory (mcp) of a host.
*
* @param host HostInterface
* @param freeMcp Long
* @param freeTempDir Long
*/
void setHostFreeMcp(HostInterface host, Long freeMcp);
void setHostFreeTempDir(HostInterface host, Long freeTempDir);

/**
* Return true if the host is swapping hard enough
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public void setHostState(HostInterface host, HardwareState state) {
}

@Override
public void setHostFreeMcp(HostInterface host, Long freeMcp) {
hostDao.updateHostFreeMcp(host, freeMcp);
public void setHostFreeTempDir(HostInterface host, Long freeTempDir) {
hostDao.updateHostFreeTempDir(host, freeTempDir);
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions cuebot/src/main/resources/opencue.properties
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ dispatcher.report_queue.max_pool_size=8
# Queue capacity for handling Host Report.
dispatcher.report_queue.queue_capacity=1000

# The minimum amount of free space in the MCP directory to book a host.
# E.g: 1G = 1048576 kB => dispatcher.min_bookable_free_mcp_kb=1048576
# The minimum amount of free space in the temporary directory (mcp) to book a host.
# E.g: 1G = 1048576 kB => dispatcher.min_bookable_free_temp_dir_kb=1048576
# Default = -1 (deactivated)
# If equals to -1, it means the feature is turned off
dispatcher.min_bookable_free_mcp_kb=-1
dispatcher.min_bookable_free_temp_dir_kb=-1

# Number of threads to keep in the pool for kill frame operation.
dispatcher.kill_queue.core_pool_size=6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private void launchJobs() {
private RenderHost.Builder buildRenderHost() {
return RenderHost.newBuilder()
.setBootTime(1192369572)
// The minimum amount of free space in the /mcp directory to book a host.
// The minimum amount of free space in the temporary directory to book a host.
.setFreeMcp(1048576)
.setFreeMem(53500)
.setFreeSwap(20760)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public DispatchHost createHost() {
RenderHost host = RenderHost.newBuilder()
.setName("test_host")
.setBootTime(1192369572)
// The minimum amount of free space in the /mcp directory to book a host.
// The minimum amount of free space in the temporary directory to book a host.
.setFreeMcp(1048576)
.setFreeMem(53500)
.setFreeSwap(20760)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void testInsertCommentOnHost() {
RenderHost host = RenderHost.newBuilder()
.setName("boo")
.setBootTime(1192369572)
// The minimum amount of free space in the /mcp directory to book a host.
// The minimum amount of free space in the temporary directory to book a host.
.setFreeMcp(1048576)
.setFreeMem(15290520)
.setFreeSwap(2076)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public DispatchHost createHost() {
RenderHost host = RenderHost.newBuilder()
.setName("test_host")
.setBootTime(1192369572)
// The minimum amount of free space in the /mcp directory to book a host.
// The minimum amount of free space in the temporary directory to book a host.
.setFreeMcp(1048576)
.setFreeMem(15290520)
.setFreeSwap(2076)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void createHost() {
RenderHost host = RenderHost.newBuilder()
.setName(HOSTNAME)
.setBootTime(1192369572)
// The minimum amount of free space in the /mcp directory to book a host.
// The minimum amount of free space in the temporary directory to book a host.
.setFreeMcp(1048576)
.setFreeMem(53500)
.setFreeSwap(20760)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void createHost() {
RenderHost host = RenderHost.newBuilder()
.setName(HOSTNAME)
.setBootTime(1192369572)
// The minimum amount of free space in the /mcp directory to book a host.
// The minimum amount of free space in the temporary directory to book a host.
.setFreeMcp(1048576)
.setFreeMem(53500)
.setFreeSwap(20760)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void create() {
RenderHost host = RenderHost.newBuilder()
.setName(HOST)
.setBootTime(1192369572)
// The minimum amount of free space in the /mcp directory to book a host.
// The minimum amount of free space in the temporary directory to book a host.
.setFreeMcp(1048576)
.setFreeMem(53500)
.setFreeSwap(20760)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static RenderHost buildRenderHost(String name) {
RenderHost host = RenderHost.newBuilder()
.setName(name)
.setBootTime(1192369572)
// The minimum amount of free space in the /mcp directory to book a host.
// The minimum amount of free space in the temporary directory to book a host.
.setFreeMcp(1048576)
.setFreeMem(15290520)
.setFreeSwap((int) CueUtil.MB512)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public DispatchHost createHost() {
RenderHost host = RenderHost.newBuilder()
.setName("beta")
.setBootTime(1192369572)
// The minimum amount of free space in the /mcp directory to book a host.
// The minimum amount of free space in the temporary directory to book a host.
.setFreeMcp(1048576)
.setFreeMem(53500)
.setFreeSwap(20760)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public DispatchHost createHost() {
RenderHost host = RenderHost.newBuilder()
.setName("test_host")
.setBootTime(1192369572)
// The minimum amount of free space in the /mcp directory to book a host.
// The minimum amount of free space in the temporary directory to book a host.
.setFreeMcp(1048576)
.setFreeMem(53500)
.setFreeSwap(20760)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public RenderHost getRenderHost() {
RenderHost host = RenderHost.newBuilder()
.setName(HOST)
.setBootTime(1192369572)
// The minimum amount of free space in the /mcp directory to book a host.
// The minimum amount of free space in the temporary directory to book a host.
.setFreeMcp(1048576)
.setFreeMem((int) Dispatcher.MEM_RESERVED_MIN * 4)
.setFreeSwap(2076)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void createHost() {
RenderHost host = RenderHost.newBuilder()
.setName(HOSTNAME)
.setBootTime(1192369572)
// The minimum amount of free space in the /mcp directory to book a host.
// The minimum amount of free space in the temporary directory to book a host.
.setFreeMcp(1048576)
.setFreeMem((int) CueUtil.GB8)
.setFreeSwap(20760)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void createHost() {
RenderHost host = RenderHost.newBuilder()
.setName(HOSTNAME)
.setBootTime(1192369572)
// The minimum amount of free space in the /mcp directory to book a host.
// The minimum amount of free space in the temporary directory to book a host.
.setFreeMcp(1048576)
.setFreeMem((int) CueUtil.GB8)
.setFreeSwap(20760)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void createHost() {
RenderHost host = RenderHost.newBuilder()
.setName(HOSTNAME)
.setBootTime(1192369572)
// The minimum amount of free space in the /mcp directory to book a host.
// The minimum amount of free space in the temporary directory to book a host.
.setFreeMcp(1048576)
.setFreeMem((int) CueUtil.GB8)
.setFreeSwap(20760)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void createHost() {
RenderHost host = RenderHost.newBuilder()
.setName(HOSTNAME)
.setBootTime(1192369572)
// The minimum amount of free space in the /mcp directory to book a host.
// The minimum amount of free space in the temporary directory to book a host.
.setFreeMcp(1048576)
.setFreeMem(53500)
.setFreeSwap(20760)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void createHost() {
RenderHost host = RenderHost.newBuilder()
.setName(HOSTNAME)
.setBootTime(1192369572)
// The minimum amount of free space in the /mcp directory to book a host.
// The minimum amount of free space in the temporary directory to book a host.
.setFreeMcp(1048576)
.setFreeMem(53500)
.setFreeSwap(20760)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void createHost() {
RenderHost host = RenderHost.newBuilder()
.setName(HOSTNAME)
.setBootTime(1192369572)
// The minimum amount of free space in the /mcp directory to book a host.
// The minimum amount of free space in the temporary directory to book a host.
.setFreeMcp(1048576)
.setFreeMem((int) CueUtil.GB8)
.setFreeSwap(20760)
Expand All @@ -140,7 +140,7 @@ public void createHost() {
RenderHost host2 = RenderHost.newBuilder()
.setName(HOSTNAME2)
.setBootTime(1192369572)
// The minimum amount of free space in the /mcp directory to book a host.
// The minimum amount of free space in the temporary directory to book a host.
.setFreeMcp(1048576)
.setFreeMem((int) CueUtil.GB4)
.setFreeSwap((int) CueUtil.GB4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void createHost() {
RenderHost host = RenderHost.newBuilder()
.setName(HOSTNAME)
.setBootTime(1192369572)
// The minimum amount of free space in the /mcp directory to book a host.
// The minimum amount of free space in the temporary directory to book a host.
.setFreeMcp(1048576)
.setFreeMem((int) CueUtil.GB8)
.setFreeSwap(20760)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private static RenderHost getRenderHost() {
return RenderHost.newBuilder()
.setName(HOSTNAME)
.setBootTime(1192369572)
// The minimum amount of free space in the /mcp directory to book a host.
// The minimum amount of free space in the temporary directory to book a host.
.setFreeMcp(1048576)
.setFreeMem(53500)
.setFreeSwap(20760)
Expand Down
Loading

0 comments on commit 04ec106

Please sign in to comment.