diff --git a/docs/4-implementation/k8s/runtime.md b/docs/4-implementation/k8s/runtime.md index 629205e16..2d9b534d9 100644 --- a/docs/4-implementation/k8s/runtime.md +++ b/docs/4-implementation/k8s/runtime.md @@ -93,7 +93,12 @@ have the units. To leave the cluster, switch to an older generation. All are public certificates. The unit waits for the cluster and for the files, and a pod that mounts the ConfigMap waits in `ContainerCreating` until - the unit has run. A path unit watches both files and runs the unit again when + the unit has run. The unit is `Type=simple`, so it doesn't hold + `multi-user.target` while it waits: the store's and the hive's CA files come + from the [setup](../../1-getting-started/setup.md), which runs after the host + has booted. The kubelet retries a failed volume mount with a backoff of up to + two minutes, so a pod that was waiting starts up to two minutes after the unit + has published. A path unit watches both files and runs the unit again when either changes, with no manual step. A running pod doesn't see a changed trust bundle until it restarts, because the kubelet doesn't update `subPath` mounts. diff --git a/nix/host-modules/k8s/runtime.nix b/nix/host-modules/k8s/runtime.nix index eff92402c..4c9c2840d 100644 --- a/nix/host-modules/k8s/runtime.nix +++ b/nix/host-modules/k8s/runtime.nix @@ -70,6 +70,10 @@ in # A pod waits in ContainerCreating until this has run. The unit has no # `RemainAfterExit`, so the path unit below starts it again whenever a # file changes. + # + # `Type = "simple"`: the start job is done once the script has forked, so + # the unit never holds `multi-user.target`. The CA files come from the + # setup, which runs after boot, and the script waits for them. (lib.mkIf (onCluster != [ ] && caFiles != { }) { systemd.services.hyperhive-k8s-ca-trust = { description = "publish the hive's CA files to the cluster's pods"; @@ -80,7 +84,7 @@ in "swarm-bao-pki.service" ]; serviceConfig = { - Type = "oneshot"; + Type = "simple"; Restart = "on-failure"; RestartSec = "10s"; SyslogIdentifier = "hyperhive-k8s-ca-trust"; diff --git a/nix/module-eval/k8s.nix b/nix/module-eval/k8s.nix index c4b93671a..8410089e4 100644 --- a/nix/module-eval/k8s.nix +++ b/nix/module-eval/k8s.nix @@ -892,6 +892,9 @@ let && hasInfix "--from-file=swarm-services-root.pem=" caUnit.script && hasInfix "--from-file=trust-bundle.pem=" caUnit.script && lib.elem "multi-user.target" caUnit.wantedBy + # Not a oneshot: its start job would last until the script ends, and the + # script waits for files the setup writes after boot. + && caUnit.serviceConfig.Type == "simple" # A change to either file publishes again with no manual step, and the # host without the node has no path unit. &&