feat(system_baseline): optionally skip the pve dist-upgrade while a vzdump backup is running #400

Open
opened 2026-11-26 20:57:50 +00:00 by Dragonish · 0 comments
Collaborator

Problem

On a Proxmox VE node, system_baseline runs apt-get dist-upgrade (profile pve, apt_upgrade: dist). If a scheduled backup (a vzdump task) is running on the node at that moment, the upgrade can restart Proxmox services, or later force a reboot, while the backup holds a snapshot of a guest. The consumer's play has no way to say "not now"; the only controls today are system_baseline_update: false (skips every update for every run) and timing the play outside the backup window by hand.

Out of scope: pausing guests, waiting for the backup to finish (the proposal skips and says so), non-Proxmox hosts, the reboot step, and the update entry point's default behaviour.

Proposal

One new optional bool, default false, so nothing changes unless a consumer opts in:

  • system_baseline_skip_upgrade_during_vzdump (bool, default false): when true and system_baseline_system_type is pve, the role asks the node for its recent tasks before the upgrade and skips the upgrade task (a visible debug message says why) if a vzdump task has no end time. It then continues with the rest of the flow.

Sketch for tasks/update.yml, before the upgrade task (all guarded on the input and on the system type being defined and pve, so off Proxmox and with the default it is a no-op):

- name: List recent Proxmox tasks on this node
  ansible.builtin.command:
    argv: [pvesh, get, "/nodes/{{ __system_baseline_pve_node }}/tasks", "--limit", "50", "--output-format", json]
  register: __system_baseline_pve_tasks
  changed_when: false
  check_mode: false          # a command that only reads state, so a dry run sees the real state
  become: true
  when: <input is true and system type is pve>

- name: Note whether a vzdump task is running
  ansible.builtin.set_fact:
    __system_baseline_vzdump_running: "{{ (__system_baseline_pve_tasks.stdout | from_json | selectattr('type', 'equalto', 'vzdump') | rejectattr('endtime', 'defined') | list | length) > 0 }}"

and the upgrade task gains and not __system_baseline_vzdump_running | default(false) in its when. The autoremove task stays as it is (the existing design keeps it separate). Node name: a new internal fact from the host's short name; an input to override it is not proposed unless the maintainer wants one.

Open question for the maintainer: update.yml is shared by the main flow and the update entry point. The default false keeps the entry point unchanged for every existing caller. Should a caller that sets the input to true and calls tasks_from: update get the guard too (one code path, proposed), or only the main flow (checked through __system_baseline_main_flow, as the check-mode skip is today)?

Also open: whether the guard belongs in the profile (a pve profile key, like apt_upgrade) rather than a flat input. A flat input is proposed because the entry point reads no profile.

Acceptance criteria

  • system_baseline_skip_upgrade_during_vzdump is in defaults/main.yml (false) and meta/argument_specs.yml (type: bool, description, default: false). Check: ansible-lint, ansible-doc -t role mortis.kamino.system_baseline.
  • With the default, a molecule run on ubuntu_lxc and ubuntu_vm executes no pvesh command and the task list is otherwise as in v3.0.0. Check: existing molecule default scenario unchanged and green.
  • With the input true on a non-pve system type, no pvesh call is made and the upgrade runs. Check: molecule scenario on ubuntu_lxc asserting the upgrade ran and pvesh is absent.
  • With the input true on pve and a running vzdump task, the upgrade is skipped, a message names the reason, and the rest of the flow runs. Check: a unit-style molecule scenario that stubs pvesh with a script printing one task with no endtime, asserts the skip message and that no apt upgrade ran.
  • With the input true on pve and no running task (all listed tasks have an endtime), the upgrade runs. Check: same stub printing finished tasks only.
  • The task that reads the task list has check_mode: false and changed_when: false. Check: review; --check on the stub scenario reports no change from it.
  • README (variables table, update entry-point note) and a minor_changes fragment exist. Check: pre-commit run --all-files.
  • Not verifiable in CI today: the real pvesh output on a Proxmox node. Check: the author runs the role once on a real node during a backup and states the result in the pull request under "Verified".

This is the contributor's own code and is offered under GPL-3.0-or-later, the Collection's licence.

Assisted-by: Claude Code

## Problem On a Proxmox VE node, `system_baseline` runs `apt-get dist-upgrade` (profile `pve`, `apt_upgrade: dist`). If a scheduled backup (a `vzdump` task) is running on the node at that moment, the upgrade can restart Proxmox services, or later force a reboot, while the backup holds a snapshot of a guest. The consumer's play has no way to say "not now"; the only controls today are `system_baseline_update: false` (skips every update for every run) and timing the play outside the backup window by hand. Out of scope: pausing guests, waiting for the backup to finish (the proposal skips and says so), non-Proxmox hosts, the reboot step, and the `update` entry point's default behaviour. ## Proposal One new optional bool, default `false`, so nothing changes unless a consumer opts in: - `system_baseline_skip_upgrade_during_vzdump` (bool, default `false`): when `true` and `system_baseline_system_type` is `pve`, the role asks the node for its recent tasks before the upgrade and skips the upgrade task (a visible `debug` message says why) if a `vzdump` task has no end time. It then continues with the rest of the flow. Sketch for `tasks/update.yml`, before the upgrade task (all guarded on the input and on the system type being defined and `pve`, so off Proxmox and with the default it is a no-op): ```yaml - name: List recent Proxmox tasks on this node ansible.builtin.command: argv: [pvesh, get, "/nodes/{{ __system_baseline_pve_node }}/tasks", "--limit", "50", "--output-format", json] register: __system_baseline_pve_tasks changed_when: false check_mode: false # a command that only reads state, so a dry run sees the real state become: true when: <input is true and system type is pve> - name: Note whether a vzdump task is running ansible.builtin.set_fact: __system_baseline_vzdump_running: "{{ (__system_baseline_pve_tasks.stdout | from_json | selectattr('type', 'equalto', 'vzdump') | rejectattr('endtime', 'defined') | list | length) > 0 }}" ``` and the upgrade task gains `and not __system_baseline_vzdump_running | default(false)` in its `when`. The autoremove task stays as it is (the existing design keeps it separate). Node name: a new internal fact from the host's short name; an input to override it is not proposed unless the maintainer wants one. Open question for the maintainer: update.yml is shared by the main flow and the `update` entry point. The default `false` keeps the entry point unchanged for every existing caller. Should a caller that sets the input to `true` and calls `tasks_from: update` get the guard too (one code path, proposed), or only the main flow (checked through `__system_baseline_main_flow`, as the check-mode skip is today)? Also open: whether the guard belongs in the profile (a `pve` profile key, like `apt_upgrade`) rather than a flat input. A flat input is proposed because the entry point reads no profile. ## Acceptance criteria - [ ] `system_baseline_skip_upgrade_during_vzdump` is in `defaults/main.yml` (`false`) and `meta/argument_specs.yml` (`type: bool`, description, `default: false`). Check: `ansible-lint`, `ansible-doc -t role mortis.kamino.system_baseline`. - [ ] With the default, a molecule run on `ubuntu_lxc` and `ubuntu_vm` executes no `pvesh` command and the task list is otherwise as in v3.0.0. Check: existing molecule `default` scenario unchanged and green. - [ ] With the input `true` on a non-`pve` system type, no `pvesh` call is made and the upgrade runs. Check: molecule scenario on `ubuntu_lxc` asserting the upgrade ran and `pvesh` is absent. - [ ] With the input `true` on `pve` and a running `vzdump` task, the upgrade is skipped, a message names the reason, and the rest of the flow runs. Check: a unit-style molecule scenario that stubs `pvesh` with a script printing one task with no `endtime`, asserts the skip message and that no apt upgrade ran. - [ ] With the input `true` on `pve` and no running task (all listed tasks have an `endtime`), the upgrade runs. Check: same stub printing finished tasks only. - [ ] The task that reads the task list has `check_mode: false` and `changed_when: false`. Check: review; `--check` on the stub scenario reports no change from it. - [ ] README (variables table, `update` entry-point note) and a `minor_changes` fragment exist. Check: `pre-commit run --all-files`. - [ ] Not verifiable in CI today: the real `pvesh` output on a Proxmox node. Check: the author runs the role once on a real node during a backup and states the result in the pull request under "Verified". This is the contributor's own code and is offered under GPL-3.0-or-later, the Collection's licence. Assisted-by: Claude Code
Dragonish added the
Status
Ready for Human
label 2026-11-26 20:57:50 +00:00
Dragonish added
Status
Ready for Agent
and removed
Status
Ready for Human
labels 2026-11-26 21:18:12 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#400