refactor: update slurm config to separate out client and server behaviors
Some checks failed
ci / treefmt (push) Failing after 5s
Some checks failed
ci / treefmt (push) Failing after 5s
This commit is contained in:
parent
40fca16e31
commit
35a5051ade
3 changed files with 74 additions and 39 deletions
40
modules/nixos/services/apps/slurm/client.nix
Normal file
40
modules/nixos/services/apps/slurm/client.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
inputs,
|
||||||
|
lib,
|
||||||
|
namespace,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib) mkIf mkAfter optionalString;
|
||||||
|
inherit (lib.${namespace}) getAttrByNamespace mkPersistDir;
|
||||||
|
base = "${namespace}.services.apps.slurm";
|
||||||
|
cfg = getAttrByNamespace config base;
|
||||||
|
inherit (config.networking) hostName;
|
||||||
|
in {
|
||||||
|
config = mkIf (builtins.hasAttr hostName cfg.nodeMap) {
|
||||||
|
services.slurm = {
|
||||||
|
client.enable = true;
|
||||||
|
|
||||||
|
extraConfig = mkAfter ''
|
||||||
|
SlurmdParameters=allow_ecores
|
||||||
|
|
||||||
|
TaskProlog=${inputs.dotfiles + "/slurm/prolog.sh"}
|
||||||
|
TaskEpilog=${inputs.dotfiles + "/slurm/epilog.sh"}
|
||||||
|
'';
|
||||||
|
|
||||||
|
extraCgroupConfig = ''
|
||||||
|
ConstrainCores=yes
|
||||||
|
ConstrainDevices=yes
|
||||||
|
ConstrainRAMSpace=yes
|
||||||
|
''
|
||||||
|
+ optionalString (hostName != "chibi") ''
|
||||||
|
ConstrainSwapSpace=yes
|
||||||
|
AllowedSwapSpace=0
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
${namespace}.services.storage.impermanence.folders = [
|
||||||
|
(mkPersistDir config "slurm" "/var/spool/slurmd")
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -7,11 +7,15 @@
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) types mkEnableOption mkIf groupBy mapAttrsToList attrNames mapAttrs concatStringsSep flatten;
|
inherit (lib) types mkEnableOption mkIf groupBy mapAttrsToList attrNames mapAttrs concatStringsSep flatten;
|
||||||
inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace resolveHostIP mkOpt mkOptAttrset mkListOpt mkPersistDir;
|
inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace resolveHostIP mkOpt mkOptAttrset mkListOpt mkPersistDir;
|
||||||
inherit (config.networking) hostName;
|
|
||||||
base = "${namespace}.services.apps.slurm";
|
base = "${namespace}.services.apps.slurm";
|
||||||
cfg = getAttrByNamespace config base;
|
cfg = getAttrByNamespace config base;
|
||||||
networkCfg = getAttrByNamespace config "${namespace}.services.networking";
|
networkCfg = getAttrByNamespace config "${namespace}.services.networking";
|
||||||
in {
|
in {
|
||||||
|
imports = [
|
||||||
|
./client.nix
|
||||||
|
./server.nix
|
||||||
|
];
|
||||||
|
|
||||||
options = with types;
|
options = with types;
|
||||||
mkOptionsWithNamespace base {
|
mkOptionsWithNamespace base {
|
||||||
enable = mkEnableOption "SLURM";
|
enable = mkEnableOption "SLURM";
|
||||||
|
|
@ -27,11 +31,6 @@ in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
services = {
|
services = {
|
||||||
slurm = {
|
slurm = {
|
||||||
client.enable = builtins.hasAttr hostName cfg.nodeMap;
|
|
||||||
server.enable = builtins.elem hostName cfg.controlHosts;
|
|
||||||
|
|
||||||
stateSaveLocation = "/mnt/nfs/slurm";
|
|
||||||
|
|
||||||
nodeName = let
|
nodeName = let
|
||||||
mkNodeConfig = node: info: "${node} NodeAddr=${resolveHostIP networkCfg.devices node} ${info.configString} State=UNKNOWN";
|
mkNodeConfig = node: info: "${node} NodeAddr=${resolveHostIP networkCfg.devices node} ${info.configString} State=UNKNOWN";
|
||||||
in
|
in
|
||||||
|
|
@ -61,39 +60,19 @@ in {
|
||||||
|> mapAttrsToList formatPartition;
|
|> mapAttrsToList formatPartition;
|
||||||
|
|
||||||
extraConfig = let
|
extraConfig = let
|
||||||
mkHostString = host: "SlurmctldHost=${host}(${resolveHostIP networkCfg.devices host})";
|
|
||||||
hostStrings =
|
hostStrings =
|
||||||
cfg.controlHosts
|
cfg.controlHosts
|
||||||
|> map mkHostString
|
|> map (host: "SlurmctldHost=${host}(${resolveHostIP networkCfg.devices host})")
|
||||||
|> concatStringsSep "\n";
|
|> concatStringsSep "\n";
|
||||||
in ''
|
in ''
|
||||||
${hostStrings}
|
${hostStrings}
|
||||||
GresTypes=gpu,shard
|
GresTypes=gpu,shard
|
||||||
TaskPlugin=task/cgroup
|
TaskPlugin=task/cgroup
|
||||||
SlurmdParameters=allow_ecores
|
|
||||||
DefCpuPerGPU=1
|
DefCpuPerGPU=1
|
||||||
DefMemPerCPU=1000
|
DefMemPerCPU=1000
|
||||||
ReturnToService=2
|
ReturnToService=2
|
||||||
|
|
||||||
TaskProlog=${inputs.dotfiles + "/slurm/prolog.sh"}
|
|
||||||
TaskEpilog=${inputs.dotfiles + "/slurm/epilog.sh"}
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
extraCgroupConfig =
|
|
||||||
''
|
|
||||||
ConstrainCores=yes
|
|
||||||
ConstrainDevices=yes
|
|
||||||
ConstrainRAMSpace=yes
|
|
||||||
''
|
|
||||||
+ (
|
|
||||||
if hostName != "chibi"
|
|
||||||
then ''
|
|
||||||
ConstrainSwapSpace=yes
|
|
||||||
AllowedSwapSpace=0
|
|
||||||
''
|
|
||||||
else ''''
|
|
||||||
);
|
|
||||||
|
|
||||||
extraConfigPaths = [(inputs.dotfiles + "/slurm/config")];
|
extraConfigPaths = [(inputs.dotfiles + "/slurm/config")];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -103,16 +82,6 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.slurmctld = mkIf (builtins.elem hostName cfg.controlHosts) {
|
|
||||||
requires = [
|
|
||||||
"mnt-nfs-slurm.mount"
|
|
||||||
];
|
|
||||||
|
|
||||||
after = [
|
|
||||||
"mnt-nfs-slurm.mount"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
sops.secrets = let
|
sops.secrets = let
|
||||||
inherit (config.users.users) munge;
|
inherit (config.users.users) munge;
|
||||||
in {
|
in {
|
||||||
|
|
@ -126,8 +95,6 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
${namespace}.services.storage.impermanence.folders = [
|
${namespace}.services.storage.impermanence.folders = [
|
||||||
(mkPersistDir config "slurm" "/var/spool/slurmctld")
|
|
||||||
(mkPersistDir config "slurm" "/var/spool/slurmd")
|
|
||||||
(mkPersistDir config "munge" "/var/lib/munge")
|
(mkPersistDir config "munge" "/var/lib/munge")
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
28
modules/nixos/services/apps/slurm/server.nix
Normal file
28
modules/nixos/services/apps/slurm/server.nix
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
namespace,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib) mkIf;
|
||||||
|
inherit (lib.${namespace}) getAttrByNamespace mkPersistDir;
|
||||||
|
base = "${namespace}.services.apps.slurm";
|
||||||
|
cfg = getAttrByNamespace config base;
|
||||||
|
inherit (config.networking) hostName;
|
||||||
|
in {
|
||||||
|
config = mkIf (builtins.elem hostName cfg.controlHosts) {
|
||||||
|
services.slurm = {
|
||||||
|
server.enable = true;
|
||||||
|
stateSaveLocation = "/mnt/nfs/slurm";
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services.slurmctld = {
|
||||||
|
requires = ["mnt-nfs-slurm.mount"];
|
||||||
|
after = ["mnt-nfs-slurm.mount"];
|
||||||
|
};
|
||||||
|
|
||||||
|
${namespace}.services.storage.impermanence.folders = [
|
||||||
|
(mkPersistDir config "slurm" "/var/spool/slurmctld")
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue