diff options
author | Florian Klink <flokli@flokli.de> | 2019-11-09 16:05:58 +0100 |
---|---|---|
committer | Florian Klink <flokli@flokli.de> | 2019-11-09 16:13:13 +0100 |
commit | ffd006086945924511114fa1f5478665870da3af (patch) | |
tree | 0f7e1186d954290d93e9a9f516a94fcdc96a1bc3 /nixos/modules | |
parent | 67e0777f6258ded0029bbfeec65fbedf36d6d4c8 (diff) | |
download | nixlib-ffd006086945924511114fa1f5478665870da3af.tar nixlib-ffd006086945924511114fa1f5478665870da3af.tar.gz nixlib-ffd006086945924511114fa1f5478665870da3af.tar.bz2 nixlib-ffd006086945924511114fa1f5478665870da3af.tar.lz nixlib-ffd006086945924511114fa1f5478665870da3af.tar.xz nixlib-ffd006086945924511114fa1f5478665870da3af.tar.zst nixlib-ffd006086945924511114fa1f5478665870da3af.zip |
nixos/ceph: use ConditionPathExists to delay ceph daemon start
This prevents services to be started before they're initialized, and renders the `systemd.targets.ceph.wantedBy = lib.mkForce [];` hack in the vm tests obsolete - The config now starts up ceph after a reboot, too. Let's take advantage of that, crash all VMs, and boot them up again.
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/services/network-filesystems/ceph.nix | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/nixos/modules/services/network-filesystems/ceph.nix b/nixos/modules/services/network-filesystems/ceph.nix index ef0d2d90a1a1..543a7b25d5d6 100644 --- a/nixos/modules/services/network-filesystems/ceph.nix +++ b/nixos/modules/services/network-filesystems/ceph.nix @@ -14,7 +14,9 @@ let { "ceph-${daemonType}-${daemonId}" = makeService daemonType daemonId cfg.global.clusterName pkgs.ceph; }) daemonIds)); - makeService = (daemonType: daemonId: clusterName: ceph: { + makeService = (daemonType: daemonId: clusterName: ceph: + let + stateDirectory = "ceph/${if daemonType == "rgw" then "radosgw" else daemonType}/${clusterName}-${daemonId}"; in { enable = true; description = "Ceph ${builtins.replaceStrings lowerChars upperChars daemonType} daemon ${daemonId}"; after = [ "network-online.target" "time-sync.target" ] ++ optional (daemonType == "osd") "ceph-mon.target"; @@ -24,6 +26,9 @@ let path = [ pkgs.getopt ]; + # Don't start services that are not yet initialized + unitConfig.ConditionPathExists = "/var/lib/${stateDirectory}/keyring"; + serviceConfig = { LimitNOFILE = 1048576; LimitNPROC = 1048576; @@ -36,7 +41,7 @@ let Restart = "on-failure"; StartLimitBurst = "5"; StartLimitInterval = "30min"; - StateDirectory = "ceph/${if daemonType == "rgw" then "radosgw" else daemonType}/${clusterName}-${daemonId}"; + StateDirectory = stateDirectory; User = "ceph"; Group = if daemonType == "osd" then "disk" else "ceph"; ExecStart = ''${ceph.out}/bin/${if daemonType == "rgw" then "radosgw" else "ceph-${daemonType}"} \ @@ -60,6 +65,7 @@ let partOf = [ "ceph.target" ]; wantedBy = [ "ceph.target" ]; before = [ "ceph.target" ]; + unitConfig.StopWhenUnneeded = true; }; } ); @@ -389,9 +395,12 @@ in systemd.targets = let targets = [ - { ceph = { description = "Ceph target allowing to start/stop all ceph service instances at once"; - wantedBy = [ "multi-user.target" ]; }; } - ] ++ optional cfg.mon.enable (makeTarget "mon") + { ceph = { + description = "Ceph target allowing to start/stop all ceph service instances at once"; + wantedBy = [ "multi-user.target" ]; + unitConfig.StopWhenUnneeded = true; + }; } ] + ++ optional cfg.mon.enable (makeTarget "mon") ++ optional cfg.mds.enable (makeTarget "mds") ++ optional cfg.osd.enable (makeTarget "osd") ++ optional cfg.rgw.enable (makeTarget "rgw") |