mirror of
https://github.com/community-scripts/ProxmoxVED.git
synced 2026-02-25 05:57:26 +00:00
Add telemetry debug/logging and failure report
Enhance post_update_to_api robustness and observability: add debug traces for entry, missing curl, duplicate submissions, DIAGNOSTICS/RANDOM_UUID checks, payload/URL output, and HTTP response code capture; make curl non-blocking and tolerant of failures. Also invoke post_update_to_api on installation failure so build/install errors are reported to telemetry. Includes a small comment glyph fix in build.func. Changes keep telemetry as a silent, best-effort path that won't break script execution.
This commit is contained in:
@@ -323,15 +323,30 @@ EOF
|
||||
# - Never blocks or fails script execution
|
||||
# ------------------------------------------------------------------------------
|
||||
post_update_to_api() {
|
||||
# DEBUG: Show function entry
|
||||
echo "[DEBUG] post_update_to_api() called with status=$1 exit_code=$2" >&2
|
||||
|
||||
# Silent fail - telemetry should never break scripts
|
||||
command -v curl &>/dev/null || return 0
|
||||
command -v curl &>/dev/null || {
|
||||
echo "[DEBUG] curl not found, skipping" >&2
|
||||
return 0
|
||||
}
|
||||
|
||||
# Prevent duplicate submissions
|
||||
POST_UPDATE_DONE=${POST_UPDATE_DONE:-false}
|
||||
[[ "$POST_UPDATE_DONE" == "true" ]] && return 0
|
||||
[[ "$POST_UPDATE_DONE" == "true" ]] && {
|
||||
echo "[DEBUG] Already sent update, skipping" >&2
|
||||
return 0
|
||||
}
|
||||
|
||||
[[ "${DIAGNOSTICS:-no}" == "no" ]] && return 0
|
||||
[[ -z "${RANDOM_UUID:-}" ]] && return 0
|
||||
[[ "${DIAGNOSTICS:-no}" == "no" ]] && {
|
||||
echo "[DEBUG] DIAGNOSTICS=no, skipping" >&2
|
||||
return 0
|
||||
}
|
||||
[[ -z "${RANDOM_UUID:-}" ]] && {
|
||||
echo "[DEBUG] RANDOM_UUID empty, skipping" >&2
|
||||
return 0
|
||||
}
|
||||
|
||||
local status="${1:-failed}"
|
||||
local raw_exit_code="${2:-1}"
|
||||
@@ -377,10 +392,16 @@ post_update_to_api() {
|
||||
EOF
|
||||
)
|
||||
|
||||
echo "[DEBUG] Sending update to: $TELEMETRY_URL" >&2
|
||||
echo "[DEBUG] Update payload: $JSON_PAYLOAD" >&2
|
||||
|
||||
# Fire-and-forget: never block, never fail
|
||||
curl -fsS -m "${TELEMETRY_TIMEOUT}" -X POST "${TELEMETRY_URL}" \
|
||||
local http_code
|
||||
http_code=$(curl -sS -w "%{http_code}" -m "${TELEMETRY_TIMEOUT}" -X POST "${TELEMETRY_URL}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$JSON_PAYLOAD" &>/dev/null || true
|
||||
-d "$JSON_PAYLOAD" -o /dev/stderr 2>&1) || true
|
||||
|
||||
echo "[DEBUG] HTTP response code: $http_code" >&2
|
||||
|
||||
POST_UPDATE_DONE=true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user