granter role unit: no-op when the granter login works, delete the token after success
This commit is contained in:
parent
0c6e8fc5a2
commit
3db835fb57
1 changed files with 42 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue