feat(telemetry): add 'validation' status, fix status transitions, show 20 log lines

Status flow is now: installing → validation → configuring → success/failed

Changes:
- post_progress_to_api() accepts optional status parameter (default: configuring)
- build.func: Send 'validation' before storage/template/cluster checks
- build.func: Send 'configuring' just before lxc-attach (app install)
- build.func: Remove redundant progress pings during container start/network
- install.func + alpine-install.func: Accept status parameter in container-side
  post_progress_to_api()
- core.func + vm-core.func: silent() now shows last 20 lines on error (was 10)
This commit is contained in:
CanbiZ (MickLesk)
2026-02-23 17:01:18 +01:00
parent 60f9622998
commit a8a1cbcf3e
6 changed files with 31 additions and 17 deletions

View File

@@ -25,7 +25,9 @@ get_lxc_ip
# post_progress_to_api() # post_progress_to_api()
# #
# - Lightweight progress ping from inside the container # - Lightweight progress ping from inside the container
# - Updates the existing telemetry record status from "installing" to "configuring" # - Updates the existing telemetry record status
# - Arguments:
# * $1: status (optional, default: "configuring")
# - Signals that the installation is actively progressing (not stuck) # - Signals that the installation is actively progressing (not stuck)
# - Fire-and-forget: never blocks or fails the script # - Fire-and-forget: never blocks or fails the script
# - Only executes if DIAGNOSTICS=yes and RANDOM_UUID is set # - Only executes if DIAGNOSTICS=yes and RANDOM_UUID is set
@@ -35,9 +37,11 @@ post_progress_to_api() {
[[ "${DIAGNOSTICS:-no}" == "no" ]] && return 0 [[ "${DIAGNOSTICS:-no}" == "no" ]] && return 0
[[ -z "${RANDOM_UUID:-}" ]] && return 0 [[ -z "${RANDOM_UUID:-}" ]] && return 0
local progress_status="${1:-configuring}"
curl -fsS -m 5 -X POST "https://telemetry.community-scripts.org/telemetry" \ curl -fsS -m 5 -X POST "https://telemetry.community-scripts.org/telemetry" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"random_id\":\"${RANDOM_UUID}\",\"execution_id\":\"${EXECUTION_ID:-${RANDOM_UUID}}\",\"type\":\"lxc\",\"nsapp\":\"${app:-unknown}\",\"status\":\"configuring\"}" &>/dev/null || true -d "{\"random_id\":\"${RANDOM_UUID}\",\"execution_id\":\"${EXECUTION_ID:-${RANDOM_UUID}}\",\"type\":\"lxc\",\"nsapp\":\"${app:-unknown}\",\"status\":\"${progress_status}\"}" &>/dev/null || true
} }
# This function enables IPv6 if it's not disabled and sets verbose mode # This function enables IPv6 if it's not disabled and sets verbose mode

View File

@@ -741,7 +741,10 @@ EOF
# post_progress_to_api() # post_progress_to_api()
# #
# - Lightweight progress ping from host or container # - Lightweight progress ping from host or container
# - Updates the existing telemetry record status to "configuring" # - Updates the existing telemetry record status
# - Arguments:
# * $1: status (optional, default: "configuring")
# Valid values: "validation", "configuring"
# - Signals that the installation is actively progressing (not stuck) # - Signals that the installation is actively progressing (not stuck)
# - Fire-and-forget: never blocks or fails the script # - Fire-and-forget: never blocks or fails the script
# - Only executes if DIAGNOSTICS=yes and RANDOM_UUID is set # - Only executes if DIAGNOSTICS=yes and RANDOM_UUID is set
@@ -752,12 +755,13 @@ post_progress_to_api() {
[[ "${DIAGNOSTICS:-no}" == "no" ]] && return 0 [[ "${DIAGNOSTICS:-no}" == "no" ]] && return 0
[[ -z "${RANDOM_UUID:-}" ]] && return 0 [[ -z "${RANDOM_UUID:-}" ]] && return 0
local progress_status="${1:-configuring}"
local app_name="${NSAPP:-${app:-unknown}}" local app_name="${NSAPP:-${app:-unknown}}"
local telemetry_type="${TELEMETRY_TYPE:-lxc}" local telemetry_type="${TELEMETRY_TYPE:-lxc}"
curl -fsS -m 5 -X POST "${TELEMETRY_URL:-https://telemetry.community-scripts.org/telemetry}" \ curl -fsS -m 5 -X POST "${TELEMETRY_URL:-https://telemetry.community-scripts.org/telemetry}" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"random_id\":\"${RANDOM_UUID}\",\"execution_id\":\"${EXECUTION_ID:-${RANDOM_UUID}}\",\"type\":\"${telemetry_type}\",\"nsapp\":\"${app_name}\",\"status\":\"configuring\"}" &>/dev/null || true -d "{\"random_id\":\"${RANDOM_UUID}\",\"execution_id\":\"${EXECUTION_ID:-${RANDOM_UUID}}\",\"type\":\"${telemetry_type}\",\"nsapp\":\"${app_name}\",\"status\":\"${progress_status}\"}" &>/dev/null || true
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------

View File

@@ -3912,7 +3912,6 @@ EOF
for i in {1..10}; do for i in {1..10}; do
if pct status "$CTID" | grep -q "status: running"; then if pct status "$CTID" | grep -q "status: running"; then
msg_ok "Started LXC Container" msg_ok "Started LXC Container"
post_progress_to_api # Signal container is running
break break
fi fi
sleep 1 sleep 1
@@ -3967,7 +3966,6 @@ EOF
echo -e "${YW}Container may have limited internet access. Installation will continue...${CL}" echo -e "${YW}Container may have limited internet access. Installation will continue...${CL}"
else else
msg_ok "Network in LXC is reachable (ping)" msg_ok "Network in LXC is reachable (ping)"
post_progress_to_api # Signal network is ready
fi fi
fi fi
# Function to get correct GID inside container # Function to get correct GID inside container
@@ -4039,7 +4037,9 @@ EOF'
fi fi
msg_ok "Customized LXC Container" msg_ok "Customized LXC Container"
post_progress_to_api # Signal ready for app installation
# Transition to 'configuring' — container install script is about to run
post_progress_to_api "configuring"
# Optional DNS override for retry scenarios (inside LXC, never on host) # Optional DNS override for retry scenarios (inside LXC, never on host)
if [[ "${DNS_RETRY_OVERRIDE:-false}" == "true" ]]; then if [[ "${DNS_RETRY_OVERRIDE:-false}" == "true" ]]; then
@@ -4910,6 +4910,9 @@ create_lxc_container() {
# Report installation start to API early - captures failures in storage/template/create # Report installation start to API early - captures failures in storage/template/create
post_to_api post_to_api
# Transition to 'validation' — Proxmox-internal checks (storage, template, cluster)
post_progress_to_api "validation"
# Storage capability check # Storage capability check
check_storage_support "rootdir" || { check_storage_support "rootdir" || {
msg_error "No valid storage found for 'rootdir' [Container]" msg_error "No valid storage found for 'rootdir' [Container]"
@@ -5439,7 +5442,6 @@ create_lxc_container() {
} }
msg_ok "LXC Container ${BL}$CTID${CL} ${GN}was successfully created." msg_ok "LXC Container ${BL}$CTID${CL} ${GN}was successfully created."
post_progress_to_api # Signal container creation complete
} }
# ============================================================================== # ==============================================================================

View File

@@ -488,7 +488,7 @@ log_section() {
# silent() # silent()
# #
# - Executes command with output redirected to active log file # - Executes command with output redirected to active log file
# - On error: displays last 10 lines of log and exits with original exit code # - On error: displays last 20 lines of log and exits with original exit code
# - Temporarily disables error trap to capture exit code correctly # - Temporarily disables error trap to capture exit code correctly
# - Sources explain_exit_code() for detailed error messages # - Sources explain_exit_code() for detailed error messages
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -530,8 +530,8 @@ silent() {
msg_custom "→" "${YWB}" "${cmd}" msg_custom "→" "${YWB}" "${cmd}"
if [[ -s "$logfile" ]]; then if [[ -s "$logfile" ]]; then
echo -e "\n${TAB}--- Last 10 lines of log ---" echo -e "\n${TAB}--- Last 20 lines of log ---"
tail -n 10 "$logfile" tail -n 20 "$logfile"
echo -e "${TAB}-----------------------------------" echo -e "${TAB}-----------------------------------"
echo -e "${TAB}📋 Full log: ${logfile}\n" echo -e "${TAB}📋 Full log: ${logfile}\n"
fi fi
@@ -1505,7 +1505,7 @@ cleanup_lxc() {
fi fi
msg_ok "Cleaned" msg_ok "Cleaned"
# Send progress ping if available (defined in install.func) # Send progress ping if available (defined in install.func)
if declare -f post_progress_to_api &>/dev/null; then if declare -f post_progress_to_api &>/dev/null; then
post_progress_to_api post_progress_to_api

View File

@@ -51,7 +51,9 @@ get_lxc_ip
# post_progress_to_api() # post_progress_to_api()
# #
# - Lightweight progress ping from inside the container # - Lightweight progress ping from inside the container
# - Updates the existing telemetry record status from "installing" to "configuring" # - Updates the existing telemetry record status
# - Arguments:
# * $1: status (optional, default: "configuring")
# - Signals that the installation is actively progressing (not stuck) # - Signals that the installation is actively progressing (not stuck)
# - Fire-and-forget: never blocks or fails the script # - Fire-and-forget: never blocks or fails the script
# - Only executes if DIAGNOSTICS=yes and RANDOM_UUID is set # - Only executes if DIAGNOSTICS=yes and RANDOM_UUID is set
@@ -61,9 +63,11 @@ post_progress_to_api() {
[[ "${DIAGNOSTICS:-no}" == "no" ]] && return 0 [[ "${DIAGNOSTICS:-no}" == "no" ]] && return 0
[[ -z "${RANDOM_UUID:-}" ]] && return 0 [[ -z "${RANDOM_UUID:-}" ]] && return 0
local progress_status="${1:-configuring}"
curl -fsS -m 5 -X POST "https://telemetry.community-scripts.org/telemetry" \ curl -fsS -m 5 -X POST "https://telemetry.community-scripts.org/telemetry" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"random_id\":\"${RANDOM_UUID}\",\"execution_id\":\"${EXECUTION_ID:-${RANDOM_UUID}}\",\"type\":\"lxc\",\"nsapp\":\"${app:-unknown}\",\"status\":\"configuring\"}" &>/dev/null || true -d "{\"random_id\":\"${RANDOM_UUID}\",\"execution_id\":\"${EXECUTION_ID:-${RANDOM_UUID}}\",\"type\":\"lxc\",\"nsapp\":\"${app:-unknown}\",\"status\":\"${progress_status}\"}" &>/dev/null || true
} }
# ============================================================================== # ==============================================================================

View File

@@ -169,7 +169,7 @@ get_active_logfile() {
# silent() # silent()
# #
# - Executes command with output redirected to active log file # - Executes command with output redirected to active log file
# - On error: displays last 10 lines of log and exits with original exit code # - On error: displays last 20 lines of log and exits with original exit code
# - Temporarily disables error trap to capture exit code correctly # - Temporarily disables error trap to capture exit code correctly
# - Sources explain_exit_code() for detailed error messages # - Sources explain_exit_code() for detailed error messages
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -207,8 +207,8 @@ silent() {
msg_custom "→" "${YWB}" "${cmd}" msg_custom "→" "${YWB}" "${cmd}"
if [[ -s "$logfile" ]]; then if [[ -s "$logfile" ]]; then
echo -e "\n${TAB}--- Last 10 lines of log ---" echo -e "\n${TAB}--- Last 20 lines of log ---"
tail -n 10 "$logfile" tail -n 20 "$logfile"
echo -e "${TAB}----------------------------\n" echo -e "${TAB}----------------------------\n"
fi fi