diff --git a/Plugin/unraid/Partnership/containers.sh b/Plugin/unraid/Partnership/containers.sh index 8a32f9b..6ca62fe 100755 --- a/Plugin/unraid/Partnership/containers.sh +++ b/Plugin/unraid/Partnership/containers.sh @@ -624,6 +624,12 @@ cleanup_deployed_stack_on_remote() { cleanup_deployed_stack_locally() { local owner_ip="$1" ssh_key="$2" 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 local -a auth_arr arr_arr @@ -647,8 +653,13 @@ cleanup_deployed_stack_locally() { fi if [[ ${#xml_names[@]} -eq 0 ]]; then - log "Could not read deployed stack from owner — skipping auth/arr/services cleanup" - return 0 + # Not a success. OWNER_REACHABLE only means a probe answered — the three SSH reads above + # 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 local _local_short @@ -685,17 +696,28 @@ cleanup_deployed_stack_locally() { "$cname" 2>/dev/null | awk -F: '{print $1}' | grep '^/mnt/.*/appdata') timeout "${DOCKER_TIMEOUT:-30}" docker stop "$cname" >/dev/null 2>&1 || true _PM_TRAP_STOPPED+=("$cname") - timeout "${DOCKER_TIMEOUT:-30}" docker rm "$cname" >/dev/null 2>&1 && \ - echo " $cname removed ✅" || warn " $cname rm failed" + if timeout "${DOCKER_TIMEOUT:-30}" docker rm "$cname" >/dev/null 2>&1; then + echo " $cname removed ✅" + else + warn " $cname rm failed" + _rc=1 + fi else log " $cname not found locally — skipping" fi while IFS= read -r path; do [[ -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 + + return "$_rc" } # ==============================================================================================