Watch
0
0
Fork
You've already forked hyperhive
0

k8s: the store-credential unit starts at fork, off the boot and switch path

`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
This commit is contained in:
maia 2026-11-27 21:53:05 +01:00
commit 6a50769269
2 changed files with 80 additions and 7 deletions

View file

@ -416,6 +416,17 @@ pkgs.testers.runNixOSTest {
raise
def store_credential_published() -> None:
# The unit is `Type=simple`: `is-active` is true while its script is still
# running and `systemctl restart` returns at fork, so `SubState=exited`
# is what says the files and the Secrets are out.
settle(
'[ "$(systemctl show --property=SubState --value swarm-bao-store-auth.service)" = exited ]',
900,
["swarm-bao-store-auth.service"],
)
def pods() -> list[str]:
return machine.succeed(f"kubectl -n {NS} get pods --selector app.kubernetes.io/name={SERVICE} -o name || true").split()
@ -849,7 +860,9 @@ pkgs.testers.runNixOSTest {
machine.succeed(f": > {EXPORTER_CONF} && systemctl reload metrics-gateway")
status, _ = gateway_until(401)
assert status == 401, status
machine.succeed("systemctl restart swarm-bao-store-auth.service && systemctl reload metrics-gateway")
machine.succeed("systemctl restart swarm-bao-store-auth.service")
store_credential_published()
machine.succeed("systemctl reload metrics-gateway")
assert gateway_until(200)[0] == 200
with subtest("a leaf that has to be issued again is issued beside the running server, which reloads it for new connections"):

View file

@ -649,6 +649,17 @@ pkgs.testers.runNixOSTest {
raise
def store_credential_published() -> None:
# The unit is `Type=simple`: `is-active` is true while its script is still
# running and `systemctl restart` returns at fork, so `SubState=exited`
# is what says the files and the Secrets are out.
settle(
'[ "$(systemctl show --property=SubState --value swarm-bao-store-auth.service)" = exited ]',
900,
["swarm-bao-store-auth.service"],
)
def service_pods(service: str) -> list[str]:
out = machine.succeed(f"kubectl -n {NS} get pods --selector app.kubernetes.io/name={service} -o name || true")
return out.split()
@ -959,7 +970,7 @@ pkgs.testers.runNixOSTest {
machine.succeed(f"test -L {MANIFESTS}/{name}.yaml")
# The pod waits for the Secret the unit publishes; the gateway reads its
# include file as it reloads.
settle('[ "$(systemctl is-active swarm-bao-store-auth.service)" = active ]', 900, ["swarm-bao-store-auth.service"])
store_credential_published()
machine.succeed("systemctl reload logs-gateway")
vl_pod = wait_pod_ready(VL)
auth_pod = wait_pod_ready(LOGS_AUTH)
@ -1137,7 +1148,9 @@ pkgs.testers.runNixOSTest {
assert status == 401, (status, body[:200])
# The unit writes the file again, and the same request is granted: the
# control that the 401 is the missing credential.
machine.succeed("systemctl restart swarm-bao-store-auth.service && systemctl reload logs-gateway")
machine.succeed("systemctl restart swarm-bao-store-auth.service")
store_credential_published()
machine.succeed("systemctl reload logs-gateway")
assert machine.succeed(f"cat {STORE_CONF}") == saved
wait_for_record(AGENT_TOKEN, "switch", "written before the switch")
@ -1521,7 +1534,9 @@ pkgs.testers.runNixOSTest {
break
time.sleep(1)
assert status == 401, (status, body[:200])
machine.succeed("systemctl restart swarm-bao-store-auth.service && systemctl reload logs-gateway")
machine.succeed("systemctl restart swarm-bao-store-auth.service")
store_credential_published()
machine.succeed("systemctl reload logs-gateway")
assert machine.succeed(f"cat {VM_CONF}") == saved
wait_for_series(AGENT_TOKEN, "written_before_the_switch")