From 5babb475344bb8b77e2e04dc45e68aaa40db234c Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Tue, 20 Jul 2010 17:56:54 +0000 Subject: [PATCH] improve error handling for scontrol hold/release commands --- src/scontrol/info_job.c | 8 +++++--- src/scontrol/update_job.c | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/scontrol/info_job.c b/src/scontrol/info_job.c index 52fe21ac740..823f7012f71 100644 --- a/src/scontrol/info_job.c +++ b/src/scontrol/info_job.c @@ -248,9 +248,9 @@ scontrol_get_job_state(uint32_t job_id) error_code = _scontrol_load_jobs(&job_buffer_ptr, job_id); if (error_code) { exit_code = 1; - if (quiet_flag != 1) + if (quiet_flag == -1) slurm_perror ("slurm_load_jobs error"); - return 0; + return (uint16_t) NO_VAL; } if (quiet_flag == -1) { char time_str[32]; @@ -265,7 +265,9 @@ scontrol_get_job_state(uint32_t job_id) if (job_ptr->job_id == job_id) return job_ptr->job_state; } - return 0; + if (quiet_flag == -1) + printf("Could not find job %u", job_id); + return (uint16_t) NO_VAL; } /* diff --git a/src/scontrol/update_job.c b/src/scontrol/update_job.c index 73ffd582567..8c76f99c476 100644 --- a/src/scontrol/update_job.c +++ b/src/scontrol/update_job.c @@ -227,6 +227,8 @@ scontrol_hold(char *op, char *job_id_str) job_msg.priority = 0; else { uint16_t job_state = scontrol_get_job_state(job_msg.job_id); + if (job_state == (uint16_t) NO_VAL) + return SLURM_ERROR; if ((job_state & JOB_STATE_BASE) != JOB_PENDING) { slurm_seterrno(ESLURM_JOB_NOT_PENDING); return ESLURM_JOB_NOT_PENDING; -- GitLab