From 47139950c40de1a68d878bf12d16c0e8988a872c Mon Sep 17 00:00:00 2001 From: Danny Auble <da@llnl.gov> Date: Fri, 19 Jun 2009 17:17:07 +0000 Subject: [PATCH] ALTERED API CALL slurm_get_job_steps 0 has been changed to NO_VAL for both job and step id to recieve all jobs/steps. Please make adjustments to your code. --- NEWS | 3 ++ slurm/slurm.h.in | 8 +-- src/api/job_step_info.c | 8 +-- src/scancel/scancel.c | 7 +-- src/scontrol/info_job.c | 9 +--- src/slurmctld/controller.c | 2 +- src/slurmctld/step_mgr.c | 102 +++++++++++++------------------------ src/squeue/squeue.c | 8 +-- src/srun/srun.c | 3 +- src/sstat/sstat.c | 2 +- src/sview/job_info.c | 4 +- 11 files changed, 61 insertions(+), 95 deletions(-) diff --git a/NEWS b/NEWS index dc69dae7ee8..a1877b1c48c 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,9 @@ documents those changes that are of interest to users and admins. user root. -- Configuration parameter ControlMachine changed to accept multiple comma- separated hostnames for support of some high-availability architectures. + -- ALTERED API CALL slurm_get_job_steps 0 has been changed to NO_VAL for both + job and step id to recieve all jobs/steps. Please make adjustments to + your code. * Changes in SLURM 2.1.0-pre1 ============================= diff --git a/slurm/slurm.h.in b/slurm/slurm.h.in index 6494b9712a8..3dd244e1e20 100644 --- a/slurm/slurm.h.in +++ b/slurm/slurm.h.in @@ -1900,11 +1900,11 @@ extern int slurm_notify_job PARAMS(( uint32_t job_id, char *message )); /* * slurm_get_job_steps - issue RPC to get specific slurm job step * configuration information if changed since update_time. - * a job_id value of zero implies all jobs, a step_id value of - * zero implies all steps + * a job_id value of NO_VAL implies all jobs, a step_id value of + * NO_VAL implies all steps * IN update_time - time of current configuration data - * IN job_id - get information for specific job id, zero for all jobs - * IN step_id - get information for specific job step id, zero for all + * IN job_id - get information for specific job id, NO_VAL for all jobs + * IN step_id - get information for specific job step id, NO_VAL for all * job steps * IN step_response_pptr - place to store a step response pointer * IN show_flags - job step filtering options diff --git a/src/api/job_step_info.c b/src/api/job_step_info.c index fc0454038dc..82206d2e719 100644 --- a/src/api/job_step_info.c +++ b/src/api/job_step_info.c @@ -159,11 +159,11 @@ slurm_sprint_job_step_info ( job_step_info_t * job_step_ptr, /* * slurm_get_job_steps - issue RPC to get specific slurm job step * configuration information if changed since update_time. - * a job_id value of zero implies all jobs, a step_id value of - * zero implies all steps + * a job_id value of NO_VAL implies all jobs, a step_id value of + * NO_VAL implies all steps * IN update_time - time of current configuration data - * IN job_id - get information for specific job id, zero for all jobs - * IN step_id - get information for specific job step id, zero for all + * IN job_id - get information for specific job id, NO_VAL for all jobs + * IN step_id - get information for specific job step id, NO_VAL for all * job steps * IN job_info_msg_pptr - place to store a job configuration pointer * IN show_flags - job step filtering options diff --git a/src/scancel/scancel.c b/src/scancel/scancel.c index 04737292925..e97412cdef9 100644 --- a/src/scancel/scancel.c +++ b/src/scancel/scancel.c @@ -402,9 +402,10 @@ _cancel_job_id (void *ci) (uint16_t)opt.batch); } else { if (opt.batch) - error_code = slurm_signal_job_step(job_id, - SLURM_BATCH_SCRIPT, - sig); + error_code = slurm_signal_job_step( + job_id, + SLURM_BATCH_SCRIPT, + sig); else error_code = slurm_signal_job (job_id, sig); } diff --git a/src/scontrol/info_job.c b/src/scontrol/info_job.c index 985a5f6936b..049936cf794 100644 --- a/src/scontrol/info_job.c +++ b/src/scontrol/info_job.c @@ -289,7 +289,7 @@ extern void scontrol_print_step (char *job_step_id_str) { int error_code, i; - uint32_t job_id = 0, step_id = 0, step_id_set = 0; + uint32_t job_id = NO_VAL, step_id = NO_VAL; char *next_str; job_step_info_response_msg_t *job_step_info_ptr; job_step_info_t * job_step_ptr; @@ -300,10 +300,8 @@ scontrol_print_step (char *job_step_id_str) if (job_step_id_str) { job_id = (uint32_t) strtol (job_step_id_str, &next_str, 10); - if (next_str[0] == '.') { + if (next_str[0] == '.') step_id = (uint32_t) strtol (&next_str[1], NULL, 10); - step_id_set = 1; - } } if (all_flag) @@ -359,9 +357,6 @@ scontrol_print_step (char *job_step_id_str) job_step_ptr = job_step_info_ptr->job_steps ; for (i = 0; i < job_step_info_ptr->job_step_count; i++) { - if (step_id_set && (step_id == 0) && - (job_step_ptr[i].step_id != 0)) - continue; slurm_print_job_step_info (stdout, & job_step_ptr[i], one_liner ) ; } diff --git a/src/slurmctld/controller.c b/src/slurmctld/controller.c index 350a37d42cd..3fbad9f61b0 100644 --- a/src/slurmctld/controller.c +++ b/src/slurmctld/controller.c @@ -1843,7 +1843,7 @@ static bool _valid_controller(void) if (strcmp(node_name, slurmctld_conf.control_machine) == 0) match = true; else if (strchr(slurmctld_conf.control_machine, ',')) { - char *token, *last; + char *token, *last = NULL; char *tmp_name = xstrdup(slurmctld_conf.control_machine); token = strtok_r(tmp_name, ",", &last); diff --git a/src/slurmctld/step_mgr.c b/src/slurmctld/step_mgr.c index d433de332de..32adf7aaca9 100644 --- a/src/slurmctld/step_mgr.c +++ b/src/slurmctld/step_mgr.c @@ -1556,17 +1556,17 @@ static void _pack_ctld_job_step_info(struct step_record *step_ptr, Buf buffer) /* * pack_ctld_job_step_info_response_msg - packs job step info - * IN job_id - specific id or zero for all - * IN step_id - specific id or zero for all + * IN job_id - specific id or NO_VAL for all + * IN step_id - specific id or NO_VAL for all * IN uid - user issuing request * IN show_flags - job step filtering options * OUT buffer - location to store data, pointers automatically advanced * RET - 0 or error code * NOTE: MUST free_buf buffer */ -extern int pack_ctld_job_step_info_response_msg(uint32_t job_id, - uint32_t step_id, uid_t uid, - uint16_t show_flags, Buf buffer) +extern int pack_ctld_job_step_info_response_msg( + uint32_t job_id, uint32_t step_id, uid_t uid, + uint16_t show_flags, Buf buffer) { ListIterator job_iterator; ListIterator step_iterator; @@ -1575,79 +1575,45 @@ extern int pack_ctld_job_step_info_response_msg(uint32_t job_id, struct step_record *step_ptr; struct job_record *job_ptr; time_t now = time(NULL); + int valid_job = 0; pack_time(now, buffer); pack32(steps_packed, buffer); /* steps_packed placeholder */ part_filter_set(uid); - if (job_id == 0) { - /* Return all steps for all jobs */ - job_iterator = list_iterator_create(job_list); - while ((job_ptr = - (struct job_record *) - list_next(job_iterator))) { - if (((show_flags & SHOW_ALL) == 0) && (uid != 0) && - (job_ptr->part_ptr) && - (job_ptr->part_ptr->hidden)) - continue; - if ((slurmctld_conf.private_data & PRIVATE_DATA_JOBS) - && (job_ptr->user_id != uid) - && !validate_super_user(uid)) - continue; + job_iterator = list_iterator_create(job_list); + while ((job_ptr = list_next(job_iterator))) { + if ((job_id != NO_VAL) && (job_ptr->job_id != job_id)) + continue; - step_iterator = - list_iterator_create(job_ptr->step_list); - while ((step_ptr = - (struct step_record *) - list_next(step_iterator))) { - _pack_ctld_job_step_info(step_ptr, buffer); - steps_packed++; - } - list_iterator_destroy(step_iterator); - } - list_iterator_destroy(job_iterator); + if (((show_flags & SHOW_ALL) == 0) + && (job_ptr->part_ptr) + && (job_ptr->part_ptr->hidden)) + continue; + + if ((slurmctld_conf.private_data & PRIVATE_DATA_JOBS) + && (job_ptr->user_id != uid) + && !validate_super_user(uid)) + continue; + + valid_job = 1; - } else { - job_ptr = find_job_record(job_id); - /* first lets filter this step based on permission and - request if not allowable set job_ptr = NULL */ - if(job_ptr) { - if (((show_flags & SHOW_ALL) == 0) - && (job_ptr->part_ptr) - && (job_ptr->part_ptr->hidden)) - job_ptr = NULL; - else if ((slurmctld_conf.private_data - & PRIVATE_DATA_JOBS) - && (job_ptr->user_id != uid) - && !validate_super_user(uid)) - job_ptr = NULL; + step_iterator = list_iterator_create(job_ptr->step_list); + while ((step_ptr = list_next(step_iterator))) { + if ((step_id != NO_VAL) + && (step_ptr->step_id != step_id)) + continue; + _pack_ctld_job_step_info(step_ptr, buffer); + steps_packed++; } + list_iterator_destroy(step_iterator); + } + list_iterator_destroy(job_iterator); + + if(!valid_job && !steps_packed) + error_code = ESLURM_INVALID_JOB_ID; - /* now send the requested steps */ - if (job_ptr) { - step_iterator = - list_iterator_create(job_ptr->step_list); - /* If step_id is 0 that means to send all - steps (We understand this is incorrect - since 0 is a valid job step, - but changing it would need to be done in - the api and so we wait until 2.1 */ - while ((step_ptr = list_next(step_iterator))) { - if ((step_id == 0) - || (step_ptr->step_id == step_id)) { - _pack_ctld_job_step_info( - step_ptr, buffer); - steps_packed++; - } - } - list_iterator_destroy(step_iterator); - - if(!steps_packed) - error_code = ESLURM_INVALID_JOB_ID; - } else - error_code = ESLURM_INVALID_JOB_ID; - } part_filter_clear(); /* put the real record count in the message body header */ diff --git a/src/squeue/squeue.c b/src/squeue/squeue.c index 0bc20e81cf5..53fce97b4f0 100644 --- a/src/squeue/squeue.c +++ b/src/squeue/squeue.c @@ -213,8 +213,8 @@ _print_job_steps( void ) if (old_step_ptr) { /* Use a last_update time of 0 so that we can get an updated * run_time for jobs rather than just its start_time */ - error_code = slurm_get_job_steps ((time_t) 0, - 0, 0, &new_step_ptr, show_flags); + error_code = slurm_get_job_steps ( + (time_t) 0, NO_VAL, NO_VAL, &new_step_ptr, show_flags); if (error_code == SLURM_SUCCESS) slurm_free_job_step_info_response_msg( old_step_ptr ); else if (slurm_get_errno () == SLURM_NO_CHANGE_IN_DATA) { @@ -223,8 +223,8 @@ _print_job_steps( void ) } } else - error_code = slurm_get_job_steps ((time_t) 0, 0, 0, - &new_step_ptr, show_flags); + error_code = slurm_get_job_steps ((time_t) 0, NO_VAL, NO_VAL, + &new_step_ptr, show_flags); if (error_code) { slurm_perror ("slurm_get_job_steps error"); return SLURM_ERROR; diff --git a/src/srun/srun.c b/src/srun/srun.c index 13c5f81e5e2..a5c31c3add1 100644 --- a/src/srun/srun.c +++ b/src/srun/srun.c @@ -917,7 +917,8 @@ _set_stdio_fds(srun_job_t *job, slurm_step_io_fds_t *cio_fds) * used, but we need to load the symbols. */ static void _define_symbols(void) { - slurm_signal_job_step(0,0,0); /* needed by mvapich and mpichgm */ + /* needed by mvapich and mpichgm */ + slurm_signal_job_step(NO_VAL, NO_VAL, 0); } static void _pty_restore(void) diff --git a/src/sstat/sstat.c b/src/sstat/sstat.c index 6bb5eb17250..ef15d3f0247 100644 --- a/src/sstat/sstat.c +++ b/src/sstat/sstat.c @@ -247,7 +247,7 @@ int main(int argc, char **argv) job_step_info_response_msg_t *step_ptr = NULL; int i = 0; if(slurm_get_job_steps( - 0, selected_step->jobid, 0, + 0, selected_step->jobid, NO_VAL, &step_ptr, SHOW_ALL)) { error("couldn't get steps for job %u", selected_step->jobid); diff --git a/src/sview/job_info.c b/src/sview/job_info.c index 950d0fb3c9b..b9d1cb93196 100644 --- a/src/sview/job_info.c +++ b/src/sview/job_info.c @@ -2477,7 +2477,7 @@ extern int get_new_info_job_step(job_step_info_response_msg_t **info_ptr, show_flags |= SHOW_ALL; if (old_step_ptr) { error_code = slurm_get_job_steps(old_step_ptr->last_update, - 0, 0, &new_step_ptr, + NO_VAL, NO_VAL, &new_step_ptr, show_flags); if (error_code == SLURM_SUCCESS) { slurm_free_job_step_info_response_msg(old_step_ptr); @@ -2488,7 +2488,7 @@ extern int get_new_info_job_step(job_step_info_response_msg_t **info_ptr, changed = 0; } } else { - error_code = slurm_get_job_steps((time_t) NULL, 0, 0, + error_code = slurm_get_job_steps((time_t) NULL, NO_VAL, NO_VAL, &new_step_ptr, show_flags); changed = 1; } -- GitLab