From a8a1cbcf3e7a1aa1708d881db37a08b0c1d5a83a Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Mon, 23 Feb 2026 17:01:18 +0100 Subject: [PATCH] feat(telemetry): add 'validation' status, fix status transitions, show 20 log lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- misc/alpine-install.func | 8 ++++++-- misc/api.func | 8 ++++++-- misc/build.func | 10 ++++++---- misc/core.func | 8 ++++---- misc/install.func | 8 ++++++-- misc/vm-core.func | 6 +++--- 6 files changed, 31 insertions(+), 17 deletions(-) diff --git a/misc/alpine-install.func b/misc/alpine-install.func index a870b8650..a80b2e6d3 100644 --- a/misc/alpine-install.func +++ b/misc/alpine-install.func @@ -25,7 +25,9 @@ get_lxc_ip # post_progress_to_api() # # - 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) # - Fire-and-forget: never blocks or fails the script # - Only executes if DIAGNOSTICS=yes and RANDOM_UUID is set @@ -35,9 +37,11 @@ post_progress_to_api() { [[ "${DIAGNOSTICS:-no}" == "no" ]] && return 0 [[ -z "${RANDOM_UUID:-}" ]] && return 0 + local progress_status="${1:-configuring}" + curl -fsS -m 5 -X POST "https://telemetry.community-scripts.org/telemetry" \ -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 diff --git a/misc/api.func b/misc/api.func index a2cc42e07..b95f3cade 100644 --- a/misc/api.func +++ b/misc/api.func @@ -741,7 +741,10 @@ EOF # post_progress_to_api() # # - 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) # - Fire-and-forget: never blocks or fails the script # - Only executes if DIAGNOSTICS=yes and RANDOM_UUID is set @@ -752,12 +755,13 @@ post_progress_to_api() { [[ "${DIAGNOSTICS:-no}" == "no" ]] && return 0 [[ -z "${RANDOM_UUID:-}" ]] && return 0 + local progress_status="${1:-configuring}" local app_name="${NSAPP:-${app:-unknown}}" local telemetry_type="${TELEMETRY_TYPE:-lxc}" curl -fsS -m 5 -X POST "${TELEMETRY_URL:-https://telemetry.community-scripts.org/telemetry}" \ -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 } # ------------------------------------------------------------------------------ diff --git a/misc/build.func b/misc/build.func index e61d2c649..38dd371b1 100644 --- a/misc/build.func +++ b/misc/build.func @@ -3912,7 +3912,6 @@ EOF for i in {1..10}; do if pct status "$CTID" | grep -q "status: running"; then msg_ok "Started LXC Container" - post_progress_to_api # Signal container is running break fi sleep 1 @@ -3967,7 +3966,6 @@ EOF echo -e "${YW}Container may have limited internet access. Installation will continue...${CL}" else msg_ok "Network in LXC is reachable (ping)" - post_progress_to_api # Signal network is ready fi fi # Function to get correct GID inside container @@ -4039,7 +4037,9 @@ EOF' fi 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) 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 post_to_api + # Transition to 'validation' — Proxmox-internal checks (storage, template, cluster) + post_progress_to_api "validation" + # Storage capability check check_storage_support "rootdir" || { 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." - post_progress_to_api # Signal container creation complete } # ============================================================================== diff --git a/misc/core.func b/misc/core.func index 33ac1752b..c0460c0ff 100644 --- a/misc/core.func +++ b/misc/core.func @@ -488,7 +488,7 @@ log_section() { # silent() # # - 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 # - Sources explain_exit_code() for detailed error messages # ------------------------------------------------------------------------------ @@ -530,8 +530,8 @@ silent() { msg_custom "→" "${YWB}" "${cmd}" if [[ -s "$logfile" ]]; then - echo -e "\n${TAB}--- Last 10 lines of log ---" - tail -n 10 "$logfile" + echo -e "\n${TAB}--- Last 20 lines of log ---" + tail -n 20 "$logfile" echo -e "${TAB}-----------------------------------" echo -e "${TAB}📋 Full log: ${logfile}\n" fi @@ -1505,7 +1505,7 @@ cleanup_lxc() { fi msg_ok "Cleaned" - + # Send progress ping if available (defined in install.func) if declare -f post_progress_to_api &>/dev/null; then post_progress_to_api diff --git a/misc/install.func b/misc/install.func index 69b1498ec..807a11426 100644 --- a/misc/install.func +++ b/misc/install.func @@ -51,7 +51,9 @@ get_lxc_ip # post_progress_to_api() # # - 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) # - Fire-and-forget: never blocks or fails the script # - Only executes if DIAGNOSTICS=yes and RANDOM_UUID is set @@ -61,9 +63,11 @@ post_progress_to_api() { [[ "${DIAGNOSTICS:-no}" == "no" ]] && return 0 [[ -z "${RANDOM_UUID:-}" ]] && return 0 + local progress_status="${1:-configuring}" + curl -fsS -m 5 -X POST "https://telemetry.community-scripts.org/telemetry" \ -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 } # ============================================================================== diff --git a/misc/vm-core.func b/misc/vm-core.func index 66949fa69..77b185fdf 100644 --- a/misc/vm-core.func +++ b/misc/vm-core.func @@ -169,7 +169,7 @@ get_active_logfile() { # silent() # # - 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 # - Sources explain_exit_code() for detailed error messages # ------------------------------------------------------------------------------ @@ -207,8 +207,8 @@ silent() { msg_custom "→" "${YWB}" "${cmd}" if [[ -s "$logfile" ]]; then - echo -e "\n${TAB}--- Last 10 lines of log ---" - tail -n 10 "$logfile" + echo -e "\n${TAB}--- Last 20 lines of log ---" + tail -n 20 "$logfile" echo -e "${TAB}----------------------------\n" fi