feat(system_baseline): optionally skip the upgrade while a vzdump backup is running
An apt upgrade of a Proxmox node can restart Proxmox services while a backup holds a snapshot of a guest, and the role had no way to say "not now". system_baseline_skip_upgrade_during_vzdump (bool, default false) makes the main flow and the update entry point ask the node for its running tasks (pvesh get /nodes/localhost/tasks --source active) before the upgrade, on the pve system type only. A vzdump task without an end time skips the upgrade with a message; autoremove, autoclean and the reboot check still run. The role does not wait for the backup. A pvesh answer that is not a JSON list stops the run. With the default no pvesh command runs. Closes #400 Assisted-by: Claude Code:claude-sonnet-5-5
This commit is contained in:
1 parent
1afce962a0
commit
5519733312
7 files changed
+170
-1
No files matched your search
@@ -0,0 +1,61 @@
|
||||
---
|
||||
# One case of the vzdump guard: a pvesh stub answers with system_baseline_case_answer, the update entry point runs in check mode, and the
|
||||
# fact that decides the upgrade, and whether pvesh was asked at all, are compared with what the case expects. Kept outside the role's own tasks:
|
||||
# no CI image is a Proxmox node, so the stub stands for the real `pvesh get /nodes/<node>/tasks` answer.
|
||||
- name: Write the pvesh stub
|
||||
check_mode: false
|
||||
ansible.builtin.copy:
|
||||
dest: /usr/local/bin/pvesh
|
||||
mode: "0755"
|
||||
content: |
|
||||
#!/bin/sh
|
||||
echo "$*" >> /var/tmp/pvesh-calls
|
||||
cat <<'JSON'
|
||||
{{ system_baseline_case.answer | to_json }}
|
||||
JSON
|
||||
|
||||
- name: Create the apt scratch directory, which a check mode run does not
|
||||
check_mode: false
|
||||
ansible.builtin.file:
|
||||
path: /var/cache/system-baseline-apt-tmp
|
||||
state: directory
|
||||
mode: "0700"
|
||||
|
||||
- name: Forget earlier calls
|
||||
ansible.builtin.file:
|
||||
path: /var/tmp/pvesh-calls
|
||||
state: absent
|
||||
|
||||
- name: Run the update entry point in check mode
|
||||
check_mode: true
|
||||
block:
|
||||
- name: Include system_baseline, tasks_from update
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.system_baseline
|
||||
tasks_from: update
|
||||
vars:
|
||||
system_baseline_system_type: "{{ system_baseline_case.type }}"
|
||||
system_baseline_skip_upgrade_during_vzdump: "{{ system_baseline_case.input }}"
|
||||
|
||||
- name: Read the recorded pvesh calls
|
||||
ansible.builtin.slurp:
|
||||
src: /var/tmp/pvesh-calls
|
||||
register: system_baseline_case_calls
|
||||
failed_when: false
|
||||
|
||||
- name: The guard decided as the case expects, and pvesh was asked only when it should be
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- __system_baseline_vzdump_running == system_baseline_case.running
|
||||
- (system_baseline_case_calls.content is defined) == system_baseline_case.asked
|
||||
- not system_baseline_case.asked or
|
||||
"get /nodes/localhost/tasks --source active --limit 0 --output-format json" in (system_baseline_case_calls.content | b64decode)
|
||||
quiet: true
|
||||
|
||||
- name: Remove the pvesh stub and its record
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- /usr/local/bin/pvesh
|
||||
- /var/tmp/pvesh-calls
|
||||
Reference in new issue
Block a user