2227
This commit is contained in:
@@ -39,8 +39,9 @@
|
||||
effective_max_attempts: "{{ (max_attempts | default(3)) | int }}"
|
||||
correlation_id: "{{ correlation_id | default('') }}"
|
||||
original_emitted_at: "{{ original_emitted_at | default('') }}"
|
||||
# keep whatever scheduler sent in core and full; prefer full when available
|
||||
target_version: "{{ target_version | default('') }}"
|
||||
target_version_full: "{{ target_version | default('') }}"
|
||||
target_version_full: "{{ target_version_full | default(target_version | default('')) }}"
|
||||
|
||||
# Visibility of what scheduler sent
|
||||
- name: Debug show received scheduler metadata
|
||||
@@ -151,7 +152,8 @@
|
||||
max_attempts: "{{ effective_max_attempts | int }}"
|
||||
correlation_id: "{{ correlation_id }}"
|
||||
original_emitted_at: "{{ original_emitted_at }}"
|
||||
target_version: "{{ target_version_full }}"
|
||||
target_version_full: "{{ target_version_full }}" # <-- ADD
|
||||
target_version: "{{ target_version | default(target_version_full) }}" # <-- ADD (keeps core if it was sent)
|
||||
current_delay_sec: "{{ next_delay_sec | int }}"
|
||||
schema_version: 1
|
||||
|
||||
@@ -698,6 +700,8 @@
|
||||
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
|
||||
current_delay_sec: "{{ next_delay_sec | int }}"
|
||||
schema_version: 1
|
||||
|
||||
|
||||
@@ -483,25 +483,20 @@
|
||||
|
||||
# ---------------------------- Normalize rebootin early (HOURS) ----------------------------
|
||||
# Accept: "", "now", "immediate", numeric (4), numeric string ("4"), or "4h"
|
||||
|
||||
- name: Normalize rebootin detect now or integer HOURS
|
||||
delegate_to: localhost
|
||||
ansible.builtin.set_fact:
|
||||
_reboot_raw: "{{ rebootin | default('') | string | trim | lower }}"
|
||||
_reboot_is_now: "{{ (rebootin | default('') | string | trim | lower) in ['', 'now', 'immediate'] }}"
|
||||
_reboot_is_numtype: "{{ (rebootin | type_debug) in ['int','float'] }}"
|
||||
_reboot_is_digitstr: "{{ (rebootin | default('') | string | trim) is match('^\\d+$') }}"
|
||||
_reboot_is_hsuffix: "{{ (rebootin | default('') | string | trim | lower) is match('^\\d+h$') }}"
|
||||
_reboot_is_int: "{{ (rebootin | default('') | string | trim) is match('^\\d+$') }}"
|
||||
_reboot_hours: >-
|
||||
{{
|
||||
0
|
||||
if ((rebootin | default('') | string | trim | lower) in ['', 'now', 'immediate'])
|
||||
else ( (rebootin | int)
|
||||
if ((rebootin | type_debug) in ['int','float'])
|
||||
else ( (_reboot_raw | regex_replace('h$', '') | int)
|
||||
if (_reboot_is_digitstr or _reboot_is_hsuffix)
|
||||
else -1))
|
||||
0 if _reboot_is_now
|
||||
else (rebootin | int if _reboot_is_int else -1)
|
||||
}}
|
||||
|
||||
|
||||
- name: Debug reboot normalization detail
|
||||
delegate_to: localhost
|
||||
ansible.builtin.debug:
|
||||
@@ -521,15 +516,19 @@
|
||||
|
||||
# Compute reboot flags and *final* seconds.
|
||||
# Rule: now/empty/0 -> 20s grace; hours>0 -> hours*3600 (no extra 20s).
|
||||
- name: Compute reboot flags requested and seconds with proper conversion
|
||||
|
||||
- name: Compute reboot flags requested and seconds with 20s grace
|
||||
delegate_to: localhost
|
||||
ansible.builtin.set_fact:
|
||||
_reboot_requested: "{{ _reboot_is_now or (_reboot_hours | int) >= 0 }}"
|
||||
_reboot_requested: "{{ _reboot_is_now or _reboot_is_int }}"
|
||||
# Rule:
|
||||
# - now/empty OR hours <= 0 -> 20s
|
||||
# - hours > 0 -> hours * 3600 (no extra 20s)
|
||||
_reboot_seconds: >-
|
||||
{{
|
||||
20
|
||||
if (_reboot_is_now or ((_reboot_hours | int) == 0))
|
||||
else ((_reboot_hours | int) * 3600)
|
||||
20 if _reboot_is_now
|
||||
else (20 if ((_reboot_is_int | bool) and ((_reboot_hours | int) <= 0))
|
||||
else ((_reboot_hours | int) * 3600))
|
||||
}}
|
||||
|
||||
# Derive minutes from seconds
|
||||
@@ -1052,11 +1051,12 @@
|
||||
ansible.builtin.set_fact:
|
||||
expected_fw_core: >-
|
||||
{{
|
||||
image_filename
|
||||
| regex_replace('.*?([0-9]+\\.[0-9]+\\.[0-9]+)-r([0-9]+).*','\\1-r\\2')
|
||||
(image_filename | regex_search('([0-9]+\\.[0-9]+\\.[0-9]+-r[0-9]+)'))
|
||||
| default('', true)
|
||||
}}
|
||||
when: au_delay_sec is defined
|
||||
|
||||
|
||||
- name: Debug derived expected target_version for checker
|
||||
delegate_to: localhost
|
||||
ansible.builtin.debug:
|
||||
@@ -1070,6 +1070,7 @@
|
||||
afterupgrade_payload:
|
||||
task_name: "afterupgrade_indoor_check"
|
||||
inscope_device: "{{ ansible_hostname | default(inventory_hostname) }}"
|
||||
target_version_full: "{{ image_filename }}"
|
||||
target_version: "{{ expected_fw_core }}"
|
||||
attempt: "{{ au_attempt }}"
|
||||
max_attempts: "{{ au_max_attempts }}"
|
||||
@@ -1080,6 +1081,7 @@
|
||||
when: au_delay_sec is defined
|
||||
delegate_to: localhost
|
||||
|
||||
|
||||
- name: Debug after-upgrade plan (routing + delay + version)
|
||||
ansible.builtin.debug:
|
||||
msg:
|
||||
@@ -1089,6 +1091,13 @@
|
||||
when: afterupgrade_payload is defined
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Debug after-upgrade payload JSON (exactly what will be sent)
|
||||
delegate_to: localhost
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ afterupgrade_payload | to_json }}"
|
||||
when: afterupgrade_payload is defined
|
||||
|
||||
|
||||
- name: Publish delayed after-upgrade check (headers.x-delay) to holding exchange
|
||||
ansible.builtin.uri:
|
||||
url: "http://{{ rmq_host }}:{{ rmq_port }}/api/exchanges/{{ rmq_vhost | urlencode }}/{{ 'deviceconfig.delayed' | urlencode }}/publish"
|
||||
|
||||
Reference in New Issue
Block a user