Watch
0
0
Fork
You've already forked hyperhive
0

fetch the secrets unit's store leaves concurrently and log how long each phase takes

This commit is contained in:
atlas 2026-11-04 17:04:35 +01:00
commit 197caa1e52

View file

@ -16,7 +16,9 @@ let
# `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.
# `FAKE_BAO_RACE` has another run create the leaf between this one's read and
# its write. Every call is logged without the value `put` reads from stdin.
# 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
# logged without the value `put` reads from stdin.
fakeBao = pkgs.writeShellScriptBin "bao" ''
echo "$*" >> "$FAKE_BAO_LOG"
case "$1 $2" in
@ -28,6 +30,12 @@ let
[ "''${BAO_TOKEN-}" = s.fake ] || { echo "fake bao: kv without the login's token" >&2; exit 97; }
leaf="$FAKE_BAO_KV/$(printf '%s' "$4" | tr / _)"
[ -z "''${FAKE_BAO_READ_TIMEOUT-}" ] || exit 124
if [ -n "''${FAKE_BAO_READ_DELAY-}" ]; then
touch "$FAKE_BAO_KV/.inflight.$$"
ls "$FAKE_BAO_KV"/.inflight.* | wc -l >> "$FAKE_BAO_KV/.peak"
sleep "$FAKE_BAO_READ_DELAY"
rm -f "$FAKE_BAO_KV/.inflight.$$"
fi
[ -z "''${FAKE_BAO_READ_5XX-}" ] || { echo "Error reading secret/data/x: Error making API request. Code: 503. Errors: * Vault is sealed" >&2; exit 2; }
[ -z "''${FAKE_BAO_DENY_READ-}" ] || { echo "fake bao: permission denied" >&2; exit 2; }
if [ -n "''${FAKE_BAO_RACE-}" ] && [ ! -e "$FAKE_BAO_KV/.raced" ]; then