Skip to content

Commit

Permalink
resource: parse systemd.enable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
garlick committed Feb 7, 2025
1 parent 05e4223 commit f177ae5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/modules/resource/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand All @@ -401,7 +401,6 @@ struct monitor *monitor_create (struct resource_ctx *ctx,
return NULL;
}


/*
* vi:tabstop=4 shiftwidth=4 expandtab
*/
2 changes: 1 addition & 1 deletion src/modules/resource/monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 11 additions & 1 deletion src/modules/resource/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,23 @@ 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;
rconfig->norestrict = norestrict ? true : false;
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);
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/modules/resource/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f177ae5

Please sign in to comment.