Watch
0
0
Fork
You've already forked hyperhive
0

granter role unit: no-op when the granter login works, delete the token after success

This commit is contained in:
atlas 2026-10-26 18:41:38 +01:00 • committed by mara
commit 3db835fb57

View file

@ -1112,6 +1112,28 @@ let
[ "swarm-bao-granter-role" ] ++ grantingUnitNames
);
}
{
# A dead token beside a working granter exits 0; one with no working
# granter still reaches exit 4; a successful run removes the token file.
# Presence controls: the controller's unit has neither the no-op line
# nor the delete.
name = "the granter's unit no-ops on a working granter login, still exits 4 without one, and deletes the token";
ok =
let
g = baoGrantHere.systemd.services.swarm-bao-granter-role.script;
other = baoGrantHere.systemd.services.swarm-bao-controller-policy.script;
noop = "granter role already in place; bootstrap token not needed";
del = "rm -f /run/secrets/bao-bootstrap.token";
before = lib.head (lib.splitString "refused the bootstrap token" g);
in
lib.hasInfix noop before
&& lib.hasInfix "bao login -method=cert -token-only" before
&& lib.hasInfix "BAO_CLIENT_CERT=" before
&& lib.hasInfix del g
&& lib.hasInfix "exit 4" g
&& !(lib.hasInfix noop other)
&& !(lib.hasInfix del other);
}
{
# Every granting unit retries a sealed or late store for a day, in the
# `[Unit]` section systemd reads it from, and waits for the unit that