127
134
/* write node records to buffer */
128
135
lock_slurmctld (node_read_lock);
129
for (inx = 0; inx < node_record_count; inx++) {
130
xassert (node_record_table_ptr[inx].magic == NODE_MAGIC);
131
xassert (node_record_table_ptr[inx].config_ptr->magic ==
134
_dump_node_state (&node_record_table_ptr[inx], buffer);
136
for (inx = 0, node_ptr = node_record_table_ptr; inx < node_record_count;
138
xassert (node_ptr->magic == NODE_MAGIC);
139
xassert (node_ptr->config_ptr->magic == CONFIG_MAGIC);
140
_dump_node_state (node_ptr, buffer);
136
unlock_slurmctld (node_read_lock);
138
/* write the buffer to file */
139
143
old_file = xstrdup (slurmctld_conf.state_save_location);
140
144
xstrcat (old_file, "/node_state.old");
141
145
reg_file = xstrdup (slurmctld_conf.state_save_location);
142
146
xstrcat (reg_file, "/node_state");
143
147
new_file = xstrdup (slurmctld_conf.state_save_location);
144
148
xstrcat (new_file, "/node_state.new");
149
unlock_slurmctld (node_read_lock);
151
/* write the buffer to file */
146
153
log_fd = creat (new_file, 0600);
147
154
if (log_fd < 0) {
148
error ("Can't save state, error creating file %s %m",
155
error ("Can't save state, error creating file %s %m", new_file);
150
156
error_code = errno;
152
158
int pos = 0, nwrite = get_buf_offset(buffer), amount, rc;
244
255
* load_all_node_state - Load the node state from file, recover on slurmctld
245
256
* restart. Execute this after loading the configuration file data.
246
257
* Data goes into common storage.
247
* IN state_only - if true, overwrite only node state, features and reason
258
* IN state_only - if true, overwrite only node state and reason
248
259
* Use this to overwrite the "UNKNOWN state typically used in slurm.conf
249
260
* RET 0 or error code
250
261
* NOTE: READ lock_slurmctld config before entry
252
263
extern int load_all_node_state ( bool state_only )
254
char *node_name, *reason = NULL, *data = NULL, *state_file, *features;
265
char *node_name = NULL, *reason = NULL, *data = NULL, *state_file;
266
char *features = NULL, *gres = NULL;
255
267
int data_allocated, data_read = 0, error_code = 0, node_cnt = 0;
256
268
uint16_t node_state;
257
269
uint16_t cpus = 1, sockets = 1, cores = 1, threads = 1;
258
270
uint32_t real_memory, tmp_disk, data_size = 0, name_len;
271
uint32_t reason_uid = NO_VAL;
272
time_t reason_time = 0;
273
List gres_list = NULL;
259
274
struct node_record *node_ptr;
261
276
time_t time_stamp, now = time(NULL);
263
278
char *ver_str = NULL;
264
279
hostset_t hs = NULL;
265
slurm_ctl_conf_t *conf = slurm_conf_lock();
266
280
bool power_save_mode = false;
281
uint16_t protocol_version = (uint16_t)NO_VAL;
268
if (conf->suspend_program && conf->resume_program)
283
if (slurmctld_conf.suspend_program && slurmctld_conf.resume_program)
269
284
power_save_mode = true;
272
286
/* read the file */
273
state_file = xstrdup (slurmctld_conf.state_save_location);
274
xstrcat (state_file, "/node_state");
275
287
lock_state_files ();
276
288
state_fd = _open_node_state_file(&state_file);
277
289
if (state_fd < 0) {
321
341
while (remaining_buf (buffer) > 0) {
322
342
uint16_t base_state;
323
safe_unpackstr_xmalloc (&node_name, &name_len, buffer);
324
safe_unpackstr_xmalloc (&reason, &name_len, buffer);
325
safe_unpackstr_xmalloc (&features, &name_len, buffer);
326
safe_unpack16 (&node_state, buffer);
327
safe_unpack16 (&cpus, buffer);
328
safe_unpack16 (&sockets, buffer);
329
safe_unpack16 (&cores, buffer);
330
safe_unpack16 (&threads, buffer);
331
safe_unpack32 (&real_memory, buffer);
332
safe_unpack32 (&tmp_disk, buffer);
333
base_state = node_state & NODE_STATE_BASE;
343
if(protocol_version >= SLURM_2_2_PROTOCOL_VERSION) {
344
safe_unpackstr_xmalloc (&node_name, &name_len, buffer);
345
safe_unpackstr_xmalloc (&reason, &name_len, buffer);
346
safe_unpackstr_xmalloc (&features, &name_len, buffer);
347
safe_unpackstr_xmalloc (&gres, &name_len, buffer);
348
safe_unpack16 (&node_state, buffer);
349
safe_unpack16 (&cpus, buffer);
350
safe_unpack16 (&sockets, buffer);
351
safe_unpack16 (&cores, buffer);
352
safe_unpack16 (&threads, buffer);
353
safe_unpack32 (&real_memory, buffer);
354
safe_unpack32 (&tmp_disk, buffer);
355
safe_unpack32 (&reason_uid, buffer);
356
safe_unpack_time (&reason_time, buffer);
357
if (gres_plugin_node_state_unpack(
358
&gres_list, buffer, node_name,
359
protocol_version) != SLURM_SUCCESS)
361
base_state = node_state & NODE_STATE_BASE;
362
} else if(protocol_version >= SLURM_2_1_PROTOCOL_VERSION) {
363
safe_unpackstr_xmalloc (&node_name, &name_len, buffer);
364
safe_unpackstr_xmalloc (&reason, &name_len, buffer);
365
safe_unpackstr_xmalloc (&features, &name_len, buffer);
366
safe_unpack16 (&node_state, buffer);
367
safe_unpack16 (&cpus, buffer);
368
safe_unpack16 (&sockets, buffer);
369
safe_unpack16 (&cores, buffer);
370
safe_unpack16 (&threads, buffer);
371
safe_unpack32 (&real_memory, buffer);
372
safe_unpack32 (&tmp_disk, buffer);
375
base_state = node_state & NODE_STATE_BASE;
335
379
/* validity test as possible */
336
380
if ((cpus == 0) ||
504
573
*buffer_size = 0;
506
575
buffer = init_buf (BUF_SIZE*16);
508
/* write header: version and time */
510
pack32 (nodes_packed, buffer);
511
select_g_alter_node_cnt(SELECT_GET_NODE_SCALING,
513
pack32 (node_scaling, buffer);
515
pack_time (now, buffer);
517
/* write node records */
518
part_filter_set(uid);
519
for (inx = 0; inx < node_record_count; inx++, node_ptr++) {
520
xassert (node_ptr->magic == NODE_MAGIC);
521
xassert (node_ptr->config_ptr->magic ==
524
/* We can't avoid packing node records without breaking
525
* the node index pointers. So pack a node with a name of
526
* NULL and let the caller deal with it. */
528
if (((show_flags & SHOW_ALL) == 0) && (uid != 0) &&
529
(_node_is_hidden(node_ptr)))
531
else if (IS_NODE_FUTURE(node_ptr))
533
else if ((node_ptr->name == NULL) ||
534
(node_ptr->name[0] == '\0'))
538
char *orig_name = node_ptr->name;
539
node_ptr->name = NULL;
540
_pack_node(node_ptr, buffer);
541
node_ptr->name = orig_name;
543
_pack_node(node_ptr, buffer);
578
if(protocol_version >= SLURM_2_1_PROTOCOL_VERSION) {
579
/* write header: version and time */
580
pack32(nodes_packed, buffer);
581
select_g_alter_node_cnt(SELECT_GET_NODE_SCALING,
583
pack32(node_scaling, buffer);
585
pack_time(now, buffer);
587
/* write node records */
588
part_filter_set(uid);
589
for (inx = 0; inx < node_record_count; inx++, node_ptr++) {
590
xassert (node_ptr->magic == NODE_MAGIC);
591
xassert (node_ptr->config_ptr->magic ==
594
/* We can't avoid packing node records without breaking
595
* the node index pointers. So pack a node
596
* with a name of NULL and let the caller deal
599
if (((show_flags & SHOW_ALL) == 0) && (uid != 0) &&
600
(_node_is_hidden(node_ptr)))
602
else if (IS_NODE_FUTURE(node_ptr))
604
else if ((node_ptr->name == NULL) ||
605
(node_ptr->name[0] == '\0'))
609
char *orig_name = node_ptr->name;
610
node_ptr->name = NULL;
611
_pack_node(node_ptr, buffer, protocol_version);
612
node_ptr->name = orig_name;
614
_pack_node(node_ptr, buffer, protocol_version);
619
error("pack_all_node: Unsupported slurm version %u",
548
623
tmp_offset = get_buf_offset (buffer);
549
624
set_buf_offset (buffer, 0);
560
635
* machine independent form (for network transmission)
561
636
* IN dump_node_ptr - pointer to node for which information is requested
562
637
* IN/OUT buffer - buffer where data is placed, pointers automatically updated
638
* IN protocol_version - slurm protocol version of client
563
639
* NOTE: if you make any changes here be sure to make the corresponding
564
640
* changes to load_node_config in api/node_info.c
565
641
* NOTE: READ lock_slurmctld config before entry
567
static void _pack_node (struct node_record *dump_node_ptr, Buf buffer)
643
static void _pack_node (struct node_record *dump_node_ptr, Buf buffer,
644
uint16_t protocol_version)
569
packstr (dump_node_ptr->name, buffer);
570
pack16 (dump_node_ptr->node_state, buffer);
571
if (slurmctld_conf.fast_schedule) {
572
/* Only data from config_record used for scheduling */
573
pack16 (dump_node_ptr->config_ptr->cpus, buffer);
574
pack16 (dump_node_ptr->config_ptr->sockets, buffer);
575
pack16 (dump_node_ptr->config_ptr->cores, buffer);
576
pack16 (dump_node_ptr->config_ptr->threads, buffer);
577
pack32 (dump_node_ptr->config_ptr->real_memory, buffer);
578
pack32 (dump_node_ptr->config_ptr->tmp_disk, buffer);
646
if(protocol_version >= SLURM_2_2_PROTOCOL_VERSION) {
647
packstr (dump_node_ptr->name, buffer);
648
pack16 (dump_node_ptr->node_state, buffer);
649
if (slurmctld_conf.fast_schedule) {
650
/* Only data from config_record used for scheduling */
651
pack16(dump_node_ptr->config_ptr->cpus, buffer);
652
pack16(dump_node_ptr->config_ptr->sockets, buffer);
653
pack16(dump_node_ptr->config_ptr->cores, buffer);
654
pack16(dump_node_ptr->config_ptr->threads, buffer);
655
pack32(dump_node_ptr->config_ptr->real_memory, buffer);
656
pack32(dump_node_ptr->config_ptr->tmp_disk, buffer);
658
/* Individual node data used for scheduling */
659
pack16(dump_node_ptr->cpus, buffer);
660
pack16(dump_node_ptr->sockets, buffer);
661
pack16(dump_node_ptr->cores, buffer);
662
pack16(dump_node_ptr->threads, buffer);
663
pack32(dump_node_ptr->real_memory, buffer);
664
pack32(dump_node_ptr->tmp_disk, buffer);
666
pack32(dump_node_ptr->config_ptr->weight, buffer);
667
pack32(dump_node_ptr->reason_uid, buffer);
669
pack_time(dump_node_ptr->boot_time, buffer);
670
pack_time(dump_node_ptr->reason_time, buffer);
671
pack_time(dump_node_ptr->slurmd_start_time, buffer);
673
select_g_select_nodeinfo_pack(dump_node_ptr->select_nodeinfo,
674
buffer, protocol_version);
676
packstr(dump_node_ptr->arch, buffer);
677
packstr(dump_node_ptr->features, buffer);
678
if (dump_node_ptr->gres)
679
packstr(dump_node_ptr->gres, buffer);
681
packstr(dump_node_ptr->config_ptr->gres, buffer);
682
packstr(dump_node_ptr->os, buffer);
683
packstr(dump_node_ptr->reason, buffer);
684
} else if(protocol_version >= SLURM_2_1_PROTOCOL_VERSION) {
685
packstr (dump_node_ptr->name, buffer);
686
pack16 (dump_node_ptr->node_state, buffer);
687
if (slurmctld_conf.fast_schedule) {
688
/* Only data from config_record used for scheduling */
689
pack16(dump_node_ptr->config_ptr->cpus, buffer);
690
pack16(dump_node_ptr->config_ptr->sockets, buffer);
691
pack16(dump_node_ptr->config_ptr->cores, buffer);
692
pack16(dump_node_ptr->config_ptr->threads, buffer);
693
pack32(dump_node_ptr->config_ptr->real_memory, buffer);
694
pack32(dump_node_ptr->config_ptr->tmp_disk, buffer);
696
/* Individual node data used for scheduling */
697
pack16(dump_node_ptr->cpus, buffer);
698
pack16(dump_node_ptr->sockets, buffer);
699
pack16(dump_node_ptr->cores, buffer);
700
pack16(dump_node_ptr->threads, buffer);
701
pack32(dump_node_ptr->real_memory, buffer);
702
pack32(dump_node_ptr->tmp_disk, buffer);
704
pack32(dump_node_ptr->config_ptr->weight, buffer);
706
select_g_select_nodeinfo_pack(dump_node_ptr->select_nodeinfo,
707
buffer, protocol_version);
709
packstr(dump_node_ptr->arch, buffer);
710
packstr(dump_node_ptr->features, buffer);
711
packstr(dump_node_ptr->os, buffer);
712
packstr(dump_node_ptr->reason, buffer);
580
/* Individual node data used for scheduling */
581
pack16 (dump_node_ptr->cpus, buffer);
582
pack16 (dump_node_ptr->sockets, buffer);
583
pack16 (dump_node_ptr->cores, buffer);
584
pack16 (dump_node_ptr->threads, buffer);
585
pack32 (dump_node_ptr->real_memory, buffer);
586
pack32 (dump_node_ptr->tmp_disk, buffer);
714
error("_pack_node: Unsupported slurm version %u",
588
pack32 (dump_node_ptr->config_ptr->weight, buffer);
590
select_g_select_nodeinfo_pack(dump_node_ptr->select_nodeinfo, buffer);
592
packstr (dump_node_ptr->arch, buffer);
593
packstr (dump_node_ptr->config_ptr->feature, buffer);
594
packstr (dump_node_ptr->os, buffer);
595
packstr (dump_node_ptr->reason, buffer);
600
* set_slurmd_addr - establish the slurm_addr for the slurmd on each node
721
* set_slurmd_addr - establish the slurm_addr_t for the slurmd on each node
601
722
* Uses common data structures.
602
723
* NOTE: READ lock_slurmctld config before entry
833
968
if (!IS_NODE_DOWN(node_ptr) &&
834
!IS_NODE_DRAIN(node_ptr) && !IS_NODE_FAIL(node_ptr))
969
!IS_NODE_DRAIN(node_ptr) && !IS_NODE_FAIL(node_ptr)) {
835
970
xfree(node_ptr->reason);
971
node_ptr->reason_time = 0;
972
node_ptr->reason_uid = NO_VAL;
837
975
free (this_node_name);
839
977
hostlist_destroy (host_list);
841
979
if ((error_code == 0) && (update_node_msg->features)) {
842
error_code = _update_node_features(
843
update_node_msg->node_names,
844
update_node_msg->features);
980
error_code = _update_node_features(update_node_msg->node_names,
981
update_node_msg->features);
983
if ((error_code == 0) && (update_node_msg->gres)) {
984
error_code = _update_node_gres(update_node_msg->node_names,
985
update_node_msg->gres);
848
988
/* Update weight. Weight is part of config_ptr,
849
* hence do the splitting if required */
989
* hence split config records if required */
850
990
if ((error_code == 0) && (update_node_msg->weight != NO_VAL)) {
851
991
error_code = _update_node_weight(update_node_msg->node_names,
852
992
update_node_msg->weight);
859
999
return error_code;
1002
/* variation of strcmp that accepts NULL pointers */
1003
static int _strcmp(char *str1, char *str2)
1011
return strcmp(str1, str2);
863
* restore_node_features - Restore node features based upon state
864
* saved (preserves interactive updates)
1015
* restore_node_features - Make node and config (from slurm.conf) fields
1016
* consistent for Features, Gres and Weight
1018
* 0, 1 - use data from config record, built using slurm.conf
1019
* 2 = use data from node record, built from saved state
866
extern void restore_node_features(void)
1021
extern void restore_node_features(int recover)
870
struct node_record *node_ptr1, *node_ptr2;
873
for (i=0, node_ptr1=node_record_table_ptr; i<node_record_count;
876
if (!node_ptr1->features)
877
continue; /* No feature to preserve */
878
if (node_ptr1->config_ptr->feature &&
879
!strcmp(node_ptr1->config_ptr->feature,
880
node_ptr1->features)) {
881
continue; /* Identical feature value */
884
hl = hostlist_create(node_ptr1->name);
885
for (j=(i+1), node_ptr2=(node_ptr1+1); j<node_record_count;
887
if (!node_ptr2->features ||
888
strcmp(node_ptr1->features, node_ptr2->features))
890
hostlist_push(hl, node_ptr2->name);
893
node_list = xmalloc(2048);
894
hostlist_ranged_string(hl, 2048, node_list);
895
error("Node %s Features(%s) differ from slurm.conf",
896
node_list, node_ptr1->features);
897
_update_node_features(node_list, node_ptr1->features);
898
xfree(node_ptr1->features);
900
hostlist_destroy(hl);
1024
struct node_record *node_ptr;
1026
for (i=0, node_ptr=node_record_table_ptr; i<node_record_count;
1029
if (node_ptr->weight != node_ptr->config_ptr->weight) {
1030
error("Node %s Weight(%u) differ from slurm.conf",
1031
node_ptr->name, node_ptr->weight);
1033
_update_node_weight(node_ptr->name,
1036
node_ptr->weight = node_ptr->config_ptr->
1041
if (_strcmp(node_ptr->config_ptr->feature, node_ptr->features)){
1042
error("Node %s Features(%s) differ from slurm.conf",
1043
node_ptr->name, node_ptr->features);
1045
_update_node_features(node_ptr->name,
1046
node_ptr->features);
1048
xfree(node_ptr->features);
1049
node_ptr->features = xstrdup(node_ptr->
1055
/* We lose the gres information updated manually and always
1056
* use the information from slurm.conf */
1057
(void) gres_plugin_node_reconfig(node_ptr->name,
1058
node_ptr->config_ptr->gres,
1060
&node_ptr->gres_list,
1061
slurmctld_conf.fast_schedule);
1062
gres_plugin_node_state_log(node_ptr->gres_list, node_ptr->name);
1066
/* Duplicate a configuration record except for the node names & bitmap */
1067
struct config_record * _dup_config(struct config_record *config_ptr)
1069
struct config_record *new_config_ptr;
1071
new_config_ptr = create_config_record();
1072
new_config_ptr->magic = config_ptr->magic;
1073
new_config_ptr->cpus = config_ptr->cpus;
1074
new_config_ptr->sockets = config_ptr->sockets;
1075
new_config_ptr->cores = config_ptr->cores;
1076
new_config_ptr->threads = config_ptr->threads;
1077
new_config_ptr->real_memory = config_ptr->real_memory;
1078
new_config_ptr->tmp_disk = config_ptr->tmp_disk;
1079
new_config_ptr->weight = config_ptr->weight;
1080
new_config_ptr->feature = xstrdup(config_ptr->feature);
1081
new_config_ptr->gres = xstrdup(config_ptr->gres);
1083
return new_config_ptr;
905
1087
* _update_node_weight - Update weight associated with nodes
906
1088
* build new config list records as needed
1024
1195
} else if (tmp_cnt == config_cnt) {
1025
1196
/* all nodes changed, update in situ */
1026
1197
xfree(config_ptr->feature);
1198
if (features && features[0])
1028
1199
config_ptr->feature = xstrdup(features);
1030
config_ptr->feature = NULL;
1031
1200
build_config_feature_list(config_ptr);
1033
1202
/* partial update, split config_record */
1034
new_config_ptr = create_config_record();
1203
new_config_ptr = _dup_config(config_ptr);
1035
1204
if (first_new == NULL);
1036
1205
first_new = new_config_ptr;
1037
new_config_ptr->magic = config_ptr->magic;
1038
new_config_ptr->cpus = config_ptr->cpus;
1039
new_config_ptr->sockets = config_ptr->sockets;
1040
new_config_ptr->cores = config_ptr->cores;
1041
new_config_ptr->threads = config_ptr->threads;
1042
new_config_ptr->real_memory = config_ptr->real_memory;
1043
new_config_ptr->tmp_disk = config_ptr->tmp_disk;
1044
new_config_ptr->weight = config_ptr->weight;
1206
xfree(new_config_ptr->feature);
1207
if (features && features[0])
1046
1208
new_config_ptr->feature = xstrdup(features);
1047
1209
new_config_ptr->node_bitmap = bit_copy(tmp_bitmap);
1048
new_config_ptr->nodes =
1049
bitmap2node_name(tmp_bitmap);
1210
new_config_ptr->nodes = bitmap2node_name(tmp_bitmap);
1050
1212
build_config_feature_list(new_config_ptr);
1051
1213
_update_config_ptr(tmp_bitmap, new_config_ptr);
1054
1216
bit_not(tmp_bitmap);
1055
1217
bit_and(config_ptr->node_bitmap, tmp_bitmap);
1056
1218
xfree(config_ptr->nodes);
1057
config_ptr->nodes = bitmap2node_name(
1058
config_ptr->node_bitmap);
1219
config_ptr->nodes = bitmap2node_name(config_ptr->
1060
bit_free(tmp_bitmap);
1222
FREE_NULL_BITMAP(tmp_bitmap);
1062
1224
list_iterator_destroy(config_iterator);
1063
bit_free(node_bitmap);
1225
FREE_NULL_BITMAP(node_bitmap);
1065
1227
info("_update_node_features: nodes %s features set to: %s",
1066
1228
node_names, features);
1067
1229
return SLURM_SUCCESS;
1233
* _update_node_gres - Update generic resources associated with nodes
1234
* build new config list records as needed
1235
* IN node_names - List of nodes to update
1236
* IN gres - New gres value
1237
* RET: SLURM_SUCCESS or error code
1239
static int _update_node_gres(char *node_names, char *gres)
1241
bitstr_t *node_bitmap = NULL, *tmp_bitmap;
1242
ListIterator config_iterator;
1243
struct config_record *config_ptr, *new_config_ptr;
1244
struct config_record *first_new = NULL;
1245
struct node_record *node_ptr;
1246
int rc, config_cnt, tmp_cnt;
1247
int i, i_first, i_last;
1249
rc = node_name2bitmap(node_names, false, &node_bitmap);
1251
info("_update_node_gres: invalid node_name");
1255
/* For each config_record with one of these nodes,
1256
* update it (if all nodes updated) or split it into
1258
config_iterator = list_iterator_create(config_list);
1259
if (config_iterator == NULL)
1260
fatal("list_iterator_create malloc failure");
1261
while ((config_ptr = (struct config_record *)
1262
list_next(config_iterator))) {
1263
if (config_ptr == first_new)
1264
break; /* done with all original records */
1266
tmp_bitmap = bit_copy(node_bitmap);
1267
bit_and(tmp_bitmap, config_ptr->node_bitmap);
1268
config_cnt = bit_set_count(config_ptr->node_bitmap);
1269
tmp_cnt = bit_set_count(tmp_bitmap);
1271
/* no overlap, leave alone */
1272
} else if (tmp_cnt == config_cnt) {
1273
/* all nodes changed, update in situ */
1274
xfree(config_ptr->gres);
1275
if (gres && gres[0])
1276
config_ptr->gres = xstrdup(gres);
1278
/* partial update, split config_record */
1279
new_config_ptr = _dup_config(config_ptr);
1280
if (first_new == NULL);
1281
first_new = new_config_ptr;
1282
xfree(new_config_ptr->gres);
1283
if (gres && gres[0])
1284
new_config_ptr->gres = xstrdup(gres);
1285
new_config_ptr->node_bitmap = bit_copy(tmp_bitmap);
1286
new_config_ptr->nodes = bitmap2node_name(tmp_bitmap);
1288
_update_config_ptr(tmp_bitmap, new_config_ptr);
1290
/* Update remaining records */
1291
bit_not(tmp_bitmap);
1292
bit_and(config_ptr->node_bitmap, tmp_bitmap);
1293
xfree(config_ptr->nodes);
1294
config_ptr->nodes = bitmap2node_name(config_ptr->
1297
FREE_NULL_BITMAP(tmp_bitmap);
1299
list_iterator_destroy(config_iterator);
1301
i_first = bit_ffs(node_bitmap);
1302
i_last = bit_fls(node_bitmap);
1303
for (i=i_first; i<=i_last; i++) {
1304
node_ptr = node_record_table_ptr + i;
1305
(void) gres_plugin_node_reconfig(node_ptr->name,
1306
node_ptr->config_ptr->gres,
1308
&node_ptr->gres_list,
1309
slurmctld_conf.fast_schedule);
1310
gres_plugin_node_state_log(node_ptr->gres_list, node_ptr->name);
1312
FREE_NULL_BITMAP(node_bitmap);
1314
info("_update_node_gres: nodes %s gres set to: %s", node_names, gres);
1315
return SLURM_SUCCESS;
1070
1318
/* Reset the config pointer for updated jobs */
1071
1319
static void _update_config_ptr(bitstr_t *bitmap,
1072
1320
struct config_record *config_ptr)
1244
1508
threads2 = cores2 * config_ptr->threads;
1246
1510
if (threads1 < threads2) {
1247
error("Node %s has low socket*core*thread count %u",
1248
reg_msg->node_name, threads1);
1511
error("Node %s has low socket*core*thread count "
1513
reg_msg->node_name, threads1, threads2);
1249
1514
error_code = EINVAL;
1250
1515
reason_down = "Low socket*core*thread count";
1251
1516
} else if ((slurmctld_conf.fast_schedule == 0) &&
1252
1517
((cr_flag == 1) || gang_flag) && (cores1 < cores2)) {
1253
error("Node %s has low socket*core count %u",
1254
reg_msg->node_name, cores1);
1518
error("Node %s has low socket*core count (%d < %d)",
1519
reg_msg->node_name, cores1, cores2);
1255
1520
error_code = EINVAL;
1256
1521
reason_down = "Low socket*core count";
1257
1522
} else if ((slurmctld_conf.fast_schedule == 0) &&
1258
1523
((cr_flag == 1) || gang_flag) &&
1259
1524
((sockets1 > sockets2) || (cores1 > cores2) ||
1260
1525
(threads1 > threads2))) {
1261
error("Node %s has high socket*core*thread count %u, "
1262
"extra resources ignored",
1263
reg_msg->node_name, threads1);
1526
error("Node %s has high socket,core,thread count "
1527
"(%d,%d,%d > %d,%d,%d), extra resources ignored",
1528
reg_msg->node_name, sockets1, cores1, threads1,
1529
sockets2, cores2, threads2);
1264
1530
/* Preserve configured values */
1265
1531
reg_msg->sockets = config_ptr->sockets;
1266
1532
reg_msg->cores = config_ptr->cores;
1391
1662
if (!IS_NODE_DRAIN(node_ptr)
1392
1663
&& !IS_NODE_FAIL(node_ptr)) {
1393
1664
xfree(node_ptr->reason);
1665
node_ptr->reason_time = 0;
1666
node_ptr->reason_uid = NO_VAL;
1394
1667
clusteracct_storage_g_node_up(
1395
acct_db_conn, slurmctld_cluster_name,
1668
acct_db_conn, node_ptr, now);
1398
1670
} else if (node_ptr->last_response
1399
&& (last_restart > node_ptr->last_response)
1671
&& (node_ptr->boot_time > node_ptr->last_response)
1400
1672
&& (slurmctld_conf.ret2service != 2)) {
1402
1673
last_node_update = now;
1403
slurm_make_time_str(&now, time_str, sizeof(time_str));
1404
if(!node_ptr->reason)
1405
node_ptr->reason = xstrdup_printf(
1406
"Node silently failed and "
1407
"came back [slurm@%s]",
1674
if(!node_ptr->reason) {
1675
node_ptr->reason_time = now;
1676
node_ptr->reason_uid =
1677
slurm_get_slurm_user_id();
1678
node_ptr->reason = xstrdup(
1679
"Node silently failed and came back");
1409
1681
info("Node %s silently failed and came back",
1410
1682
reg_msg->node_name);
1411
1683
_make_node_down(node_ptr, last_node_update);
1420
1692
(reg_msg->job_count == 0)) { /* job already done */
1421
1693
last_node_update = now;
1422
1694
node_ptr->node_state &= (~NODE_STATE_COMPLETING);
1695
bit_clear(cg_node_bitmap, node_inx);
1423
1696
} else if (IS_NODE_IDLE(node_ptr) &&
1424
1697
(reg_msg->job_count != 0)) {
1425
1698
last_node_update = now;
1426
node_ptr->node_state = NODE_STATE_ALLOCATED |
1428
error("Invalid state for node %s, was IDLE with %u "
1430
node_ptr->name, reg_msg->job_count);
1699
if (node_ptr->run_job_cnt != 0) {
1700
node_ptr->node_state = NODE_STATE_ALLOCATED |
1702
error("Invalid state for node %s, was IDLE "
1703
"with %u running jobs",
1704
node_ptr->name, reg_msg->job_count);
1707
* there must be completing job(s) on this node since
1708
* reg_msg->job_count was set (run_job_cnt +
1709
* comp_job_cnt) in validate_jobs_on_node()
1711
if (node_ptr->comp_job_cnt != 0) {
1712
node_ptr->node_state |= NODE_STATE_COMPLETING;
1713
bit_set(cg_node_bitmap, node_inx);
1433
select_g_update_node_config((node_ptr-node_record_table_ptr));
1434
select_g_update_node_state((node_ptr - node_record_table_ptr),
1435
node_ptr->node_state);
1717
select_g_update_node_config(node_inx);
1718
select_g_update_node_state(node_inx, node_ptr->node_state);
1436
1719
_sync_bitmaps(node_ptr, reg_msg->job_count);
1546
1835
info("Killing orphan batch job %u", job_ptr->job_id);
1547
job_complete(job_ptr->job_id, 0, false, 0);
1836
job_complete(job_ptr->job_id, 0, false, false, 0);
1549
1838
list_iterator_destroy(job_iterator);
1551
/* Now validate the node info */
1840
(void) gres_plugin_node_config_unpack(reg_msg->gres_info,
1841
node_record_table_ptr->name);
1552
1842
for (i=0; i<node_record_count; i++) {
1553
1843
node_ptr = &node_record_table_ptr[i];
1554
1844
config_ptr = node_ptr->config_ptr;
1555
1845
jobs_on_node = node_ptr->run_job_cnt + node_ptr->comp_job_cnt;
1556
1846
node_ptr->last_response = time (NULL);
1848
(void) gres_plugin_node_config_validate(node_ptr->name,
1851
&node_ptr->gres_list,
1855
gres_plugin_node_state_log(node_ptr->gres_list, node_ptr->name);
1857
if (reg_msg->up_time) {
1858
node_ptr->up_time = reg_msg->up_time;
1859
node_ptr->boot_time = now - reg_msg->up_time;
1861
node_ptr->slurmd_start_time = reg_msg->slurmd_start_time;
1558
1863
if (IS_NODE_NO_RESPOND(node_ptr)) {
1864
update_node_state = true;
1560
1865
node_ptr->node_state &= (~NODE_STATE_NO_RESPOND);
1561
1866
node_ptr->node_state &= (~NODE_STATE_POWER_UP);
1658
1966
node_ptr->name, reg_msg->job_count);
1661
select_g_update_node_config(
1662
(node_ptr - node_record_table_ptr));
1663
select_g_update_node_state(
1664
(node_ptr - node_record_table_ptr),
1665
node_ptr->node_state);
1969
select_g_update_node_config(i);
1970
select_g_update_node_state(i, node_ptr->node_state);
1666
1971
_sync_bitmaps(node_ptr, jobs_on_node);
1670
1975
if (prolog_hostlist) {
1671
1976
hostlist_uniq(prolog_hostlist);
1672
hostlist_ranged_string(prolog_hostlist, sizeof(host_str),
1977
host_str = hostlist_ranged_string_xmalloc(prolog_hostlist);
1674
1978
error("Prolog failure on nodes %s, set to DOWN", host_str);
1675
1980
hostlist_destroy(prolog_hostlist);
1677
1982
if (reg_hostlist) {
1678
1983
hostlist_uniq(reg_hostlist);
1679
hostlist_ranged_string(reg_hostlist, sizeof(host_str),
1984
host_str = hostlist_ranged_string_xmalloc(reg_hostlist);
1681
1985
debug("Nodes %s have registered", host_str);
1682
1987
hostlist_destroy(reg_hostlist);
1684
1989
if (return_hostlist) {
1685
1990
hostlist_uniq(return_hostlist);
1686
hostlist_ranged_string(return_hostlist, sizeof(host_str),
1991
host_str = hostlist_ranged_string_xmalloc(return_hostlist);
1688
1992
info("Nodes %s returned to service", host_str);
1689
1994
hostlist_destroy(return_hostlist);
1997
if (update_node_state) {
1693
1998
last_node_update = time (NULL);
1694
1999
reset_job_priority();
2196
2521
last_node_update = now;
2197
if (node_ptr->comp_job_cnt == 0)
2522
if (node_ptr->comp_job_cnt == 0) {
2198
2523
node_ptr->node_state &= (~NODE_STATE_COMPLETING);
2524
bit_clear(cg_node_bitmap, inx);
2199
2526
node_flags = node_ptr->node_state & NODE_STATE_FLAGS;
2200
2527
if (IS_NODE_DOWN(node_ptr)) {
2201
2528
debug3("make_node_idle: Node %s being left DOWN",
2202
2529
node_ptr->name);
2203
2530
} else if ((IS_NODE_DRAIN(node_ptr) || IS_NODE_FAIL(node_ptr)) &&
2204
(node_ptr->run_job_cnt == 0) &&
2205
(node_ptr->comp_job_cnt == 0)) {
2531
(node_ptr->run_job_cnt == 0) &&
2532
(node_ptr->comp_job_cnt == 0)) {
2206
2533
node_ptr->node_state = NODE_STATE_IDLE | node_flags;
2207
bit_set(idle_node_bitmap, inx);
2208
2534
bit_clear(avail_node_bitmap, inx);
2535
bit_set(idle_node_bitmap, inx);
2536
bit_set(up_node_bitmap, inx);
2209
2537
debug3("make_node_idle: Node %s is DRAINED",
2210
2538
node_ptr->name);
2211
2539
node_ptr->last_idle = now;
2212
2540
trigger_node_drained(node_ptr);
2213
2541
clusteracct_storage_g_node_down(acct_db_conn,
2214
slurmctld_cluster_name,
2215
node_ptr, now, NULL);
2542
node_ptr, now, NULL,
2543
slurm_get_slurm_user_id());
2216
2544
} else if (node_ptr->run_job_cnt) {
2217
2545
node_ptr->node_state = NODE_STATE_ALLOCATED | node_flags;
2546
if (!IS_NODE_NO_RESPOND(node_ptr) &&
2547
!IS_NODE_FAIL(node_ptr) && !IS_NODE_DRAIN(node_ptr))
2548
bit_set(avail_node_bitmap, inx);
2549
bit_set(up_node_bitmap, inx);
2219
2551
node_ptr->node_state = NODE_STATE_IDLE | node_flags;
2220
2552
if (!IS_NODE_NO_RESPOND(node_ptr) &&
2553
!IS_NODE_FAIL(node_ptr) && !IS_NODE_DRAIN(node_ptr))
2554
bit_set(avail_node_bitmap, inx);
2555
if (!IS_NODE_NO_RESPOND(node_ptr) &&
2221
2556
!IS_NODE_COMPLETING(node_ptr))
2222
2557
bit_set(idle_node_bitmap, inx);
2558
bit_set(up_node_bitmap, inx);
2223
2559
node_ptr->last_idle = now;