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

@ -8,6 +8,9 @@
# race reads the winner's back. A read of the leaf that fails for any reason
# but "No value found" prints the store's error and neither mints nor writes.
#
# `store_list` lists a prefix and answers `[]` for one that holds nothing; see
# it for why that is not the "No value found" of a table-format list.
#
# `store_prefetch` reads many leaves concurrently, and the first `store_read` of
# a leaf returns that answer, status and error included, instead of asking
# again, so what a caller decides from a read is the same. Later reads of the
@ -54,6 +57,29 @@
fi
}
# <prefix> Prints the names under the prefix as bao's JSON array, `[]` for a
# prefix that holds nothing, and returns 0. Any other answer prints the
# store's error on stderr and returns 1.
#
# ⚠️ With `-format=json`, bao answers a prefix that holds nothing with status
# 2, `{}` on stdout and NOTHING on stderr. The "No value found" message
# belongs to the table format, so a grep for it never matches here. And status
# 2 alone is no answer: a refused token, a sealed store and a store that is not
# there end with status 2 too, with their error on stderr and nothing on
# stdout. So "nothing there" is exactly: failed, empty stderr, stdout `{}`.
store_list() {
local out rc=0
out="$(store_bao kv list -format=json "$1" 2>"$STORE_ERR")" || rc=$?
if [ "$rc" = 0 ]; then
printf '%s\n' "$out"
elif [ ! -s "$STORE_ERR" ] && [ "$(printf '%s' "$out" | tr -d '[:space:]')" = '{}' ]; then
echo '[]'
else
cat "$STORE_ERR" >&2
return 1
fi
}
# <leaf>… Starts the first read of each leaf now, at most STORE_PREFETCH_JOBS
# at a time, and returns when all have ended. Each read is bounded by
# `store_bao`, and its answer is kept for `store_read`. Does nothing without