From b9af7b9c4a5acbfd238913a20f383f01d5fd2ece Mon Sep 17 00:00:00 2001 From: Tim Wickberg <tim@schedmd.com> Date: Thu, 29 Sep 2016 07:18:33 -0400 Subject: [PATCH] Prevent update to last_part_update by partition uid access updates when no change made. Switch to list_for_each, and check if access list actually changed after each update before updating last_prat_update. This prevents the backfill scheduler from resetting mid-cycle unnecessarily. Bug 3123. --- NEWS | 3 +++ src/slurmctld/partition_mgr.c | 49 ++++++++++++++++++++++++++++------- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index ab256bb133d..c9316fc71c2 100644 --- a/NEWS +++ b/NEWS @@ -89,6 +89,9 @@ documents those changes that are of interest to users and administrators. behaviour with respect to waiting for all allocated nodes to be ready for use. Job can override the configuration option using the --wait-all-nodes=# option. + -- Prevent partition group access updates from resetting last_part_update when + no changes have been made. Prevents backfill scheduler from restarting + mid-cycle unnecessarily. * Changes in Slurm 16.05.4 ========================== diff --git a/src/slurmctld/partition_mgr.c b/src/slurmctld/partition_mgr.c index 7a3f7c96efb..dd2a6869d4f 100644 --- a/src/slurmctld/partition_mgr.c +++ b/src/slurmctld/partition_mgr.c @@ -2010,6 +2010,36 @@ extern int validate_alloc_node(struct part_record *part_ptr, char* alloc_node) return status; } +static int _update_part_uid_access_list(void *x, void *arg) +{ + struct part_record *part_ptr = (struct part_record *)x; + int *updated = (int *)arg; + int i = 0; + uid_t *tmp_uids; + + tmp_uids = part_ptr->allow_uids; + part_ptr->allow_uids = _get_groups_members(part_ptr->allow_groups); + + if ((!part_ptr->allow_uids) && (!tmp_uids)) { + /* no changes, and no arrays to compare */ + } else if ((!part_ptr->allow_uids) || (!tmp_uids)) { + /* one is set when it wasn't before */ + *updated = 1; + } else { + /* step through arrays and compare item by item */ + /* uid_t arrays are terminated with a zero */ + for (i = 0; part_ptr->allow_uids[i]; i++) { + if (tmp_uids[i] != part_ptr->allow_uids[i]) { + *updated = 1; + break; + } + } + } + + xfree(tmp_uids); + return 0; +} + /* * load_part_uid_allow_list - reload the allow_uid list of partitions * if required (updated group file or force set) @@ -2018,9 +2048,8 @@ extern int validate_alloc_node(struct part_record *part_ptr, char* alloc_node) void load_part_uid_allow_list(int force) { static time_t last_update_time; + int updated = 0; time_t temp_time; - ListIterator part_iterator; - struct part_record *part_ptr; DEF_TIMERS; START_TIMER; @@ -2029,16 +2058,18 @@ void load_part_uid_allow_list(int force) return; debug("Updating partition uid access list"); last_update_time = temp_time; - last_part_update = time(NULL); - part_iterator = list_iterator_create(part_list); - while ((part_ptr = (struct part_record *) list_next(part_iterator))) { - xfree(part_ptr->allow_uids); - part_ptr->allow_uids = - _get_groups_members(part_ptr->allow_groups); + list_for_each(part_list, _update_part_uid_access_list, &updated); + + /* only update last_part_update when changes made to avoid restarting + * backfill scheduler unnecessarily */ + if (updated) { + debug2("%s: list updated, resetting last_part_update time", + __func__); + last_part_update = time(NULL); } + clear_group_cache(); - list_iterator_destroy(part_iterator); END_TIMER2("load_part_uid_allow_list"); } -- GitLab