diff --git a/slurm/slurm.h.in b/slurm/slurm.h.in index 856e78ac472c174ec099d08d836dae8bf6ab2698..bb1df0b10bd9508e71aa12e3b200dd174047e96d 100644 --- a/slurm/slurm.h.in +++ b/slurm/slurm.h.in @@ -285,6 +285,7 @@ typedef struct node_info { uint32_t weight; /* arbitrary priority of node for scheduling */ char *features; /* arbitrary list of features for node */ char *partition; /* name of partition node configured to */ + char *reason; /* reason for node being DOWN or DRAINING */ } node_info_t; typedef struct node_info_msg { @@ -409,6 +410,7 @@ typedef struct submit_response_msg { typedef struct slurm_update_node_msg { char *node_names; /* comma separated list of required nodes */ uint16_t node_state; /* see enum node_states */ + char *reason; /* reason for node being DOWN or DRAINING */ } update_node_msg_t; typedef struct partition_info update_part_msg_t; diff --git a/src/api/free_msg.c b/src/api/free_msg.c index b8c99d12837c3c71fbb9b622fa5abc8ba5266d53..f59b513003e2a37e8183f9ef17ef746892b93b9a 100644 --- a/src/api/free_msg.c +++ b/src/api/free_msg.c @@ -278,6 +278,7 @@ static void _slurm_free_node_info_members(node_info_t * node) xfree(node->name); xfree(node->features); xfree(node->partition); + xfree(node->reason); } } diff --git a/src/api/node_info.c b/src/api/node_info.c index 5f18c6ce0f22935b8cfaa3bd749e1197237ea129..5b71d3ac13f615d643d05c98cfd6d6cecbdad3c0 100644 --- a/src/api/node_info.c +++ b/src/api/node_info.c @@ -81,7 +81,7 @@ slurm_print_node_table ( FILE * out, node_info_t * node_ptr, int one_liner ) fprintf ( out, "NodeName=%s State=%s CPUs=%u ", node_ptr->name, node_state_string(node_ptr->node_state), node_ptr->cpus); - fprintf ( out, "RealMemory=%u TmpDisk=%u", + fprintf ( out, "RealMemory=%u TmpDisk=%u ", node_ptr->real_memory, node_ptr->tmp_disk); if (one_liner) fprintf ( out, " "); @@ -89,8 +89,20 @@ slurm_print_node_table ( FILE * out, node_info_t * node_ptr, int one_liner ) fprintf ( out, "\n "); /****** Line 2 ******/ - fprintf ( out, "Weight=%u Partition=%s Features=%s\n\n", + fprintf ( out, "Weight=%u Partition=%s Features=%s", node_ptr->weight, node_ptr->partition, node_ptr->features); + if (one_liner) + fprintf ( out, " "); + else + fprintf ( out, "\n "); + + + /****** Line 3 ******/ + fprintf ( out, "Reason=%s", node_ptr->reason); + if (one_liner) + fprintf ( out, "\n"); + else + fprintf ( out, "\n\n"); } diff --git a/src/common/read_config.c b/src/common/read_config.c index cc5b7540147119385dc159bdf2f680891a7b1d02..528b06d0b36c5d217a1d4cef05d405547edb1168 100644 --- a/src/common/read_config.c +++ b/src/common/read_config.c @@ -507,7 +507,7 @@ _parse_node_spec (char *in_line) { int error_code; char *feature = NULL, *node_addr = NULL, *node_name = NULL; - char *state = NULL; + char *state = NULL, *reason=NULL; int cpus_val, real_memory_val, tmp_disk_val, weight_val; error_code = slurm_parser (in_line, @@ -516,6 +516,7 @@ _parse_node_spec (char *in_line) "NodeName=", 's', &node_name, "Procs=", 'd', &cpus_val, "RealMemory=", 'd', &real_memory_val, + "Reason=", 's', &reason, "State=", 's', &state, "TmpDisk=", 'd', &tmp_disk_val, "Weight=", 'd', &weight_val, @@ -527,6 +528,7 @@ _parse_node_spec (char *in_line) xfree(feature); xfree(node_addr); xfree(node_name); + xfree(reason); xfree(state); return 0; diff --git a/src/common/slurm_protocol_defs.c b/src/common/slurm_protocol_defs.c index 31a902404220d5b366dceb3a1c8fa780f6651df3..069f37c1a9fb7c38ae85b33a55b19ad5df8df23d 100644 --- a/src/common/slurm_protocol_defs.c +++ b/src/common/slurm_protocol_defs.c @@ -171,6 +171,7 @@ void slurm_free_update_node_msg(update_node_msg_t * msg) { if (msg) { xfree(msg->node_names); + xfree(msg->reason); xfree(msg); } } diff --git a/src/common/slurm_protocol_pack.c b/src/common/slurm_protocol_pack.c index a71d220a4899313a4500d5e3f7d058eb8b1b5083..1c72661e57bdb8a8ee67003b7570ccee1d2f8ddd 100644 --- a/src/common/slurm_protocol_pack.c +++ b/src/common/slurm_protocol_pack.c @@ -653,6 +653,7 @@ _pack_update_node_msg(update_node_msg_t * msg, Buf buffer) packstr(msg->node_names, buffer); pack16(msg->node_state, buffer); + packstr(msg->reason, buffer); } static int @@ -668,10 +669,12 @@ _unpack_update_node_msg(update_node_msg_t ** msg, Buf buffer) safe_unpackstr_xmalloc(&tmp_ptr->node_names, &uint16_tmp, buffer); safe_unpack16(&tmp_ptr->node_state, buffer); + safe_unpackstr_xmalloc(&tmp_ptr->reason, &uint16_tmp, buffer); return SLURM_SUCCESS; unpack_error: xfree(tmp_ptr->node_names); + xfree(tmp_ptr->reason); xfree(tmp_ptr); *msg = NULL; return SLURM_ERROR; @@ -986,6 +989,7 @@ _unpack_node_info_members(node_info_t * node, Buf buffer) safe_unpack32(&node->weight, buffer); safe_unpackstr_xmalloc(&node->features, &uint16_tmp, buffer); safe_unpackstr_xmalloc(&node->partition, &uint16_tmp, buffer); + safe_unpackstr_xmalloc(&node->reason, &uint16_tmp, buffer); return SLURM_SUCCESS; @@ -993,6 +997,7 @@ _unpack_node_info_members(node_info_t * node, Buf buffer) xfree(node->name); xfree(node->features); xfree(node->partition); + xfree(node->reason); return SLURM_ERROR; } diff --git a/src/scontrol/scontrol.c b/src/scontrol/scontrol.c index 6e61a9f47eaf04b9307064c42bccf20730f5b69d..79007a8eb96c592c96fd8d14155d9c12b9d282f9 100644 --- a/src/scontrol/scontrol.c +++ b/src/scontrol/scontrol.c @@ -213,7 +213,9 @@ _get_command (int *argc, char **argv) add_history(in_line); #endif + /* break in_line into tokens */ for (i = 0; i < in_line_size; i++) { + bool double_quote = false, single_quote = false; if (in_line[i] == '\0') break; if (isspace ((int) in_line[i])) @@ -226,11 +228,22 @@ _get_command (int *argc, char **argv) } argv[(*argc)++] = &in_line[i]; for (i++; i < in_line_size; i++) { - if ((in_line[i] != '\0') && - (!isspace ((int) in_line[i]))) + if (in_line[i] == '\042') { + double_quote = !double_quote; continue; - in_line[i] = (char) NULL; - break; + } + if (in_line[i] == '\047') { + single_quote = !single_quote; + continue; + } + if (in_line[i] == '\0') + break; + if (double_quote || single_quote) + continue; + if (isspace ((int) in_line[i])) { + in_line[i] = '\0'; + break; + } } } return 0; @@ -1221,15 +1234,31 @@ _update_job (int argc, char *argv[]) static int _update_node (int argc, char *argv[]) { - int i, j, k; + int i, j, k, rc; uint16_t state_val; update_node_msg_t node_msg; + char *reason_str = NULL; node_msg.node_names = NULL; + node_msg.reason = NULL; node_msg.node_state = (uint16_t) NO_VAL; for (i=0; i<argc; i++) { if (strncasecmp(argv[i], "NodeName=", 9) == 0) node_msg.node_names = &argv[i][9]; + else if (strncasecmp(argv[i], "Reason=", 7) == 0) { + int len = strlen(&argv[i][7]); + reason_str = xmalloc(len+1); + if (argv[i][7] == '"') + strcpy(reason_str, &argv[i][8]); + else + strcpy(reason_str, &argv[i][7]); + + len = strlen(reason_str) - 1; + if ((len >= 0) && (reason_str[len] == '"')) + reason_str[len] = '\0'; + + node_msg.reason = reason_str; + } else if (strncasecmp(argv[i], "State=NoResp", 12) == 0) node_msg.node_state = NODE_STATE_NO_RESPOND; else if (strncasecmp(argv[i], "State=", 6) == 0) { @@ -1268,7 +1297,10 @@ _update_node (int argc, char *argv[]) } } - if (slurm_update_node(&node_msg)) + rc = slurm_update_node(&node_msg); + xfree(reason_str); + + if (rc) return slurm_get_errno (); else return 0;