Watch
0
0
Fork
You've already forked hyperhive
0

archive: an empty prefix lists as no users, not as a failure

swarm-archive-users and hive-archive-backup read "No value found" on
stderr to tell a prefix that holds nothing from an error. With
`kv list -format=json`, bao answers such a prefix with status 2, `{}` on
stdout and nothing on stderr, so on a swarm whose archive has no users
yet the unit failed every 30 seconds forever, and every switch reported
it.

store_list, in the shared store helper, prints the names as a JSON array
and `[]` for a prefix that holds nothing: failed, empty stderr, stdout
`{}`. It is not decided on status 2 alone, which a refused token, a
sealed store and an unreachable store end with as well (their error is on
stderr). The two scripts use it. The script test runs it against a stub
that answers as bao does, with controls for a refusal, a sealed store and
a warning beside an empty answer, and the archive VM test's stub no
longer prints the table format's message for a JSON list. full-setup
waits for the users file to be rendered on a fresh swarm.

Closes #6840
This commit is contained in:
maia 2026-11-24 18:19:26 +01:00
commit df9cd8c7e6

View file

@ -15,6 +15,11 @@ let
# `FAKE_BAO_READ_TIMEOUT` is `timeout` ending the read: status 124, silent.
# `FAKE_BAO_READ_5XX` is a server error on the read. A leaf nobody wrote is
# "No value found at <path>", status 2, as `bao kv get` answers it.
# `kv list -format=json` answers `FAKE_BAO_LIST` (a JSON array) when it is
# set, and as bao answers a prefix that holds nothing when it is not: status
# 2, `{}`, nothing on stderr. `FAKE_BAO_LIST_DENY` and `FAKE_BAO_LIST_SEALED`
# are the errors, which end with status 2 as well but print on stderr, and
# `FAKE_BAO_LIST_NOISY` is an empty answer with a line on stderr.
# `FAKE_BAO_RACE` has another run create the leaf between this one's read and
# its write. `FAKE_BAO_READ_DELAY` holds each read that long and records, in
# `$FAKE_BAO_KV/.peak`, how many reads were in flight with it. Every call is
@ -47,6 +52,19 @@ let
[ -e "$leaf" ] || { echo "No value found at secret/data/x" >&2; exit 2; }
cat "$leaf"
;;
"kv list")
[ "''${BAO_TOKEN-}" = s.fake ] || { echo "fake bao: kv without the login's token" >&2; exit 97; }
[ "$3" = -format=json ] || { echo "fake bao: kv list without -format=json" >&2; exit 98; }
# As bao answers: a refusal and a sealed store end with status 2, the
# error on stderr and nothing on stdout.
[ -z "''${FAKE_BAO_LIST_DENY-}" ] || { printf 'Error listing %s: Code: 403. Errors:\n\n* 1 error occurred:\n\t* permission denied\n' "$4" >&2; exit 2; }
[ -z "''${FAKE_BAO_LIST_SEALED-}" ] || { echo "Error making API request. Code: 503. Errors: * Vault is sealed" >&2; exit 2; }
# An empty answer with something on stderr is not "nothing there".
[ -z "''${FAKE_BAO_LIST_NOISY-}" ] || { echo "fake bao: a warning" >&2; echo '{}'; exit 2; }
# A prefix that holds nothing: status 2, `{}`, nothing on stderr.
[ -n "''${FAKE_BAO_LIST-}" ] || { echo '{}'; exit 2; }
printf '%s\n' "$FAKE_BAO_LIST"
;;
"kv put")
[ "''${BAO_TOKEN-}" = s.fake ] || { echo "fake bao: kv without the login's token" >&2; exit 97; }
[ "$3" = -cas=0 ] || { echo "fake bao: put without -cas=0" >&2; exit 96; }