hub v0.161.0: passphrase keys only until the box uses its own (box-config route; R-1159, D19); ep0 namespaces without a prune job alarmed, tenantsync v1.3.0 creates the job (R-1165)
gates / gates (push) Successful in 7m47s
gates / gates (push) Successful in 7m47s
This commit is contained in:
1 parent
224fe41e06
commit
b6a911c3f9
16 files changed
+802
-35
No files matched your search
@@ -1,7 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# felhom-tenantsync v1.2.0 — the offsite endpoint's per-customer PBS tenancy surface (PBS DR tier
|
||||
# felhom-tenantsync v1.3.0 — the offsite endpoint's per-customer PBS tenancy surface (PBS DR tier
|
||||
# SLICE 1; spike SPIKE-pbs-tier-provisioning-2026-07-10 §3).
|
||||
#
|
||||
# v1.3.0 (2026-10-19, R-1165): a household's namespace gets its PRUNE JOB with it. provision/reissue ensure
|
||||
# `prune-<id>` (keep-weekly 2, 03:30, ns-scoped, max-depth 0 — the shape of the demo-hp/demo-felhom jobs, STATUS
|
||||
# D18) unless a job on felhom-offsite already covers that namespace (idempotent: a second run changes nothing);
|
||||
# a failed create is logged and never fails the provision (the hub's alarm below names the namespace). deprovision
|
||||
# removes the namespace's jobs before the namespace. `usage` adds `unpruned` — the top-level namespaces no job
|
||||
# covers (read-only: the namespace folders + `prune-job list`), or `unpruned_checked:false` when the list cannot be
|
||||
# read. Box tokens stay write-only: pruning is server-side, so a namespace without a job grows for ever.
|
||||
# Pinned by scripts/tenantsync-prune-harness.sh.
|
||||
#
|
||||
# v1.2.0 (2026-07-17, hub R-5 PBS visibility): + read-only `usage` op — the felhom-offsite datastore's
|
||||
# total/used/avail (bytes, via `df` on the datastore path). No customer_id, no admin token, NO
|
||||
# mutation. Structural twin of `fingerprint`. Backward-compatible: an older hub never sends it, and a
|
||||
@@ -28,7 +37,8 @@
|
||||
# This is the DELIBERATE, gated data-destruction the slice-1 note reserved — the operator RESET
|
||||
# confirm (typed customer-id + separate escrow-custody ack) is the human decision it demanded.
|
||||
# {"op":"fingerprint"} → {"status":"ok","fingerprint":"<PBS cert sha256>"}
|
||||
# {"op":"usage"} → {"status":"ok","total":<bytes>,"used":<bytes>,"avail":<bytes>}
|
||||
# {"op":"usage"} → {"status":"ok","total":<bytes>,"used":<bytes>,"avail":<bytes>,
|
||||
# "unpruned":[<ns>…],"unpruned_checked":true}
|
||||
# READ-ONLY datastore fill (df on the felhom-offsite path). No customer_id, no admin token, no mutation.
|
||||
#
|
||||
# Secret hygiene (load-bearing):
|
||||
@@ -85,7 +95,21 @@ if [ "$OP" = "usage" ]; then
|
||||
# df -B1: 1-byte blocks. --output pins the columns; tail -1 skips the header row.
|
||||
read -r TOTAL USED AVAIL < <(df -B1 --output=size,used,avail "$DS_PATH" | tail -1)
|
||||
[ -n "$TOTAL" ] && [ -n "$USED" ] && [ -n "$AVAIL" ] || err_json internal "could not read datastore usage"
|
||||
printf '{"status":"ok","total":%s,"used":%s,"avail":%s}\n' "$TOTAL" "$USED" "$AVAIL"
|
||||
# v1.3.0 (R-1165): the top-level namespaces no prune job covers. A job covers a namespace when it names it, or when
|
||||
# it sits on the root (no ns) without a max-depth of 0. Read-only; a list that cannot be read says so.
|
||||
NSES='[]'
|
||||
if [ -d "$DS_PATH/ns" ]; then
|
||||
NSES=$(find "$DS_PATH/ns" -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | jq -R . | jq -cs .)
|
||||
fi
|
||||
if JOBS=$(proxmox-backup-manager prune-job list --output-format json 2>/dev/null) && jq -e 'type == "array"' >/dev/null 2>&1 <<<"$JOBS"; then
|
||||
jq -cn --argjson t "$TOTAL" --argjson u "$USED" --argjson a "$AVAIL" --argjson ns "$NSES" --argjson jobs "$JOBS" --arg ds "$DS" '
|
||||
($jobs | map(select(.store == $ds))) as $j
|
||||
| ($j | any(((.ns // "") == "") and ((."max-depth" // 7) > 0))) as $root
|
||||
| {"status":"ok","total":$t,"used":$u,"avail":$a,"unpruned_checked":true,
|
||||
"unpruned": (if $root then [] else [$ns[] as $n | select(($j | any((.ns // "") == $n)) | not) | $n] | sort end)}'
|
||||
else
|
||||
printf '{"status":"ok","total":%s,"used":%s,"avail":%s,"unpruned_checked":false}\n' "$TOTAL" "$USED" "$AVAIL"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -126,6 +150,11 @@ if [ "$OP" = "deprovision" ]; then
|
||||
# residual namespace ACLs (belt-and-suspenders — the user grant is not token-scoped).
|
||||
proxmox-backup-manager acl update "/datastore/$DS/$CID" DatastoreBackup --auth-id "$PBS_USER" --delete >&2 2>/dev/null || true
|
||||
proxmox-backup-manager acl update "/datastore/$DS/$CID" DatastoreBackup --auth-id "$TOKEN_ID" --delete >&2 2>/dev/null || true
|
||||
# v1.3.0 (R-1165): the namespace's prune job(s) go first — a job left on a deleted namespace fails every night.
|
||||
for job in $(proxmox-backup-manager prune-job list --output-format json 2>/dev/null \
|
||||
| jq -r --arg ns "$CID" --arg ds "$DS" '.[] | select(.store == $ds and (.ns // "") == $ns) | .id'); do
|
||||
proxmox-backup-manager prune-job remove "$job" >&2 && log "deprovision: prune job $job removed"
|
||||
done
|
||||
ns_existed=false
|
||||
if PBS_PASSWORD="$ADM" proxmox-backup-client namespace list --repository "$ADMIN_REPO" \
|
||||
--output-format json | jq -e --arg ns "$CID" '(.data // .) | any(.[]; .ns == $ns)' >/dev/null; then
|
||||
@@ -155,6 +184,23 @@ if ! PBS_PASSWORD="$ADM" proxmox-backup-client namespace list --repository "$ADM
|
||||
log "created namespace $CID"
|
||||
fi
|
||||
|
||||
# 3b. v1.3.0 (R-1165): the namespace's prune job — keep-weekly 2 at 03:30, the D18 shape. Idempotent: any job on this
|
||||
# datastore that already names the namespace counts (whatever its id). A PBS job id is at most 32 characters, so a
|
||||
# long customer id gets a shortened, hashed one. A failure is logged, never fatal (the hub's usage alarm names it).
|
||||
JOB_ID="prune-$CID"
|
||||
if [ "${#JOB_ID}" -gt 32 ]; then
|
||||
JOB_ID="prune-${CID:0:20}-$(printf '%s' "$CID" | sha256sum | cut -c1-5)"
|
||||
fi
|
||||
if proxmox-backup-manager prune-job list --output-format json \
|
||||
| jq -e --arg ns "$CID" --arg ds "$DS" 'any(.[]; .store == $ds and (.ns // "") == $ns)' >/dev/null; then
|
||||
log "prune job for namespace $CID already present"
|
||||
elif proxmox-backup-manager prune-job create "$JOB_ID" --store "$DS" --ns "$CID" --max-depth 0 --keep-weekly 2 \
|
||||
--schedule 03:30 --comment "R-1165: one copy per ISO week, 2 weeks, server-side (box tokens are write-only)" >&2; then
|
||||
log "created prune job $JOB_ID (keep-weekly 2, 03:30) for namespace $CID"
|
||||
else
|
||||
log "WARNING: could not create prune job $JOB_ID for namespace $CID — its copies are not pruned until one exists"
|
||||
fi
|
||||
|
||||
token_exists() {
|
||||
proxmox-backup-manager user list-tokens "$PBS_USER" --output-format json \
|
||||
| jq -e --arg t "$TOKEN_ID" 'any(.[]; .tokenid == $t)' >/dev/null
|
||||
|
||||
Reference in new issue
Block a user