diff --git a/src/common/read_config.c b/src/common/read_config.c index 2881d4fd7e4aea450b2415fd39a804da82744790..9f3294bda7043eb3f80195e7b492fed41fb76278 100644 --- a/src/common/read_config.c +++ b/src/common/read_config.c @@ -122,7 +122,8 @@ free_slurm_conf (slurm_ctl_conf_t *ctl_conf_ptr) /* * init_slurm_conf - initialize or re-initialize the slurm configuration - * values. + * values to defaults (NULL or NO_VAL). Note that the configuration + * file pathname (slurm_conf) is not changed. * IN/OUT ctl_conf_ptr - pointer to data structure to be initialized */ void diff --git a/src/common/read_config.h b/src/common/read_config.h index 102fd1d06fe612273bbfcd5dc763c591fe750cc1..65deae016d2d0061830149577aac0a4a8f4d4ac0 100644 --- a/src/common/read_config.h +++ b/src/common/read_config.h @@ -54,7 +54,8 @@ /* * init_slurm_conf - initialize or re-initialize the slurm configuration - * values. + * values defaults (NULL or NO_VAL). Note that the configuration + * file pathname (slurm_conf) is not changed. * IN/OUT ctl_conf_ptr - pointer to data structure to be initialized */ extern void init_slurm_conf (slurm_ctl_conf_t *ctl_conf_ptr); diff --git a/src/common/slurm_protocol_api.c b/src/common/slurm_protocol_api.c index 642013e5373a1ea2bb6d5ce4ee63a1ac1c2be62c..c8cd451315a32329d10782fc045dd842e7fb9e78 100644 --- a/src/common/slurm_protocol_api.c +++ b/src/common/slurm_protocol_api.c @@ -98,6 +98,18 @@ slurm_protocol_config_t *slurm_get_api_config() return proto_conf; } +/* slurm_api_set_conf_file + * set slurm configuration file to a non-default value + */ +extern void slurm_api_set_conf_file(char *pathname) +{ + if (pathname == NULL) + return; + xfree(slurmctld_conf.slurm_conf); + slurmctld_conf.slurm_conf = xstrdup(pathname); + return; +} + /* slurm_api_set_default_config * called by the send_controller_msg function to insure that at least * the compiled in default slurm_protocol_config object is initialized @@ -110,8 +122,9 @@ int slurm_api_set_default_config() static time_t last_config_update = (time_t) 0; slurm_mutex_lock(&config_lock); - if (stat(SLURM_CONFIG_FILE, &config_stat) < 0) { - error("Can't stat %s: %m", SLURM_CONFIG_FILE); + if ( (slurmctld_conf.slurm_conf) && + (stat(slurmctld_conf.slurm_conf, &config_stat) < 0)) { + error("Can't stat %s: %m", slurmctld_conf.slurm_conf); rc = SLURM_ERROR; goto cleanup; } @@ -121,7 +134,7 @@ int slurm_api_set_default_config() goto cleanup; last_config_update = config_stat.st_mtime; - free_slurm_conf(&slurmctld_conf); + init_slurm_conf(&slurmctld_conf); read_slurm_conf_ctl(&slurmctld_conf); if ((slurmctld_conf.control_addr == NULL) || diff --git a/src/common/slurm_protocol_api.h b/src/common/slurm_protocol_api.h index b6d3a14938c8919d9659cab9adee376848d6a344..84139c270022bf85a39dbbc13daa8022379af89a 100644 --- a/src/common/slurm_protocol_api.h +++ b/src/common/slurm_protocol_api.h @@ -83,6 +83,12 @@ int inline slurm_set_api_config(slurm_protocol_config_t * protocol_conf); */ inline slurm_protocol_config_t *slurm_get_api_config(); +/* slurm_api_set_conf_file + * set slurm configuration file to a non-default value + * pathname IN - pathname of slurm configuration file to be used + */ +extern void slurm_api_set_conf_file(char *pathname); + /* slurm_api_set_default_config * called by the send_controller_msg function to insure that at least * the compiled in default slurm_protocol_config object is initialized diff --git a/src/slurmctld/controller.c b/src/slurmctld/controller.c index e512ea6c8ebc0cfe19912049bec9da34c11eae92..fce1f6732067eed4eb32fe2602d2093d0d1ae35c 100644 --- a/src/slurmctld/controller.c +++ b/src/slurmctld/controller.c @@ -145,11 +145,12 @@ int main(int argc, char *argv[]) slurmctld_pid = getpid(); _parse_commandline(argc, argv, &slurmctld_conf); init_locks(); + slurm_api_set_conf_file(slurmctld_conf.slurm_conf); /* Get SlurmctldPidFile for _kill_old_slurmctld */ if ((error_code = read_slurm_conf_ctl (&slurmctld_conf))) fatal("read_slurm_conf_ctl reading %s: %s", - SLURM_CONFIG_FILE, slurm_strerror(error_code)); + slurmctld_conf.slurm_conf, slurm_strerror(error_code)); update_logging(); _kill_old_slurmctld(); @@ -230,7 +231,7 @@ int main(int argc, char *argv[]) /* Now recover the remaining state information */ if ((error_code = read_slurm_conf(recover))) { fatal("read_slurm_conf reading %s: %s", - SLURM_CONFIG_FILE, + slurmctld_conf.slurm_conf, slurm_strerror(error_code)); } } else { diff --git a/src/slurmd/slurmd.c b/src/slurmd/slurmd.c index 246bd7206d2f6e3389b8044e36ebdd3f2eacc841..cdf859f7ca672d446692df0cfac997625a09410e 100644 --- a/src/slurmd/slurmd.c +++ b/src/slurmd/slurmd.c @@ -446,6 +446,7 @@ _read_config() char *path_pubkey; conf->cf.slurm_conf = xstrdup(conf->conffile); + slurm_api_set_conf_file(conf->conffile); read_slurm_conf_ctl(&conf->cf);