Offboard reported a stack cleanup that could not fail and, on one path, had not run
This commit is contained in:
@@ -624,6 +624,12 @@ cleanup_deployed_stack_on_remote() {
|
|||||||
cleanup_deployed_stack_locally() {
|
cleanup_deployed_stack_locally() {
|
||||||
local owner_ip="$1" ssh_key="$2"
|
local owner_ip="$1" ssh_key="$2"
|
||||||
local -a xml_names=()
|
local -a xml_names=()
|
||||||
|
# Callers write `cleanup_deployed_stack_locally … || STEP_STACK_CLEANUP_OK=false`, so the
|
||||||
|
# exit status is what the offboard summary prints. Every removal below warns and carries on
|
||||||
|
# — one container that will not die must not abandon the rest of the stack — which meant the
|
||||||
|
# function ended on a `done` and could only ever return 0. Step 3 reported ✅ even when every
|
||||||
|
# docker rm and every rm -rf had failed. Failures are collected here and reported at the end.
|
||||||
|
local _rc=0
|
||||||
|
|
||||||
if [[ -n "$owner_ip" ]]; then
|
if [[ -n "$owner_ip" ]]; then
|
||||||
local -a auth_arr arr_arr
|
local -a auth_arr arr_arr
|
||||||
@@ -647,8 +653,13 @@ cleanup_deployed_stack_locally() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${#xml_names[@]} -eq 0 ]]; then
|
if [[ ${#xml_names[@]} -eq 0 ]]; then
|
||||||
log "Could not read deployed stack from owner — skipping auth/arr/services cleanup"
|
# Not a success. OWNER_REACHABLE only means a probe answered — the three SSH reads above
|
||||||
return 0
|
# can still time out or come back empty, and then nothing was cleaned. The caller's own
|
||||||
|
# unreachable-owner branch sets STEP_STACK_CLEANUP_OK=false for exactly this situation,
|
||||||
|
# so returning 0 here made the summary claim a cleanup that never ran.
|
||||||
|
warn "Could not read deployed stack from owner — auth/arr/services cleanup did not run"
|
||||||
|
warn "Containers will remain — re-run when the owner answers over SSH"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local _local_short
|
local _local_short
|
||||||
@@ -685,17 +696,28 @@ cleanup_deployed_stack_locally() {
|
|||||||
"$cname" 2>/dev/null | awk -F: '{print $1}' | grep '^/mnt/.*/appdata')
|
"$cname" 2>/dev/null | awk -F: '{print $1}' | grep '^/mnt/.*/appdata')
|
||||||
timeout "${DOCKER_TIMEOUT:-30}" docker stop "$cname" >/dev/null 2>&1 || true
|
timeout "${DOCKER_TIMEOUT:-30}" docker stop "$cname" >/dev/null 2>&1 || true
|
||||||
_PM_TRAP_STOPPED+=("$cname")
|
_PM_TRAP_STOPPED+=("$cname")
|
||||||
timeout "${DOCKER_TIMEOUT:-30}" docker rm "$cname" >/dev/null 2>&1 && \
|
if timeout "${DOCKER_TIMEOUT:-30}" docker rm "$cname" >/dev/null 2>&1; then
|
||||||
echo " $cname removed ✅" || warn " $cname rm failed"
|
echo " $cname removed ✅"
|
||||||
|
else
|
||||||
|
warn " $cname rm failed"
|
||||||
|
_rc=1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
log " $cname not found locally — skipping"
|
log " $cname not found locally — skipping"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while IFS= read -r path; do
|
while IFS= read -r path; do
|
||||||
[[ -z "$path" ]] && continue
|
[[ -z "$path" ]] && continue
|
||||||
rm -rf "$path" && echo " Appdata removed: $path ✅" || warn " Failed to remove: $path"
|
if rm -rf "$path"; then
|
||||||
|
echo " Appdata removed: $path ✅"
|
||||||
|
else
|
||||||
|
warn " Failed to remove: $path"
|
||||||
|
_rc=1
|
||||||
|
fi
|
||||||
done <<< "$appdata_paths"
|
done <<< "$appdata_paths"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
return "$_rc"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ==============================================================================================
|
# ==============================================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user