Skip to content
Snippets Groups Projects
Commit 7b2428f5 authored by Moe Jette's avatar Moe Jette
Browse files

Fix state read to deal with errors better.

Fix update node RPC to handle reason field change without state change.
  State was being handled as type int instead of uint16_t so NO_VAL check
  was not working properly.
parent fed83e1b
No related branches found
No related tags found
No related merge requests found
...@@ -417,14 +417,16 @@ extern int load_all_node_state ( bool state_only ) ...@@ -417,14 +417,16 @@ extern int load_all_node_state ( bool state_only )
else { else {
data_allocated = BUF_SIZE; data_allocated = BUF_SIZE;
data = xmalloc(data_allocated); data = xmalloc(data_allocated);
while ((data_read = while (1) {
read (state_fd, &data[data_size], BUF_SIZE)) == data_read = read (state_fd, &data[data_size], BUF_SIZE);
BUF_SIZE) { if ((data_read == -1) && (errno == EINTR))
data_size += data_read; continue;
data_allocated += BUF_SIZE; if (data_read == 0) /* eof */
break;
data_size += data_read;
data_allocated += data_read;
xrealloc(data, data_allocated); xrealloc(data, data_allocated);
} }
data_size += data_read;
close (state_fd); close (state_fd);
if (data_read < 0) if (data_read < 0)
error ("Read error on %s, %m", state_file); error ("Read error on %s, %m", state_file);
...@@ -934,11 +936,11 @@ static void _split_node_name (char *name, char *prefix, char *suffix, ...@@ -934,11 +936,11 @@ static void _split_node_name (char *name, char *prefix, char *suffix,
*/ */
int update_node ( update_node_msg_t * update_node_msg ) int update_node ( update_node_msg_t * update_node_msg )
{ {
int error_code = 0, state_val, base_state, node_inx; int error_code = 0, base_state, node_inx;
struct node_record *node_ptr; struct node_record *node_ptr;
char *this_node_name ; char *this_node_name ;
hostlist_t host_list; hostlist_t host_list;
uint16_t no_resp_flag = 0; uint16_t no_resp_flag = 0, state_val;
if (update_node_msg -> node_names == NULL ) { if (update_node_msg -> node_names == NULL ) {
error ("update_node: invalid node name %s", error ("update_node: invalid node name %s",
...@@ -968,7 +970,7 @@ int update_node ( update_node_msg_t * update_node_msg ) ...@@ -968,7 +970,7 @@ int update_node ( update_node_msg_t * update_node_msg )
break; break;
} }
if (state_val != NO_VAL) { if (state_val != (uint16_t) NO_VAL) {
base_state = node_ptr->node_state & base_state = node_ptr->node_state &
(~NODE_STATE_NO_RESPOND); (~NODE_STATE_NO_RESPOND);
if (!_valid_node_state_change(base_state, state_val)) { if (!_valid_node_state_change(base_state, state_val)) {
...@@ -977,11 +979,11 @@ int update_node ( update_node_msg_t * update_node_msg ) ...@@ -977,11 +979,11 @@ int update_node ( update_node_msg_t * update_node_msg )
this_node_name, this_node_name,
node_state_string(base_state), node_state_string(base_state),
node_state_string(state_val)); node_state_string(state_val));
state_val = NO_VAL; state_val = (uint16_t) NO_VAL;
error_code = ESLURM_INVALID_NODE_STATE; error_code = ESLURM_INVALID_NODE_STATE;
} }
} }
if (state_val != NO_VAL) { if (state_val != (uint16_t) NO_VAL) {
if (state_val == NODE_STATE_DOWN) { if (state_val == NODE_STATE_DOWN) {
/* We must set node down before killing its jobs */ /* We must set node down before killing its jobs */
_make_node_down(node_ptr); _make_node_down(node_ptr);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment