git: b7c34da93ef6 - main - sysutils/slurm-wlm: Fix: slurmd: error: Unable to initialize cgroup plugin

From: Vladimir Druzenko <vvd_at_FreeBSD.org>
Date: Sat, 06 Sep 2025 23:05:49 UTC
The branch main has been updated by vvd:

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

commit b7c34da93ef6159f7d4989e2d96f551fef6a7f8f
Author:     Generic Rikka <rikka.goering@outlook.de>
AuthorDate: 2025-09-06 23:03:01 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2025-09-06 23:03:01 +0000

    sysutils/slurm-wlm: Fix: slurmd: error: Unable to initialize cgroup plugin
    
    When trying to run slurmd -Dvvv, slurmd produces the following output
    and crashes:
    slurmd: debug:  Log file re-opened
    slurmd: debug2: hwloc_topology_init
    slurmd: debug2: hwloc_topology_load
    slurmd: debug2: hwloc_topology_export_xml
    slurmd: debug:  CPUs:4 Boards:1 Sockets:1 CoresPerSocket:4 ThreadsPerCore:1
    slurmd: error: Unable to initialize cgroup plugin
    slurmd: error: slurmd initialization failed
    
    Conditionally remove cgroups support on FreeBSD, to prevent slurmd from
    crashing due to missing cgroups support.
    
    PR:                     288617
    Differential Revision:  https://reviews.freebsd.org/D52138
    MFH:                    2025Q3
---
 sysutils/slurm-wlm/Makefile                        |  2 +-
 .../files/patch-src_slurmd_slurmd_slurmd.c         | 50 ++++++++++++++++++++++
 2 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/sysutils/slurm-wlm/Makefile b/sysutils/slurm-wlm/Makefile
index a676f4bb7ad2..b3532a0fbfd5 100644
--- a/sysutils/slurm-wlm/Makefile
+++ b/sysutils/slurm-wlm/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	slurm
 DISTVERSION=	23.11.7
-PORTREVISION=	10
+PORTREVISION=	11
 CATEGORIES=	sysutils
 MASTER_SITES=	https://download.schedmd.com/slurm/
 PKGNAMESUFFIX=	-wlm
diff --git a/sysutils/slurm-wlm/files/patch-src_slurmd_slurmd_slurmd.c b/sysutils/slurm-wlm/files/patch-src_slurmd_slurmd_slurmd.c
new file mode 100644
index 000000000000..cb9dcc42879a
--- /dev/null
+++ b/sysutils/slurm-wlm/files/patch-src_slurmd_slurmd_slurmd.c
@@ -0,0 +1,50 @@
+--- src/slurmd/slurmd/slurmd.c.orig	2024-05-21 17:19:51 UTC
++++ src/slurmd/slurmd/slurmd.c
+@@ -2191,10 +2191,17 @@ _slurmd_init(void)
+ 	build_all_frontend_info(true);
+ 
+ 	/*
++	 * cgroups is unsupported on FreeBSD and would prevent slurmd from starting
++	 */
++#if defined(__FreeBSD__)
++	info("FreeBSD: Skipping cgroup_conf_init() - cgroups unsupported");
++#else
++	/*
+ 	 * This needs to happen before _read_config where we will try to read
+ 	 * cgroup.conf values
+ 	 */
+ 	cgroup_conf_init();
++#endif
+ 
+ 	xcpuinfo_refresh_hwloc(original);
+ 
+@@ -2214,6 +2221,10 @@ _slurmd_init(void)
+ 	 * defaults and command line.
+ 	 */
+ 	_read_config();
++
++#if defined(__FreeBSD__)
++	info("FreeBSD: Skipping cgroup_g_init() - cgroups unsupported");
++#else
+ 	/*
+ 	 * This needs to happen before _resource_spec_init where we will try to
+ 	 * attach the slurmd pid to system cgroup, and after _read_config to
+@@ -2223,6 +2234,7 @@ _slurmd_init(void)
+ 		error("Unable to initialize cgroup plugin");
+ 		return SLURM_ERROR;
+ 	}
++#endif
+ 
+ #ifndef HAVE_FRONT_END
+ 	if (!find_node_record(conf->node_name))
+@@ -2562,6 +2574,10 @@ static int _resource_spec_init(void)
+  */
+ static int _resource_spec_init(void)
+ {
++#if defined(__FreeBSD__)
++	debug("FreeBSD: Skipping system cpuset and memory cgroup setup");
++	return SLURM_SUCCESS;
++#endif
+ 	fini_system_cgroup();	/* Prevent memory leak */
+ 	if (_core_spec_init() != SLURM_SUCCESS)
+ 		error("Resource spec: core specialization disabled");