Bug 290211 - sysutils/slurm-wlm: refresh rc.d scripts (slurmctld & slurmd): configurable conf/log dirs, pidfiles, status, and cleanup
Summary: sysutils/slurm-wlm: refresh rc.d scripts (slurmctld & slurmd): configurable c...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Vladimir Druzenko
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-10-13 15:52 UTC by Generic Rikka
Modified: 2025-11-26 18:32 UTC (History)
1 user (show)

See Also:


Attachments
Modernize slurm's rc.d scripts (9.43 KB, patch)
2025-11-24 18:54 UTC, Generic Rikka
rikka.goering: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Generic Rikka 2025-10-13 15:52:34 UTC
Summary

Modernize and harden the slurmctld and slurmd rc.d services:
- Make the configuration file path configurable via rc.conf (default to %%ETCDIR%%/slurm.conf).
- Add configurable log directory and pidfile locations; run via daemon(8) by default.
- Implement robust status (and onestop) using pidfiles/rc.subr.
- Review & remove outdated bits; align defaults with current port (--sysconfdir=%%ETCDIR%%).
- Preserve backwards compatibility with existing *_flags and SLURM_CONF.


Motivation / Why now

- The port now installs config under %%ETCDIR%%; rc.d should reflect that and allow overrides.
- Current scripts lack a proper status and don’t consistently manage pidfiles/logging.
- Users expect rc.d services to support configurable paths without editing scripts.


Scope of change

- Files: files/slurmctld.in and files/slurmd.in
- No ABI/API change; rc knobs only.
- Defaults safe for fresh installs; compatible with existing deployments.


Proposed rc variables (defaults)

# Common (both services honour these)
slurm_user="slurm"
slurm_group="slurm"
slurm_conf="%%ETCDIR%%/slurm.conf"     # exported as SLURM_CONF
slurm_logdir="/var/log/slurm"          # created with 0750/slurm:slurm
slurm_rundir="/var/run/slurm"          # created with 0755/root:wheel

# Service-specific (overridable)
slurmctld_enable="NO"
slurmctld_flags=""                      # extra args
slurmctld_pidfile="/var/run/slurm/slurmctld.pid"
slurmctld_logfile="/var/log/slurm/slurmctld.log"

slurmd_enable="NO"
slurmd_flags=""
slurmd_pidfile="/var/run/slurm/slurmd.pid"
slurmd_logfile="/var/log/slurm/slurmd.log"


Behavioural details

- start: create run/log dirs, ensure ownership, export SLURM_CONF="${slurm_conf}", start via daemon(8) with -P <pidfile> -o <logfile> -r.
- status: use rc_subr pidfile helpers (status_cmd="${name}_status" with check_pidfile).
- stop: stop_postcmd verifies pidfile removal; fall back to pkill -F if needed.
- reload: send HUP to daemon pid (both daemons support SIGHUP to re-read config).
- Backward compatible: existing slurm_*_flags still honoured; SLURM_CONF can be set globally in /etc/rc.conf or environment—rc script exports it from slurm_conf if not already set.
Comment 1 Vladimir Druzenko freebsd_committer freebsd_triage 2025-11-22 18:58:37 UTC
Can you create patch against current ports tree.
Comment 2 Generic Rikka 2025-11-24 18:54:07 UTC
Created attachment 265625 [details]
Modernize slurm's rc.d scripts

Created a patch against the current ports tree to modernize the slurmctld and slurmd rc.d scripts.

The updated scripts:
 - Add rc.conf knobs for slurm_conf, log directory, run directory, pidfile, and logfile paths.
 - Run slurmctld and slurmd via daemon(8) in foreground mode (-D) for predictable pidfile and log handling.
 - Implement status and reload using pidfiles and rc.subr helpers, instead of ad-hoc logic.
 - Ensure log/run directories are created with appropriate ownership and permissions (slurm:slurm for logs, root:wheel for run).
 - Improve stop handling to avoid leaving stray helper processes behind after restarts.
 - Preserve compatibility with existing slurm*_flags and SLURM_CONF configuration.

I tested:
 - Starting/stopping/restarting both services, including status and reload, and verified they act on the correct PIDs.
 - Overriding all new rc.conf knobs (paths for config, logs, pidfiles, rundir) and confirmed the services honour them.
 - Bringing up a minimal controller + worker setup to confirm that the updated rc.d scripts do not interfere with normal Slurm operation.
Comment 3 commit-hook freebsd_committer freebsd_triage 2025-11-26 18:31:41 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=dbb76b3a6836ad106df7fb4a99753ef55fed939b

commit dbb76b3a6836ad106df7fb4a99753ef55fed939b
Author:     Generic Rikka <rikka.goering@outlook.de>
AuthorDate: 2025-11-26 18:27:56 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2025-11-26 18:29:59 +0000

    sysutils/slurm-wlm: Improve rc.d scripts

    - Add rc.conf knobs for slurm_conf, logdir, rundir, pidfile and logfile paths
    - Run slurmctld and slurmd under daemon(8) in foreground mode (-D)
    - Implement status/reload using pidfiles and procname via rc.subr helpers
    - Create log/run directories with appropriate ownership and permissions
    - Ensure clean shutdown and avoid stray helper processes across restarts
    - Preserve compatibility with existing *_flags and SLURM_CONF settings

    PR:     290211

 sysutils/slurm-wlm/Makefile           |   1 +
 sysutils/slurm-wlm/files/slurmctld.in | 133 +++++++++++++++++++++++++++++-----
 sysutils/slurm-wlm/files/slurmd.in    | 111 +++++++++++++++++++++++-----
 3 files changed, 209 insertions(+), 36 deletions(-)
Comment 4 Vladimir Druzenko freebsd_committer freebsd_triage 2025-11-26 18:32:19 UTC
Thanks.