From 0e97b7ce4cb3f0e13ba25efe5192619c9e4771d5 Mon Sep 17 00:00:00 2001 From: Jim Garlick Date: Mon, 25 Apr 2022 17:40:23 -0700 Subject: [PATCH] flux-shutdown: add --gc, --dump=PATH options Problem: a system instance that runs flux-dump(1) from rc3 might get killed by systemd TimeoutStopSec. Have flux-shutdown(1) arrange for the dump. If the instance is being shut down by this method, then systemctl stop is not being run, so TimeoutStopSec does not apply. --- src/cmd/builtin/shutdown.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/cmd/builtin/shutdown.c b/src/cmd/builtin/shutdown.c index b2cc411ce76b..006d8f4f94db 100644 --- a/src/cmd/builtin/shutdown.c +++ b/src/cmd/builtin/shutdown.c @@ -68,6 +68,15 @@ static int subcmd (optparse_t *p, int ac, char *av[]) if (optparse_hasopt (p, "background")) flags &= ~FLUX_RPC_STREAMING; + if (optparse_hasopt (p, "gc") || optparse_hasopt (p, "dump")) { + const char *val = optparse_get_str (p, "dump", "auto"); + + if (flux_attr_set (h, "content.dump", val) < 0) + log_err_exit ("error setting content.dump attribute"); + + log_msg ("shutdown will dump KVS (this may take some time)"); + } + /* N.B. set nodeid=FLUX_NODEID_ANY so we get immediate error from * broker if run on rank > 0. */ @@ -90,6 +99,12 @@ static int subcmd (optparse_t *p, int ac, char *av[]) } static struct optparse_option opts[] = { + { .name = "gc", .has_arg = 0, + .usage = "Garbage collect KVS (short for --dump=auto)", + }, + { .name = "dump", .has_arg = 1, .arginfo = "PATH", + .usage = "Dump KVS content to specified archive file using flux-dump(1)." + }, { .name = "background", .has_arg = 0, .usage = "Exit the command immediately after initiating shutdown", },