swarm-archive: grant only once an archive is up; keep logins across a gap in placements
The archive host creates a ready marker in the store and swarm-controller writes no credentials before it exists, so a swarm without an archive, and a mixed-version swarm, leave every hive backup a logged no-op. A hive with no declaration no longer counts as placing nothing: its copies and its agents' user lines stay. The restic password is pinned by tests across a revoke, a re-placement and a move.
This commit is contained in:
parent
306aae0378
commit
91f36f39d2
2 changed files with 241 additions and 52 deletions
|
|
@ -5,7 +5,8 @@
|
|||
# same script against a stand-in `bao`.
|
||||
#
|
||||
# Needs `bao`, `jq`, `coreutils`, `gnugrep`, `btrfs-progs` on the unit's `path`
|
||||
# and the `BAO_*` client set. Every failure prints a line starting
|
||||
# and the `BAO_*` client set. A store that cannot be reached, or an agent whose
|
||||
# backup fails, prints a line starting
|
||||
# `archive backup failed`, which the swarm's alert reads, and ends the run with
|
||||
# a non-zero status once the other agents have been tried.
|
||||
{ lib }:
|
||||
|
|
@ -127,11 +128,10 @@ in
|
|||
fi
|
||||
done
|
||||
|
||||
# Agents here and not one of them granted: swarm-controller has not written
|
||||
# this hive's grants, which a controller without the archive never does.
|
||||
# No grant for any agent here: the swarm has no archive, or its controller
|
||||
# has not granted this hive yet. Neither is a failure of this hive.
|
||||
if [ "$candidates" -gt 0 ] && [ -z "$granted" ]; then
|
||||
echo "archive backup failed: swarm-controller has granted this hive no archive credentials ($candidates agents here)" >&2
|
||||
failed=1
|
||||
echo "swarm-controller has granted this hive no archive credentials ($candidates agents here); nothing to back up."
|
||||
fi
|
||||
exit "$failed"
|
||||
''
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ let
|
|||
|
||||
usersPrefix = "secret/swarm/services/archive/users";
|
||||
resticPrefix = "secret/swarm/services/archive/restic";
|
||||
readyPath = "secret/swarm/services/archive/ready";
|
||||
|
||||
keepFlags = lib.concatStringsSep " " (
|
||||
[ "--keep-last ${toString retention.keepLast}" ]
|
||||
|
|
@ -81,6 +82,12 @@ in
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Tells swarm-controller an archive exists; it grants no credentials until
|
||||
# then. Created once, never rewritten.
|
||||
if ! store_bao kv get -field=ready ${lib.escapeShellArg readyPath} >/dev/null 2>&1; then
|
||||
store_bao kv put -cas=0 ${lib.escapeShellArg readyPath} ready=1 >/dev/null
|
||||
fi
|
||||
|
||||
# A prefix that holds nothing is "No value found"; it means no agent has a
|
||||
# user yet, not a failure.
|
||||
rc=0
|
||||
|
|
|
|||
Loading…
Reference in a new issue