diff --git a/files/2.2.0-r9739.bin b/files/2.2.0-r9739.bin deleted file mode 100644 index 4fb6c94..0000000 Binary files a/files/2.2.0-r9739.bin and /dev/null differ diff --git a/files/2.2.1-r9763.bin b/files/2.2.1-r9763.bin deleted file mode 100644 index 53a1af8..0000000 Binary files a/files/2.2.1-r9763.bin and /dev/null differ diff --git a/files/ansible-playbooks/afterupgrade_indoor_check.yml b/files/ansible-playbooks/afterupgrade_indoor_check.yml index 035423f..3222d5d 100644 --- a/files/ansible-playbooks/afterupgrade_indoor_check.yml +++ b/files/ansible-playbooks/afterupgrade_indoor_check.yml @@ -43,6 +43,21 @@ target_version: "{{ target_version | default('') }}" target_version_full: "{{ target_version_full | default(target_version | default('')) }}" + - name: Debug | snapshot of incoming scheduler metadata + delegate_to: localhost + when: debug_aic | bool + ansible.builtin.debug: + msg: + - "attempt={{ attempt | default('') }}" + - "max_attempts={{ max_attempts | default('') }}" + - "current_delay_sec={{ current_delay_sec | default('') }}" + - "correlation_id={{ correlation_id | default('') }}" + - "original_emitted_at={{ original_emitted_at | default('') }}" + - "target_version_full={{ target_version_full | default('') }}" + - "target_version={{ target_version | default('') }}" + - "schema_version={{ schema_version | default('') }}" + + # Visibility of what scheduler sent - name: Debug show received scheduler metadata delegate_to: localhost @@ -152,8 +167,8 @@ max_attempts: "{{ effective_max_attempts | int }}" correlation_id: "{{ correlation_id }}" original_emitted_at: "{{ original_emitted_at }}" - target_version_full: "{{ target_version_full }}" # <-- ADD - target_version: "{{ target_version | default(target_version_full) }}" # <-- ADD (keeps core if it was sent) + target_version_full: "{{ target_version_full }}" + target_version: "{{ target_version | default(target_version_full) }}" current_delay_sec: "{{ next_delay_sec | int }}" schema_version: 1 @@ -336,6 +351,15 @@ changed_when: false ignore_errors: true + - name: Debug | banner normalization inputs + delegate_to: localhost + when: debug_aic | bool + ansible.builtin.debug: + msg: + - "banner_raw={{ (firmware_banner.stdout | default(firmware_banner) | default('')) | trim }}" + - "normalize rule: '2.2.1 rev 6801' -> '2.2.1-r6801'" + + - name: Debug show raw firmware readout from DEV2 delegate_to: localhost ansible.builtin.debug: @@ -365,6 +389,16 @@ ansible.builtin.set_fact: expected_norm_step1: "{{ (target_version_full | default('') | trim) }}" + - name: Debug | expected target base and regex extraction inputs + delegate_to: localhost + when: debug_aic | bool + ansible.builtin.debug: + msg: + - "target_version(raw)={{ target_version | default('') }}" + - "target_version_full(raw)={{ target_version_full | default('') }}" + - "regex='[0-9]+\\.[0-9]+\\.[0-9]+-r[0-9]+'" + + - name: Extract version core X dot Y dot Z dash rNNNN from target if present delegate_to: localhost ansible.builtin.set_fact: @@ -380,6 +414,14 @@ ansible.builtin.set_fact: expected_norm: "{{ (expected_norm_core | default('') | length > 0) | ternary(expected_norm_core, expected_norm_step1) }}" + - name: Debug | final expected normalized version (what we will compare against) + delegate_to: localhost + when: debug_aic | bool + ansible.builtin.debug: + msg: + - "expected_norm={{ expected_norm | default('') }}" + + # 1 capture raw banner line from DEV2 - name: Capture firmware banner line from DEV2 delegate_to: localhost @@ -399,6 +441,24 @@ ) }} + - name: Debug | banner normalized result + delegate_to: localhost + when: debug_aic | bool + ansible.builtin.debug: + msg: + - "banner_norm={{ banner_norm | default('') }}" + + - name: Debug | version compare inputs and strategy + delegate_to: localhost + when: debug_aic | bool + ansible.builtin.debug: + msg: + - "expected_norm={{ expected_norm | default('') }}" + - "banner_norm={{ banner_norm | default('') }}" + - "eq={{ (expected_norm | default('')) == (banner_norm | default('')) }}" + - "substr={{ (banner_norm | default('')) is search((expected_norm | default('')), ignorecase=False) if (expected_norm | default('') | length) > 0 else 'N/A' }}" + + - name: Evaluate version match using normalized equality or substring delegate_to: localhost ansible.builtin.set_fact: @@ -412,6 +472,14 @@ ) }} + - name: Debug | version match outcome + delegate_to: localhost + when: debug_aic | bool + ansible.builtin.debug: + msg: + - "version_match={{ version_match | default(false) }}" + + - name: Debug snapshot of expected and actual normalized versions delegate_to: localhost ansible.builtin.debug: @@ -700,11 +768,21 @@ max_attempts: "{{ effective_max_attempts | int }}" correlation_id: "{{ correlation_id | default('') }}" original_emitted_at: "{{ original_emitted_at | default('') }}" - target_version_full: "{{ target_version_full }}" # <-- ADD - target_version: "{{ target_version | default(target_version_full) }}" # <-- ADD + target_version_full: "{{ target_version_full }}" + target_version: "{{ target_version | default(target_version_full) }}" current_delay_sec: "{{ next_delay_sec | int }}" schema_version: 1 + - name: Debug | next attempt backoff plan + delegate_to: localhost + when: debug_aic | bool and (version_match | default(false) | bool) == false + ansible.builtin.debug: + msg: + - "attempt={{ attempt | default('') }} / max_attempts={{ max_attempts | default('') }}" + - "next_delay_sec={{ next_delay_sec | default('') }}" + - "routing_key={{ routing_key | default('deviceconfig') }}" + - "correlation_id={{ correlation_id | default('') }}" + - name: Publish delayed next indoor attempt to holding with TTL routed to deviceconfig when: delayed_payload is defined delegate_to: localhost diff --git a/files/rabbit-client.sh b/files/rabbit-client.sh index 29178e6..9568b65 100644 --- a/files/rabbit-client.sh +++ b/files/rabbit-client.sh @@ -64,24 +64,41 @@ dispatch_task() { task="$(jq -er '.task_name // empty' <<<"$json")" || task="" task_options="$(jq -r '.task_options // empty' <<<"$json")" || task_options="" + # Pass after-upgrade metadata via -e by augmenting task_options (single source of truth) - if [[ "$task" == "afterupgrade_check" ]]; then - local attempt corr_id orig_at target_ver - attempt="$(jq -r '.attempt // empty' <<<"$json")" - corr_id="$(jq -r '.correlation_id // empty' <<<"$json")" - orig_at="$(jq -r '.original_emitted_at // empty' <<<"$json")" - target_ver="$(jq -r '.target_version // empty' <<<"$json")" + # Supports both historic 'afterupgrade_check' and current 'afterupgrade_indoor_check' + if [[ "$task" == "afterupgrade_indoor_check" || "$task" == "afterupgrade_check" ]]; then + # Extract everything the publisher may send + local attempt max_attempts cur_delay corr_id orig_at target_ver tv_full schema + attempt="$(jq -r '.attempt // ""' <<<"$json")" + max_attempts="$(jq -r '.max_attempts // ""' <<<"$json")" + cur_delay="$(jq -r '.current_delay_sec // ""' <<<"$json")" + corr_id="$(jq -r '.correlation_id // ""' <<<"$json")" + orig_at="$(jq -r '.original_emitted_at // ""' <<<"$json")" + target_ver="$(jq -r '.target_version // ""' <<<"$json")" + tv_full="$(jq -r '.target_version_full // ""' <<<"$json")" + schema="$(jq -r '.schema_version // ""' <<<"$json")" - [[ -n "$attempt" ]] && task_options+=" -e attempt=${attempt}" - [[ -n "$corr_id" ]] && task_options+=" -e correlation_id=${corr_id}" - [[ -n "$orig_at" ]] && task_options+=" -e original_emitted_at=${orig_at}" - - if [[ -n "$target_ver" ]]; then - local esc_tv=${target_ver//\'/\'\"\'\"\'} # replace ' with '\'' safely - task_options+=" -e target_version='${esc_tv}'" + # Backfill target_version from target_version_full if missing (e.g., fox200-2.2.1-r6801.bin → 2.2.1-r6801) + if [[ -z "$target_ver" && -n "$tv_full" ]]; then + target_ver="$(sed -nE 's/.*([0-9]+\.[0-9]+\.[0-9]+-r[0-9]+).*/\1/p' <<<"$tv_full" || true)" fi + + # Safe single-quote escaper for -e 'value' + esc() { local s="$1"; printf "%s" "${s//\'/\047}"; } + + # Always pass the vars (even if empty), so the play never sees undefined + task_options+=" -e attempt='$(esc "$attempt")'" + task_options+=" -e max_attempts='$(esc "$max_attempts")'" + task_options+=" -e current_delay_sec='$(esc "$cur_delay")'" + task_options+=" -e correlation_id='$(esc "$corr_id")'" + task_options+=" -e original_emitted_at='$(esc "$orig_at")'" + task_options+=" -e target_version='$(esc "$target_ver")'" + task_options+=" -e target_version_full='$(esc "$tv_full")'" + task_options+=" -e schema_version='$(esc "$schema")'" fi + if [[ -z "$device" || -z "$task" ]]; then warn "payload missing required keys (inscope_device/task_name). Skipping." return 0