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
|
|
@ -278,6 +278,7 @@ let
|
|||
# reaches this at 127.0.0.1:<port>.
|
||||
privateNetwork = false;
|
||||
storeRetry = import ./lib/store-retry.nix { };
|
||||
storeRefreshTimer = import ./lib/store-refresh-timer.nix { };
|
||||
in
|
||||
{
|
||||
# What the service IS to every hive is `swarm.grafana` in
|
||||
|
|
@ -576,8 +577,9 @@ in
|
|||
# Grafana (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-grafana-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
|
||||
|
|
@ -665,6 +667,8 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
systemd.timers.swarm-bao-grafana-oidc = storeRefreshTimer "re-read Grafana's OIDC client secret from the swarm secret store";
|
||||
|
||||
# The admin password: created in the store if it holds none, then copied
|
||||
# into the container, under Grafana's own leaf. Same shape as
|
||||
# `swarm-bao-nats-callout-xkey` in ./swarm-nats.nix. The grant is
|
||||
|
|
|
|||
Loading…
Reference in a new issue