nix: re-run the host's store fetches on a ten-minute timer
Seven host oneshots fetch a secret from the swarm secret store into a file their consumer loads at start: swarm-bao-grafana-oidc, swarm-bao-otel-oidc, swarm-bao-matrix-oidc, swarm-bao-ci-runner, swarm-bao-forge-oidc, swarm-bao-hive-otel-oidc and swarm-bao-forwarder-oidc. Each was RemainAfterExit with no timer, so it ran at boot or deploy and never again: a secret re-minted in the store reached its consumer only through an operator restarting the fetch. lib/store-refresh-timer.nix gives each one a timer (OnUnitInactiveSec 10min, RandomizedDelaySec 1min, the agent's own store re-read interval), and each drops RemainAfterExit so a timer start is not a no-op. Each script already writes the file only when secret_differs, and refresh_consumer/refresh_unit restart the consumer only when the file is newer than its last start, so a run reading an unchanged value restarts nothing. Two docs said these units do not run on a timer; credentials.md's ci-runner row said the runner token is not re-pulled. Part of #5017 (slice T).
This commit is contained in:
parent
c2dc18413b
commit
2f05e2db28
12 changed files with 146 additions and 13 deletions
|
|
@ -303,6 +303,7 @@ let
|
|||
# its own trust material.
|
||||
privateNetwork = false;
|
||||
storeRetry = import ./lib/store-retry.nix { };
|
||||
storeRefreshTimer = import ./lib/store-refresh-timer.nix { };
|
||||
in
|
||||
{
|
||||
# What the collector IS to the swarm — the client it is registered as, where
|
||||
|
|
@ -453,8 +454,9 @@ in
|
|||
# the collector (below).
|
||||
inherit (storeRetry) startLimitBurst startLimitIntervalSec;
|
||||
serviceConfig = storeRetry.serviceConfig // {
|
||||
# No `RemainAfterExit`: the timer below starts this again, and
|
||||
# starting an active unit is a no-op.
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
SyslogIdentifier = "swarm-bao-otel-oidc";
|
||||
# What actually bounds each attempt below. Stated here rather than left
|
||||
# to systemd's default, so the number a boot waits on is in the file
|
||||
|
|
@ -532,6 +534,10 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
systemd.timers.swarm-bao-otel-oidc = lib.mkIf haveClientIdentity (
|
||||
storeRefreshTimer "re-read the swarm collector's OIDC client secret from the swarm secret store"
|
||||
);
|
||||
|
||||
# Where the delivery unit above lands the secret. `mkDefault`, so a
|
||||
# deployment delivering it some other way just sets the option — and
|
||||
# `mkIf haveClientIdentity` so a host with no store identity is left with
|
||||
|
|
|
|||
Loading…
Reference in a new issue