From f177ae556cf88680b54e39bc009131a310945959 Mon Sep 17 00:00:00 2001 From: Jim Garlick Date: Thu, 6 Feb 2025 07:45:37 -0800 Subject: [PATCH] resource: parse systemd.enable Problem: the monitor subsystem of the resource module needs to know whether the "sdmon.idle" broker group will be populated. Parse the enable key from [systemd]. Pass the whole resource_config struct to the monitor subsystem instead of just monitor_force_up. --- src/modules/resource/monitor.c | 5 ++--- src/modules/resource/monitor.h | 2 +- src/modules/resource/resource.c | 12 +++++++++++- src/modules/resource/resource.h | 1 + 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/modules/resource/monitor.c b/src/modules/resource/monitor.c index 593cf89f4165..b2de5fe0b70f 100644 --- a/src/modules/resource/monitor.c +++ b/src/modules/resource/monitor.c @@ -337,7 +337,7 @@ void monitor_destroy (struct monitor *monitor) struct monitor *monitor_create (struct resource_ctx *ctx, int inventory_size, - bool monitor_force_up) + struct resource_config *config) { struct monitor *monitor; @@ -374,7 +374,7 @@ struct monitor *monitor_create (struct resource_ctx *ctx, if (!(monitor->up = idset_create (monitor->size, 0)) || !(monitor->torpid = idset_create (monitor->size, 0))) goto error; - if (monitor_force_up) { + if (config->monitor_force_up) { if (idset_range_set (monitor->up, 0, monitor->size - 1) < 0) goto error; } @@ -401,7 +401,6 @@ struct monitor *monitor_create (struct resource_ctx *ctx, return NULL; } - /* * vi:tabstop=4 shiftwidth=4 expandtab */ diff --git a/src/modules/resource/monitor.h b/src/modules/resource/monitor.h index 869513d2fb97..caac5c0131c9 100644 --- a/src/modules/resource/monitor.h +++ b/src/modules/resource/monitor.h @@ -13,7 +13,7 @@ struct monitor *monitor_create (struct resource_ctx *ctx, int inventory_size, - bool monitor_force_up); + struct resource_config *config); void monitor_destroy (struct monitor *monitor); const struct idset *monitor_get_down (struct monitor *monitor); diff --git a/src/modules/resource/resource.c b/src/modules/resource/resource.c index 09b675c901b9..f5c409f87830 100644 --- a/src/modules/resource/resource.c +++ b/src/modules/resource/resource.c @@ -145,6 +145,15 @@ static int parse_config (struct resource_ctx *ctx, return -1; } } + /* Check systemd.enable so we know whether sdmon.idle will be populated. + * Configuration errors in [systemd] are handled elsewhere. + */ + int systemd_enable = 0; + (void)flux_conf_unpack (conf, + NULL, + "{s?{s?b}}", + "systemd", + "enable", &systemd_enable); if (rconfig) { rconfig->exclude_idset = exclude; rconfig->noverify = noverify ? true : false; @@ -152,6 +161,7 @@ static int parse_config (struct resource_ctx *ctx, rconfig->no_update_watch = no_update_watch ? true : false; rconfig->rediscover = rediscover ? true : false; rconfig->R = o; + rconfig->systemd_enable = systemd_enable ? true : false; } else json_decref (o); @@ -393,7 +403,7 @@ int mod_main (flux_t *h, int argc, char **argv) goto error; if (!(ctx->monitor = monitor_create (ctx, inventory_get_size (ctx->inventory), - config.monitor_force_up))) + &config))) goto error; if (!(ctx->status = status_create (ctx))) goto error; diff --git a/src/modules/resource/resource.h b/src/modules/resource/resource.h index 41e627a209a6..bcd1d0be1fac 100644 --- a/src/modules/resource/resource.h +++ b/src/modules/resource/resource.h @@ -19,6 +19,7 @@ struct resource_config { bool norestrict; bool no_update_watch; bool monitor_force_up; + bool systemd_enable; // systemd.enable, not under [resource] }; struct resource_ctx {