git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/slurm: add slurmdbd to module

* New options "services.slurm.dbdserver.[enable,config]" * Add slurmdbd to test slurm.nix

commit79c9dbfb40d5123f18ed64485265d8bc19209091 authorMarkus Kowalewski <markus.kowalewski@gmail.com> dateSat 15 Sep 2018, 13:09 (8 years ago) parent111d4eb
2 files changed+99−7
nixos/modules/services/computing/slurm/slurm.nix+53−2 nixos/tests/slurm.nix+46−5
nixos/modules/services/computing/slurm/slurm.nix+53−2
@@ -29,12 +29,19 @@ let
2929 ${cfg.extraPlugstackConfig}
3030 '';
3131
32−
3332 cgroupConfig = pkgs.writeTextDir "cgroup.conf"
3433 ''
3534 ${cfg.extraCgroupConfig}
3635 '';
3736
37+ slurmdbdConf = pkgs.writeTextDir "slurmdbd.conf"
38+ ''
39+ DbdHost=${cfg.dbdserver.dbdHost}
40+ SlurmUser=${cfg.user}
41+ StorageType=accounting_storage/mysql
42+ ${cfg.dbdserver.extraConfig}
43+ '';
44+
3845 # slurm expects some additional config files to be
3946 # in the same directory as slurm.conf
4047 etcSlurm = pkgs.symlinkJoin {
@@ -65,6 +72,27 @@ in
6572 };
6673 };
6774
75+ dbdserver = {
76+ enable = mkEnableOption "SlurmDBD service";
77+
78+ dbdHost = mkOption {
79+ type = types.str;
80+ default = config.networking.hostName;
81+ description = ''
82+ Hostname of the machine where <literal>slurmdbd</literal>
83+ is running (i.e. name returned by <literal>hostname -s</literal>).
84+ '';
85+ };
86+
87+ extraConfig = mkOption {
88+ type = types.lines;
89+ default = "";
90+ description = ''
91+ Extra configuration for <literal>slurmdbd.conf</literal>
92+ '';
93+ };
94+ };
95+
6896 client = {
6997 enable = mkEnableOption "slurm client daemon";
7098 };
@@ -208,6 +236,8 @@ in
208236 used when <literal>procTrackType=proctrack/cgroup</literal>.
209237 '';
210238 };
239+
240+
211241 };
212242
213243 };
@@ -244,7 +274,10 @@ in
244274 '';
245275 };
246276
247− in mkIf (cfg.enableStools || cfg.client.enable || cfg.server.enable) {
277+ in mkIf ( cfg.enableStools ||
278+ cfg.client.enable ||
279+ cfg.server.enable ||
280+ cfg.dbdserver.enable ) {
248281
249282 environment.systemPackages = [ wrappedSlurm ];
250283
@@ -301,6 +334,24 @@ in
301334 '';
302335 };
303336
337+ systemd.services.slurmdbd = mkIf (cfg.dbdserver.enable) {
338+ path = with pkgs; [ wrappedSlurm munge coreutils ];
339+
340+ wantedBy = [ "multi-user.target" ];
341+ after = [ "network.target" "munged.service" "mysql.service" ];
342+ requires = [ "munged.service" "mysql.service" ];
343+
344+ # slurm strips the last component off the path
345+ environment.SLURM_CONF = "${slurmdbdConf}/slurm.conf";
346+
347+ serviceConfig = {
348+ Type = "forking";
349+ ExecStart = "${cfg.package}/bin/slurmdbd";
350+ PIDFile = "/run/slurmdbd.pid";
351+ ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
352+ };
353+ };
354+
304355 };
305356
306357}
nixos/tests/slurm.nix+46−5
@@ -1,5 +1,7 @@
11import ./make-test.nix ({ ... }:
2−let mungekey = "mungeverryweakkeybuteasytointegratoinatest";
2+let
3+ mungekey = "mungeverryweakkeybuteasytointegratoinatest";
4+
35 slurmconfig = {
46 controlMachine = "control";
57 nodeName = ''
@@ -7,6 +9,10 @@ let mungekey = "mungeverryweakkeybuteasytointegratoinatest";
79 NodeName=node[1-3] CPUs=1 State=UNKNOWN
810 '';
911 partitionName = "debug Nodes=node[1-3] Default=YES MaxTime=INFINITE State=UP";
12+ extraConfig = ''
13+ AccountingStorageHost=dbd
14+ AccountingStorageType=accounting_storage/slurmdbd
15+ '';
1016 };
1117in {
1218 name = "slurm";
@@ -16,7 +22,7 @@ in {
1622 computeNode =
1723 { ...}:
1824 {
19− # TODO slrumd port and slurmctld port should be configurations and
25+ # TODO slurmd port and slurmctld port should be configurations and
2026 # automatically allowed by the firewall.
2127 networking.firewall.enable = false;
2228 services.slurm = {
@@ -43,6 +49,24 @@ in {
4349 } // slurmconfig;
4450 };
4551
52+ dbd =
53+ { pkgs, ... } :
54+ {
55+ networking.firewall.enable = false;
56+ services.slurm.dbdserver = {
57+ enable = true;
58+ };
59+ services.mysql = {
60+ enable = true;
61+ package = pkgs.mysql;
62+ ensureDatabases = [ "slurm_acct_db" ];
63+ ensureUsers = [{
64+ ensurePermissions = { "slurm_acct_db.*" = "ALL PRIVILEGES"; };
65+ name = "slurm";
66+ }];
67+ };
68+ };
69+
4670 node1 = computeNode;
4771 node2 = computeNode;
4872 node3 = computeNode;
@@ -54,7 +78,7 @@ in {
5478 startAll;
5579
5680 # Set up authentification across the cluster
57− foreach my $node (($submit,$control,$node1,$node2,$node3))
81+ foreach my $node (($submit,$control,$dbd,$node1,$node2,$node3))
5882 {
5983 $node->waitForUnit("default.target");
6084
@@ -63,10 +87,22 @@ in {
6387 $node->succeed("chmod 0400 /etc/munge/munge.key");
6488 $node->succeed("chown munge:munge /etc/munge/munge.key");
6589 $node->succeed("systemctl restart munged");
66− }
90+
91+ $node->waitForUnit("munged");
92+ };
6793
6894 # Restart the services since they have probably failed due to the munge init
6995 # failure
96+ subtest "can_start_slurmdbd", sub {
97+ $dbd->succeed("systemctl restart slurmdbd");
98+ $dbd->waitForUnit("slurmdbd.service");
99+ };
100+
101+ # there needs to be an entry for the current
102+ # cluster in the database before slurmctld is restarted
103+ subtest "add_account", sub {
104+ $control->succeed("sacctmgr -i add cluster default");
105+ };
70106
71107 subtest "can_start_slurmctld", sub {
72108 $control->succeed("systemctl restart slurmctld");
@@ -81,12 +117,17 @@ in {
81117 }
82118 };
83119
84− # Test that the cluster work and can distribute jobs;
120+ # Test that the cluster works and can distribute jobs;
85121
86122 subtest "run_distributed_command", sub {
87123 # Run `hostname` on 3 nodes of the partition (so on all the 3 nodes).
88124 # The output must contain the 3 different names
89125 $submit->succeed("srun -N 3 hostname | sort | uniq | wc -l | xargs test 3 -eq");
90126 };
127+
128+ subtest "check_slurm_dbd", sub {
129+ # find the srun job from above in the database
130+ $submit->succeed("sacct | grep hostname");
131+ };
91132 '';
92133})