fix(supabase): db:trial second re-review fixes
Post-create scan covers pg_stat_statements and labels each count; log path defined; rotate-secrets 401 window documented; plan shows image state unknown without a daemon; start_containers checks the app host before recreating GoTrue; truthful restore and destroy way-out messages; harness checks read stdin from /dev/null. Harness 372/0.
This commit is contained in:
1 parent
d3bdbbe0ba
commit
f2cbf6814f
4 files changed
+121
-22
No files matched your search
+25
-6
@@ -285,9 +285,14 @@ absent_answer() { # kind name: the daemon's wording, which differs by kind
|
||||
image) printf 'Error response from daemon: No such image: %s' "$2" ;;
|
||||
esac
|
||||
}
|
||||
refuse_inspect() { # kind name reason [extra hint]: the reason alone, for a path where Docker gave no sentence to quote
|
||||
die "docker $1 inspect $2 $3: refused; check that the Docker daemon answers (docker info)${4:+, $4}"
|
||||
}
|
||||
# The absent sentences above were measured on Docker 29.9.3: a Docker that rewords them lands here.
|
||||
inspect_refused() { # kind name what answer: Docker's answer shown quoted, cut at 200 characters
|
||||
local shown="${4:0:200}"
|
||||
die "docker $1 inspect $2 $3 (answer ${shown@Q}), not the daemon's own 'absent' sentence: refused; check that the Docker daemon answers (docker info)"
|
||||
refuse_inspect "$1" "$2" "$3 (answer ${shown@Q}), not the daemon's own 'absent' sentence" \
|
||||
"or that Docker's absent wording did not change (absent_answer, measured on Docker 29.9.3)"
|
||||
}
|
||||
resource_exists() { # kind name: 0 exists, 1 absent, else die
|
||||
local err status=0 field='{{.Name}}'
|
||||
@@ -302,12 +307,12 @@ container_running() { # 0 running, 1 stopped or absent, else die: an error is ne
|
||||
local out status=0
|
||||
container_exists "$1" || return 1
|
||||
out="$(docker container inspect -f '{{.State.Running}}' "$1" 2>/dev/null)" || status=$?
|
||||
[ "$status" -eq 0 ] || inspect_refused container "$1" "failed (exit $status) after it was found" "no answer kept"
|
||||
[ "$status" -eq 0 ] || refuse_inspect container "$1" "failed (exit $status) after it was found"
|
||||
case "$out" in
|
||||
true) return 0 ;;
|
||||
false) return 1 ;;
|
||||
esac
|
||||
inspect_refused container "$1" "returned an unexpected value" "$out"
|
||||
refuse_inspect container "$1" "returned the unexpected value ${out:0:200}"
|
||||
}
|
||||
volume_exists() { resource_exists volume "$1"; }
|
||||
network_exists() { resource_exists network "$1"; }
|
||||
@@ -579,6 +584,8 @@ start_containers() {
|
||||
done
|
||||
ports_free "${todo[@]}"
|
||||
if [ "$missing" = yes ]; then write_env_files; ensure_network; fi
|
||||
# GoTrue's recreation reads the app host: a refusal must come before the first container starts.
|
||||
if ! container_exists "$AUTH"; then trial_host >/dev/null; fi
|
||||
for name in "${todo[@]}"; do
|
||||
if container_exists "$name"; then
|
||||
docker start "$name" >/dev/null
|
||||
@@ -826,7 +833,9 @@ plan_images() {
|
||||
local image where
|
||||
echo "Images:"
|
||||
for image in "$IMAGE_DB" "$IMAGE_AUTH" "$IMAGE_REST" "$IMAGE_STORAGE" "$IMAGE_MAIL" "$IMAGE_GATEWAY"; do
|
||||
if docker image inspect -f '{{.Id}}' "$image" >/dev/null 2>&1; then where=present; else where='not pulled yet (create pulls it)'; fi
|
||||
if [ "$PLAN_DAEMON" = no ]; then where='unknown (Docker daemon unreachable)'
|
||||
elif docker image inspect -f '{{.Id}}' "$image" >/dev/null 2>&1; then where=present
|
||||
else where='not pulled yet (create pulls it)'; fi
|
||||
printf ' %-46s %s\n' "$image" "$where"
|
||||
done
|
||||
}
|
||||
@@ -1119,11 +1128,14 @@ new_backup_dir() { # label → a fresh folder (700)
|
||||
( umask 077; mkdir -p "$BACKUPS"; mkdir "$dir" ) || die "cannot create $dir"
|
||||
printf '%s' "$dir"
|
||||
}
|
||||
restore_extracted_note() { # volume that failed: what the extraction loop had done before it
|
||||
if [ "$1" = "$VOL_DB" ]; then echo "nothing was extracted"; else echo "$VOL_DB was extracted, $1 was not"; fi
|
||||
}
|
||||
# `docker volume create` succeeds on an existing name: a restore extracts into an empty volume only.
|
||||
volume_is_empty() { # volume
|
||||
local out
|
||||
out="$(docker run --rm --name "$HELPER" --network none -v "$1:/volume:ro" --entrypoint sh "$IMAGE_DB" \
|
||||
-c 'ls -A /volume')" || die "$1 cannot be read by the helper: nothing was extracted"
|
||||
-c 'ls -A /volume')" || die "$1 cannot be read by the helper: $(restore_extracted_note "$1")"
|
||||
[ -z "$out" ]
|
||||
}
|
||||
# Size in KiB and entry count of a volume, by the helper (read-only, no network); the entries are
|
||||
@@ -1333,7 +1345,7 @@ cmd_restore() {
|
||||
for vol in "$VOL_DB" "$VOL_STORAGE"; do
|
||||
if volume_exists "$vol"; then docker volume rm "$vol" >/dev/null; fi
|
||||
docker volume create --label faunosteo.stack=trial "$vol" >/dev/null
|
||||
volume_is_empty "$vol" || die "$vol is not empty after its creation: nothing was extracted"
|
||||
volume_is_empty "$vol" || die "$vol is not empty after its creation: $(restore_extracted_note "$vol")"
|
||||
docker run --rm -i --name "$HELPER" --network none -v "$vol:/volume" --entrypoint tar "$IMAGE_DB" \
|
||||
--numeric-owner -xpf - -C /volume < "$dir/${vol#faunosteo_trial_}.tar"
|
||||
done
|
||||
@@ -1357,9 +1369,16 @@ destroy_way_out_line() { # kind command
|
||||
|| { echo " ($1 listing failed, Docker did not answer: inspect the faunosteo_trial $1s by hand)"; return 0; }
|
||||
if [ -n "$names" ]; then echo " $2 ${names% }"; fi
|
||||
}
|
||||
# A container that still runs is stopped before it is removed: docker rm refuses it.
|
||||
destroy_stop_line() {
|
||||
local name names
|
||||
names="$(for name in "${CONTAINERS[@]}"; do if container_running "$name"; then printf '%s ' "$name"; fi; done)" || return 0
|
||||
if [ -n "$names" ]; then echo " docker stop ${names% } (first: these still run, docker rm refuses a running container)"; fi
|
||||
}
|
||||
destroy_way_out() { # kept backup folder, or empty
|
||||
if [ -n "$1" ]; then echo "backup $(basename "$1") is kept."; else echo "no backup could be made."; fi
|
||||
echo "Nothing was removed. To remove the stack yourself, run by hand:"
|
||||
destroy_stop_line
|
||||
destroy_way_out_line container 'docker rm'
|
||||
destroy_way_out_line network 'docker network rm'
|
||||
destroy_way_out_line volume 'docker volume rm'
|
||||
|
||||
Reference in new issue
Block a user