|
8 | 8 | * SPDX-License-Identifier: LGPL-3.0 |
9 | 9 | \************************************************************/ |
10 | 10 |
|
11 | | -/* flux-job raise/cancel/kill */ |
| 11 | +/* flux-job raise/kill */ |
12 | 12 |
|
13 | 13 | #if HAVE_CONFIG_H |
14 | 14 | #include "config.h" |
|
26 | 26 | #include "ccan/str/str.h" |
27 | 27 | #include "common.h" |
28 | 28 |
|
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 | | - |
53 | 29 | struct optparse_option raise_opts[] = { |
54 | 30 | { .name = "severity", .key = 's', .has_arg = 1, .arginfo = "N", |
55 | 31 | .usage = "Set exception severity [0-7] (default=0)", |
@@ -449,98 +425,5 @@ int cmd_killall (optparse_t *p, int argc, char **argv) |
449 | 425 | return 0; |
450 | 426 | } |
451 | 427 |
|
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, ¬e); |
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 | | - |
545 | 428 | /* vi: ts=4 sw=4 expandtab |
546 | 429 | */ |
0 commit comments