From 1240c1f695652d9f7465a457f1f93759fd6de65e Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Tue, 31 May 2011 13:42:26 -0700 Subject: [PATCH] dd scancel support for --clusters option --- NEWS | 1 + src/scancel/opt.c | 6 +++--- src/scancel/scancel.c | 47 +++++++++++++++++++++++++++++++++++++------ src/squeue/squeue.c | 2 ++ 4 files changed, 47 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 0498efdc5a6..9712a3638b4 100644 --- a/NEWS +++ b/NEWS @@ -26,6 +26,7 @@ documents those changes that are of interest to users and admins. -- Improve accuracy of REQUEST_JOB_WILL_RUN start time with respect to higher priority pending jobs. -- Add -R/--reservation option to squeue command as a job filter. + -- Add scancel support for --clusters option. * Changes in SLURM 2.3.0.pre5 ============================= diff --git a/src/scancel/opt.c b/src/scancel/opt.c index 1277c2df4bc..608eee82649 100644 --- a/src/scancel/opt.c +++ b/src/scancel/opt.c @@ -365,10 +365,10 @@ static void _opt_args(int argc, char **argv) break; case (int)'M': opt.ctld = true; - if(opt.clusters) + if (opt.clusters) list_destroy(opt.clusters); - if(!(opt.clusters = - slurmdb_get_info_cluster(optarg))) { + opt.clusters = slurmdb_get_info_cluster(optarg); + if (!opt.clusters) { error("'%s' invalid entry for --cluster", optarg); exit(1); diff --git a/src/scancel/scancel.c b/src/scancel/scancel.c index 92593568b0d..045b489c2bd 100644 --- a/src/scancel/scancel.c +++ b/src/scancel/scancel.c @@ -59,6 +59,7 @@ #include "slurm/slurm.h" +#include "src/common/list.h" #include "src/common/log.h" #include "src/common/xstring.h" #include "src/common/xmalloc.h" @@ -69,14 +70,16 @@ #define MAX_THREADS 20 -static void _cancel_jobs (void); +static void _cancel_jobs (void); static void *_cancel_job_id (void *cancel_info); static void *_cancel_step_id (void *cancel_info); static int _confirmation (int i, uint32_t step_id); static void _filter_job_records (void); static void _load_job_records (void); -static int _verify_job_ids (void); +static int _multi_cluster(List clusters); +static int _proc_cluster(void); +static int _verify_job_ids (void); static job_info_msg_t * job_buffer_ptr = NULL; @@ -107,9 +110,41 @@ main (int argc, char *argv[]) log_alter (log_opts, SYSLOG_FACILITY_DAEMON, NULL); } + if (opt.clusters) + rc = _multi_cluster(opt.clusters); + else + rc = _proc_cluster(); + + exit (rc); +} + +/* _multi_cluster - process job cancellation across a list of clusters */ +static int +_multi_cluster(List clusters) +{ + ListIterator itr; + int rc = 0, rc2; + + itr = list_iterator_create(clusters); + if (!itr) + fatal("list_iterator_create: malloc failure"); + while ((working_cluster_rec = list_next(itr))) { + rc2 = _proc_cluster(); + rc = MAX(rc, rc2); + } + list_iterator_destroy(itr); + + return rc; +} + +/* _proc_cluster - process job cancellation on a specific cluster */ +static int +_proc_cluster(void) +{ + int rc; + _load_job_records(); rc = _verify_job_ids(); - if ((opt.account) || (opt.interactive) || (opt.job_name) || @@ -120,14 +155,14 @@ main (int argc, char *argv[]) (opt.state != JOB_END) || (opt.user_name) || (opt.wckey)) { - _filter_job_records (); + _filter_job_records(); } _cancel_jobs (); + slurm_free_job_info_msg(job_buffer_ptr); - exit (rc); + return rc; } - /* _load_job_records - load all job information for filtering and verification */ static void _load_job_records (void) diff --git a/src/squeue/squeue.c b/src/squeue/squeue.c index a51517f6728..6e21287ce54 100644 --- a/src/squeue/squeue.c +++ b/src/squeue/squeue.c @@ -117,6 +117,8 @@ static int _multi_cluster(List clusters) int rc = 0, rc2; itr = list_iterator_create(clusters); + if (!itr) + fatal("list_iterator_create: malloc failure"); while ((working_cluster_rec = list_next(itr))) { if (first) first = false; -- GitLab