fix(vm_collect,vm_hot_plug): fix label selector and memory bugs#8
Conversation
Observed ScenarioA user reported CPU hotplug failing via AAP with the following job template vars: vars:
openshift_host: "{{ openshift_host }}"
openshift_api_key: "{{ openshift_api_key }}"
openshift_verify_ssl: "{{ openshift_verify_ssl | default(false) | bool }}"
vm_hot_plug_request:
- namespace: "{{ vm_namespace }}"
names:
- "{{ vm_name }}"
compute:
cpu:
cores: "{{ cpu_cores | int }}"
restartIfRequired: "{{ restart_if_needed | default(false) | bool }}"Observed behavior:
Analysis: This scenario uses
For the specific "No items in the list" skip on |
Omitted seeing conflicted file @stevefulme1 would you be able to review the conflict in the |
…ctor queries and memory hotplug Three bugs fixed: 1. vm_collect: task name referenced vm_backup_restore_collect_obj and collect_obj_default_kind (leftover from backup_restore role), causing undefined variable errors when using label_selectors. Fixed to use vm_collect_obj and vm_collect_obj_default_kind. 2. vm_collect: set_fact in the label_selectors block referenced vm_collect_no_label_selectors_response (the loop_var from the other block) instead of vm_collect_label_selectors_response. This caused VMs queried via label_selectors to never be added to the collection, resulting in an empty VM list downstream. 3. vm_hot_plug: compute_patch.yml.j2 checked for 'cpu' instead of 'memory' when deciding whether to patch domain/memory/guest. Memory- only hotplug was silently skipped; cpu-only hotplug would fail trying to render an undefined memory value. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…-ansible manage deps/commands
2cd50bc to
1942a6e
Compare
|
Rebased onto main and resolved the |
Summary
vm_backup_restorethat break VM collection when usinglabel_selectorsBug Details
Bug 1 — Wrong variable names in task name (
vm_collect/tasks/main.yml:48)The label selector block's task name referenced
vm_backup_restore_collect_objandcollect_obj_default_kind— leftover from thevm_backup_restorerole. Both are undefined in thevm_collectcontext, causing a variable error when the block evaluates.Fix: Changed to
vm_collect_obj | default(vm_collect_obj_default_kind)to match the rest of the role.Bug 2 — Wrong loop variable in set_fact (
vm_collect/tasks/main.yml:64)The
set_factin the label_selectors block referencedvm_collect_no_label_selectors_response(the loop_var from the other block) instead ofvm_collect_label_selectors_response. This means VMs queried via label selectors were never added to the collection list — the variable was undefined, so the task would error or produce empty results.Fix: Changed
vm_collect_no_label_selectors_response→vm_collect_label_selectors_response.Bug 3 — Wrong condition for memory hotplug (
vm_hot_plug/templates/compute_patch.yml.j2:13)The Jinja2 template checked
'cpu' in vm_hot_plug_computebefore rendering the memory patch (/spec/template/spec/domain/memory/guest). This caused:vm_hot_plug_compute['memory']which is undefined)Fix: Changed condition to
'memory' in vm_hot_plug_compute.Test plan
vm_hot_plugwithlabel_selectorsin the request — VMs should now be collected and patchedvm_hot_plugwith CPU-only compute change — should patch CPU without attempting memoryvm_hot_plugwith memory-only compute change — should patch memory correctlyvm_hot_plugwith both CPU and memory — both patches appliedvm_hot_plugwith namespace/names (no label_selectors) — verify no regression🤖 Generated with Claude Code