git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/slurm: run ctld as user and fix spool dir

* run as user 'slurm' per default instead of root * add user/group slurm to ids.nix * fix default location for the state dir of slurmctld: (/var/spool -> /var/spool/slurmctld) * Update release notes with the above changes

commit111d4eb090cdd71b227701842dc67f3bc6dc5f44 authorMarkus Kowalewski <markus.kowalewski@gmail.com> dateTue 23 Oct 2018, 23:43 (8 years ago) parentf129ed2
3 files changed+54
nixos/doc/manual/release-notes/rl-1903.xml+14 nixos/modules/misc/ids.nix+2 nixos/modules/services/computing/slurm/slurm.nix+38
nixos/doc/manual/release-notes/rl-1903.xml+14
@@ -152,6 +152,20 @@
152152 has been renamed to <varname>postgresql_9_6</varname>.
153153 </para>
154154 </listitem>
155+ <listitem>
156+ <para>
157+ Slurm introduces the new option
158+ <literal>services.slurm.stateSaveLocation</literal>,
159+ which is now set to <literal>/var/spool/slurm</literal> by default
160+ (instead of <literal>/var/spool</literal>).
161+ Make sure to move all files to the new directory or to set the option accordingly.
162+ </para>
163+ <para>
164+ The slurmctld now runs as user <literal>slurm</literal> instead of <literal>root</literal>.
165+ If you want to keep slurmctld running as <literal>root</literal>, set
166+ <literal>services.slurm.user = root</literal>.
167+ </para>
168+ </listitem>
155169 </itemizedlist>
156170 </section>
157171
nixos/modules/misc/ids.nix+2
@@ -331,6 +331,7 @@
331331 zeronet = 304;
332332 lirc = 305;
333333 lidarr = 306;
334+ slurm = 307;
334335
335336 # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
336337
@@ -622,6 +623,7 @@
622623 zeronet = 304;
623624 lirc = 305;
624625 lidarr = 306;
626+ slurm = 307;
625627
626628 # When adding a gid, make sure it doesn't match an existing
627629 # uid. Users and groups with the same name should have equal
nixos/modules/services/computing/slurm/slurm.nix+38
@@ -6,9 +6,14 @@ let
66
77 cfg = config.services.slurm;
88 # configuration file can be generated by http://slurm.schedmd.com/configurator.html
9+
10+ defaultUser = "slurm";
11+
912 configFile = pkgs.writeTextDir "slurm.conf"
1013 ''
1114 ClusterName=${cfg.clusterName}
15+ StateSaveLocation=${cfg.stateSaveLocation}
16+ SlurmUser=${cfg.user}
1217 ${optionalString (cfg.controlMachine != null) ''controlMachine=${cfg.controlMachine}''}
1318 ${optionalString (cfg.controlAddr != null) ''controlAddr=${cfg.controlAddr}''}
1419 ${optionalString (cfg.nodeName != null) ''nodeName=${cfg.nodeName}''}
@@ -159,6 +164,25 @@ in
159164 '';
160165 };
161166
167+ stateSaveLocation = mkOption {
168+ type = types.str;
169+ default = "/var/spool/slurmctld";
170+ description = ''
171+ Directory into which the Slurm controller, slurmctld, saves its state.
172+ '';
173+ };
174+
175+ user = mkOption {
176+ type = types.str;
177+ default = defaultUser;
178+ description = ''
179+ Set this option when you want to run the slurmctld daemon
180+ as something else than the default slurm user "slurm".
181+ Note that the UID of this user needs to be the same
182+ on all nodes.
183+ '';
184+ };
185+
162186 extraConfig = mkOption {
163187 default = "";
164188 type = types.lines;
@@ -226,6 +250,15 @@ in
226250
227251 services.munge.enable = mkDefault true;
228252
253+ # use a static uid as default to ensure it is the same on all nodes
254+ users.users.slurm = mkIf (cfg.user == defaultUser) {
255+ name = defaultUser;
256+ group = "slurm";
257+ uid = config.ids.uids.slurm;
258+ };
259+
260+ users.groups.slurm.gid = config.ids.uids.slurm;
261+
229262 systemd.services.slurmd = mkIf (cfg.client.enable) {
230263 path = with pkgs; [ wrappedSlurm coreutils ]
231264 ++ lib.optional cfg.enableSrunX11 slurm-spank-x11;
@@ -261,6 +294,11 @@ in
261294 PIDFile = "/run/slurmctld.pid";
262295 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
263296 };
297+
298+ preStart = ''
299+ mkdir -p ${cfg.stateSaveLocation}
300+ chown -R ${cfg.user}:slurm ${cfg.stateSaveLocation}
301+ '';
264302 };
265303
266304 };