Skip to content

Commit 0730f5f

Browse files
garlickmergify[bot]
authored andcommitted
flux-job: remove cancel[all]subcommands
Problem: flux job cancel[all] have been deprecated in favor of flux cancel [--all] for a long time but still exist, leading to occasional confusion. Remove those subcommands. Fixes issue#7034
1 parent afeb76e commit 0730f5f

File tree

2 files changed

+1
-138
lines changed

2 files changed

+1
-138
lines changed

src/cmd/job/cancel.c

Lines changed: 1 addition & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* SPDX-License-Identifier: LGPL-3.0
99
\************************************************************/
1010

11-
/* flux-job raise/cancel/kill */
11+
/* flux-job raise/kill */
1212

1313
#if HAVE_CONFIG_H
1414
#include "config.h"
@@ -26,30 +26,6 @@
2626
#include "ccan/str/str.h"
2727
#include "common.h"
2828

29-
struct optparse_option cancel_opts[] = {
30-
{ .name = "message", .key = 'm', .has_arg = 1, .arginfo = "NOTE",
31-
.usage = "Set cancel exception note",
32-
},
33-
OPTPARSE_TABLE_END
34-
};
35-
36-
struct optparse_option cancelall_opts[] = {
37-
{ .name = "user", .key = 'u', .has_arg = 1, .arginfo = "USER",
38-
.usage = "Set target user or 'all' (instance owner only)",
39-
},
40-
{ .name = "states", .key = 'S', .has_arg = 1, .arginfo = "STATES",
41-
.flags = OPTPARSE_OPT_AUTOSPLIT,
42-
.usage = "Set target job states (default=ACTIVE)",
43-
},
44-
{ .name = "force", .key = 'f', .has_arg = 0,
45-
.usage = "Confirm the command",
46-
},
47-
{ .name = "quiet", .key = 'q', .has_arg = 0,
48-
.usage = "Suppress output if no jobs match",
49-
},
50-
OPTPARSE_TABLE_END
51-
};
52-
5329
struct optparse_option raise_opts[] = {
5430
{ .name = "severity", .key = 's', .has_arg = 1, .arginfo = "N",
5531
.usage = "Set exception severity [0-7] (default=0)",
@@ -449,98 +425,5 @@ int cmd_killall (optparse_t *p, int argc, char **argv)
449425
return 0;
450426
}
451427

452-
int cmd_cancel (optparse_t *p, int argc, char **argv)
453-
{
454-
int optindex = optparse_option_index (p);
455-
flux_t *h;
456-
char *note = NULL;
457-
zlistx_t *args;
458-
struct jobid_arg *arg;
459-
flux_future_t *f;
460-
int rc = 0;
461-
462-
if (argc - optindex < 1) {
463-
optparse_print_usage (p);
464-
exit (1);
465-
}
466-
467-
parse_jobids_and_note (p, argv + optindex, &args, &note);
468-
469-
fprintf (stderr,
470-
"WARNING: this command is deprecated. Use flux-cancel(1).\n");
471-
472-
if (!(h = flux_open (NULL, 0)))
473-
log_err_exit ("flux_open");
474-
475-
if (!(f = flux_future_wait_all_create ()))
476-
log_err_exit ("flux_future_wait_all_create");
477-
flux_future_set_flux (f, h);
478-
479-
arg = zlistx_first (args);
480-
while (arg) {
481-
flux_future_t *rf = flux_job_cancel (h, arg->id, note);
482-
if (!rf || flux_future_push (f, arg->arg, rf) < 0)
483-
log_err_exit ("flux_job_cancel");
484-
arg = zlistx_next (args);
485-
}
486-
rc = wait_all_check (f, "cancel");
487-
488-
zlistx_destroy (&args);
489-
flux_future_destroy (f);
490-
flux_close (h);
491-
free (note);
492-
return rc;
493-
}
494-
495-
int cmd_cancelall (optparse_t *p, int argc, char **argv)
496-
{
497-
int optindex = optparse_option_index (p);
498-
uint32_t userid;
499-
int state_mask;
500-
flux_t *h;
501-
char *note = NULL;
502-
int dry_run = 1;
503-
int count;
504-
int errors;
505-
506-
if (optindex < argc)
507-
note = parse_arg_message (argv + optindex, "message");
508-
if (optparse_hasopt (p, "states")) {
509-
state_mask = parse_arg_states (p, "states");
510-
if ((state_mask & FLUX_JOB_STATE_INACTIVE))
511-
log_msg_exit ("Inactive jobs cannot be canceled");
512-
}
513-
else
514-
state_mask = FLUX_JOB_STATE_ACTIVE;
515-
if (optparse_hasopt (p, "user"))
516-
userid = parse_arg_userid (p, "user");
517-
else
518-
userid = getuid ();
519-
if (optparse_hasopt (p, "force"))
520-
dry_run = 0;
521-
fprintf (stderr,
522-
"WARNING: this command is deprecated. Use flux-cancel(1).\n");
523-
if (!(h = flux_open (NULL, 0)))
524-
log_err_exit ("flux_open");
525-
count = raiseall (h,
526-
dry_run,
527-
userid,
528-
state_mask,
529-
0,
530-
"cancel",
531-
note,
532-
&errors);
533-
if (count > 0 && dry_run)
534-
log_msg ("Command matched %d jobs (-f to confirm)", count);
535-
else if (count > 0 && !dry_run)
536-
log_msg ("Canceled %d jobs (%d errors)", count, errors);
537-
else if (!optparse_hasopt (p, "quiet"))
538-
log_msg ("Command matched 0 jobs");
539-
flux_close (h);
540-
free (note);
541-
return 0;
542-
}
543-
544-
545428
/* vi: ts=4 sw=4 expandtab
546429
*/

src/cmd/job/main.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ extern int cmd_namespace (optparse_t *p, int argc, char **argv);
4646
extern int cmd_urgency (optparse_t *p, int argc, char **argv);
4747
extern struct optparse_option urgency_opts[];
4848

49-
extern int cmd_cancel (optparse_t *p, int argc, char **argv);
50-
extern struct optparse_option cancel_opts[];
51-
52-
extern int cmd_cancelall (optparse_t *p, int argc, char **argv);
53-
extern struct optparse_option cancelall_opts[];
54-
5549
extern int cmd_raise (optparse_t *p, int argc, char **argv);
5650
extern struct optparse_option raise_opts[];
5751

@@ -128,20 +122,6 @@ static struct optparse_subcommand subcommands[] = {
128122
0,
129123
urgency_opts,
130124
},
131-
{ "cancel",
132-
"[OPTIONS] ids... [--] [message ...]",
133-
"Cancel one or more jobs",
134-
cmd_cancel,
135-
OPTPARSE_SUBCMD_HIDDEN,
136-
cancel_opts,
137-
},
138-
{ "cancelall",
139-
"[OPTIONS] [message ...]",
140-
"Cancel multiple jobs",
141-
cmd_cancelall,
142-
OPTPARSE_SUBCMD_HIDDEN,
143-
cancelall_opts,
144-
},
145125
{ "raise",
146126
"[OPTIONS] ids... [--] [message ...]",
147127
"Raise exception on one or more jobs",

0 commit comments

Comments
 (0)