Skip to content

Commit 5b330f5

Browse files
committed
job-manager: add stop-queues-on-restart config key
Problem: Adminstrators would like a way to have all queues stopped after a Flux restart, but there's currently no way to do that. Add a `job-manager.stop-queues-on-restart` configuration parameter which, when set to `true` stops any started queues on restart with the message "Automatically stopped due to restart". Fixes #6795
1 parent bc7b3c9 commit 5b330f5

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/modules/job-manager/queue.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ struct queue_ctx {
8282
zhashx_t *named;
8383
};
8484
bool have_named_queues;
85+
bool stop_on_restart; // stop started queues on restart
8586
};
8687

8788
static void dequeue_jobs (struct queue_ctx *qctx, const char *name);
@@ -403,7 +404,18 @@ static int restore_state_v1 (struct queue_ctx *qctx, json_t *entry)
403404
return -1;
404405
}
405406
if (start) {
406-
if (queue_start (q, false) < 0)
407+
/* If job-manager.stop-queues-on-restart is enabled, then
408+
* stop this started queue with an automated message, otherwise
409+
* leave the queue started.
410+
*/
411+
if (qctx->stop_on_restart) {
412+
if (queue_stop_one (qctx,
413+
q,
414+
"Automatically stopped due to restart",
415+
false) < 0)
416+
return -1;
417+
}
418+
else if (queue_start (q, false) < 0)
407419
return -1;
408420
}
409421
else {
@@ -493,7 +505,12 @@ static int queue_configure (const flux_conf_t *conf,
493505
struct queue_ctx *qctx = arg;
494506
json_t *queues;
495507

496-
if (flux_conf_unpack (conf, NULL, "{s:o}", "queues", &queues) == 0
508+
if (flux_conf_unpack (conf,
509+
NULL,
510+
"{s?{s?b} s:o}",
511+
"job-manager",
512+
"stop-queues-on-restart", &qctx->stop_on_restart,
513+
"queues", &queues) == 0
497514
&& json_object_size (queues) > 0) {
498515
const char *name;
499516
json_t *value;
@@ -1025,6 +1042,8 @@ struct queue_ctx *queue_ctx_create (struct job_manager *ctx)
10251042
if (!(qctx = calloc (1, sizeof (*qctx))))
10261043
return NULL;
10271044
qctx->ctx = ctx;
1045+
qctx->stop_on_restart = false;
1046+
10281047
if (!(qctx->anon = queue_create (NULL, NULL)))
10291048
goto error;
10301049
if (flux_msg_handler_addvec (ctx->h,

0 commit comments

Comments
 (0)