fetch-secrets ran under umask 0227 for the files it writes, which made the
mktemp file of grafana_secret_key mode 0400: the redirect of bao's stderr
into it failed, every bao call in the helper answered 1, and the init
container exited 1 before it stored or read the key. The umask now covers
only the writes of put(), the helper chmods its own file, the script test runs
under that umask, and a pod that does not start prints its init containers'
logs.
Grafana wraps the data keys of its database with secret_key, and a different
key makes them undecryptable, which grafana cli's re-encrypt cannot repair
(it decrypts with the current key first). So the init container takes the
store's key, else the file the container generated, else a new key, and a new
key only over a database that holds no data_keys row; otherwise it exits
non-zero naming the leaf. The file reaches it read-only through a claim on a
static local volume, because the namespace refuses a hostPath.
The Deployment swarm-grafana replaces the swarm-grafana container: one
replica on a static local volume that is the container's data directory,
an init container that fetches the OIDC client secret and creates the
administrator password, the datasources' bearer and the encryption key in
the secret store, and a sidecar that keeps the controller's Viewer token.
The datasources reach the stores through the gateway with that bearer, and
Grafana's /metrics asks for the stores' kind of credential, which the vhost
sends. The five host units, the journal forwarder, its client glue and the
unix-socket directory go with the container.
A VM test script and `lib/k3s.py` share one namespace, so a step that assigns
`pod = ...` replaces the library's `pod()` for every later call and the test dies
mid-run with `TypeError: 'dict' object is not callable`. `ty` and
`ruff --select F` accept a module-level rebinding, so this cost a full VM round
on #6947.
`vm-test-shadow-scan.py` parses the script and fails when a name bound at module
level (assignment, `for` or `with` target, `import ... as`, walrus, `except ... as`)
is also a module-level `def`. It looks into `with`, `if`, `for`, `while` and `try`
bodies, where `with subtest(...)` steps live, and not into function or
comprehension bodies. Every `vm-test-typecheck-<name>` runs it on the script alone.
`vm-test-typecheck-shadow-control` passes only when it rejects each form of
rebinding and accepts the same names where they are local.
The one existing case, `sources` in `k8s-services`, is renamed `cred_sources`.
Closes#6951
`swarm-bao-store-auth` was a retrying oneshot on multi-user.target. A
oneshot's start job stays pending through its restarts, so a boot or a switch
with the secret store sealed waited on it for up to 15 minutes, the same
shape as #6901's CA publisher.
It is now `Type=simple` with the shared retry kept: the start job is done at
fork and the unit keeps trying until the store answers. `RemainAfterExit`
leaves it `active (exited)` once the credential is out, and the 15-minute
start timeout goes, as a start job done at fork has no use for it. Nothing
orders after the unit: the gateway reads the file at its next reload and the
pods wait in ContainerCreating for the Secret.
`is-active` is now true while the script runs and `systemctl restart` returns
at fork, so the k8s-services and k8s-nats tests wait for `SubState=exited` where they relied
on either.
Closes#6937
Each store runs with -httpAuth.* and a credential from the secret store, published to the namespace as a Secret by the host. The gateway's locations send it after auth_request has passed, and the collector's scrape and push take the same one, so a process on the node that bypasses the gateway is refused.
the grafana responder's service targeted the port name api, which resolves to the logs responder's container; its port is now grafana-api.
the node-ready wait is raised from 300 to 600 seconds: slow k3s image imports on this test's machine kept the node from registering in vm-nightly 8992 and 8997, so the test never reached the subtests this change fixes.
swarm-logs-auth and swarm-metrics-auth take --listen for a TCP address beside
--socket. The log store is a Deployment on a static local volume that is its
old container's data directory, behind a ClusterIP Service the gateway dials by
name. Its two auth_request responders are one unpinned pod with a jwt role.
The renderer gains a plain HTTP listener, a probe path, fsGroupChangePolicy,
and one policy for a pod with both a listener and egress.