Watch
0
0
Fork
You've already forked hyperhive
0

archive: read the repository without its lock for the prune metrics

This commit is contained in:
atlas 2026-11-14 11:40:20 +01:00
commit c4919c5945
2 changed files with 5 additions and 3 deletions

View file

@ -255,7 +255,7 @@ in
"hyperhive.archive.prune.last_run_success=$ok" "hyperhive.archive.prune.last_run_success=$ok"
"hyperhive.archive.prune.last_run_timestamp_seconds=$(date +%s)" "hyperhive.archive.prune.last_run_timestamp_seconds=$(date +%s)"
) )
if snaps="$(${restic}/bin/restic -r "$repo" --retry-lock 10m snapshots --json 2>/dev/null)" \ if snaps="$(${restic}/bin/restic -r "$repo" --no-lock snapshots --json 2>/dev/null)" \
&& count="$(jq 'length' <<<"$snaps" 2>/dev/null)"; then && count="$(jq 'length' <<<"$snaps" 2>/dev/null)"; then
metrics+=("hyperhive.archive.repo.snapshots=$count") metrics+=("hyperhive.archive.repo.snapshots=$count")
while read -r time; do while read -r time; do
@ -267,7 +267,7 @@ in
metrics+=("hyperhive.archive.repo.latest_snapshot_timestamp_seconds=$latest") metrics+=("hyperhive.archive.repo.latest_snapshot_timestamp_seconds=$latest")
fi fi
fi fi
if stats="$(${restic}/bin/restic -r "$repo" --retry-lock 10m stats --mode raw-data --json 2>/dev/null)" \ if stats="$(${restic}/bin/restic -r "$repo" --no-lock stats --mode raw-data --json 2>/dev/null)" \
&& stats="$(jq -r '.total_size' <<<"$stats" 2>/dev/null)"; then && stats="$(jq -r '.total_size' <<<"$stats" 2>/dev/null)"; then
metrics+=("hyperhive.archive.repo.size_bytes=$stats") metrics+=("hyperhive.archive.repo.size_bytes=$stats")
fi fi

View file

@ -9,7 +9,9 @@
let let
fakeRestic = pkgs.writeShellScriptBin "restic" '' fakeRestic = pkgs.writeShellScriptBin "restic" ''
# Answers from the files named by FAKE_SNAPSHOTS and FAKE_STATS; an unset # Answers from the files named by FAKE_SNAPSHOTS and FAKE_STATS; an unset
# variable makes that subcommand fail. # variable makes that subcommand fail, and so does a call without --no-lock:
# the metrics only read, and must not wait on a lock.
case " $* " in *" --no-lock "*) ;; *) exit 1 ;; esac
case " $* " in case " $* " in
*" snapshots "*) [ -n "''${FAKE_SNAPSHOTS:-}" ] && cat "$FAKE_SNAPSHOTS" ;; *" snapshots "*) [ -n "''${FAKE_SNAPSHOTS:-}" ] && cat "$FAKE_SNAPSHOTS" ;;
*" stats "*) [ -n "''${FAKE_STATS:-}" ] && cat "$FAKE_STATS" ;; *" stats "*) [ -n "''${FAKE_STATS:-}" ] && cat "$FAKE_STATS" ;;