Watch
0
0
Fork
You've already forked hyperhive
0

swarm-otel, swarm-grafana: a delivery unit fails on no value yet

The collector's and Grafana's OIDC delivery units exited 0 when the store
held no value, so systemd did not retry them. On a fresh swarm authelia's
mint writes the secret about 30 s after the first read, and only the
refresh timer, ten minutes on, read it again. Both units now exit 75, and
the store retry they already carry asks every 30 s until the mint lands.

Closes #6790
This commit is contained in:
maia 2026-11-23 12:43:37 +01:00
commit dad288d555

View file

@ -749,21 +749,21 @@ in
#
# It is a store reader, and this is what the store's readers do: a cert
# login that fails LOUDLY, since every state it fails on is one a retry
# fixes, then a read that degrades QUIETLY, since no retry turns "no value
# there" into a value.
# fixes, then a read that fails the same way when the value is not there
# yet.
#
# ⚠️ An ABSENT secret is "not published yet", not a fault of this host's.
# The mint runs in authelia's container and authelia mints on its
# first boot, so early in a swarm's life there is legitimately nothing to
# read.
# read, and a retry finds it a moment later. A unit that exited 0 on it
# would not run again until the refresh timer, about ten minutes on.
# Nothing here writes a stand-in: there is no such thing as a locally valid
# OIDC client secret, and a placeholder would turn a Grafana that cannot
# log anyone in into one whose token exchange is refused.
#
# ⇒ So the absence surfaces at Grafana rather than here, and this unit's job
# is to leave the journal line that says which of the three it was: the
# secret not arriving is a Grafana nobody can log into, and a named cause is
# the only thing separating that from a mystery.
# ⇒ So the unit fails, and leaves the journal line that says which of the
# three it was: a secret that does not arrive is a Grafana nobody can log
# into, and a named cause is the only thing separating that from a mystery.
systemd.services.swarm-bao-grafana-oidc = {
description = "fetch Grafana's OIDC client secret from the swarm secret store";
# Ordered after the store where it runs here
@ -812,9 +812,9 @@ in
${ensureSecretDir}
# `bao`'s own message is the only thing separating a missing value from
# a refused identity from an unreachable host. This unit's degraded
# mode is correct for all three, so it reports which one rather than
# asserting all three in a sentence of ours.
# a refused identity from an unreachable host. Retrying is right for
# all three, so this unit reports which one rather than asserting all
# three in a sentence of ours.
err="$(mktemp)"
trap 'rm -f "$err"' EXIT
@ -834,6 +834,9 @@ in
fi
export BAO_TOKEN
# 75 is EX_TEMPFAIL: not there yet, ask again. `Restart=on-failure`
# (./lib/store-retry.nix) asks every 30 s until the mint has written it,
# and the status line says "no value" rather than "no login" (1).
if ! secret="$(bao kv get -field=value ${lib.escapeShellArg storeSecretPath} 2>"$err")"; then
echo "swarm-bao did not return ${storeSecretPath}; Grafana has no OIDC client secret yet." >&2
if [ -s "$err" ]; then
@ -841,12 +844,12 @@ in
else
echo "bao failed without writing a diagnostic." >&2
fi
exit 0
exit 75
fi
if [ -z "$secret" ]; then
echo "swarm-bao returned an empty ${storeSecretPath}; leaving the file as it is." >&2
exit 0
exit 75
fi
# Written with a shell builtin, never handed to a program: `printf` is