PERFSCALE-2110: Ansible: scope create-vm teardown to target VM#6531
Conversation
Only destroy/undefine the VM named by vm_name instead of every microshift-* VM on the host.
|
@sjug: This pull request references PERFSCALE-2110 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target either version "5.0." or "openshift-5.0.", but it targets "openshift-4.14" instead. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
WalkthroughThis change simplifies VM cleanup logic in an Ansible playbook by replacing regex-based discovery of multiple VMs matching a pattern with a single Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 10✅ Passed checks (10 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ansible/roles/create-vm/tasks/main.yml (1)
9-19: LGTM — teardown now correctly scoped tovm_name.Single-VM targeting with the
vm_name in (all_vms.list_vms | default([]))guard cleanly prevents collateral damage to othermicroshift-*VMs on the host and safely no-ops when the VM doesn't exist.Optional nit: the identical
whenis duplicated across both tasks — wrapping them in ablock:with a singlewhen:would DRY it up, but totally fine as-is.♻️ Optional block refactor
-- name: destroy target VM if present - community.libvirt.virt: - name: "{{ vm_name }}" - state: destroyed - when: vm_name in (all_vms.list_vms | default([])) - -- name: undefine target VM if present - community.libvirt.virt: - name: "{{ vm_name }}" - command: undefine - when: vm_name in (all_vms.list_vms | default([])) +- name: tear down target VM if present + when: vm_name in (all_vms.list_vms | default([])) + block: + - name: destroy target VM + community.libvirt.virt: + name: "{{ vm_name }}" + state: destroyed + - name: undefine target VM + community.libvirt.virt: + name: "{{ vm_name }}" + command: undefine🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ansible/roles/create-vm/tasks/main.yml` around lines 9 - 19, Teardown tasks duplicate the same when condition; wrap the two tasks ("destroy target VM if present" and "undefine target VM if present") in a single block with a shared when: vm_name in (all_vms.list_vms | default([])) to DRY the playbook, keeping the community.libvirt.virt invocations (state: destroyed and command: undefine) unchanged and leaving vm_name and all_vms.list_vms as the gating symbols.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@ansible/roles/create-vm/tasks/main.yml`:
- Around line 9-19: Teardown tasks duplicate the same when condition; wrap the
two tasks ("destroy target VM if present" and "undefine target VM if present")
in a single block with a shared when: vm_name in (all_vms.list_vms |
default([])) to DRY the playbook, keeping the community.libvirt.virt invocations
(state: destroyed and command: undefine) unchanged and leaving vm_name and
all_vms.list_vms as the gating symbols.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: b4fe2f6b-8efe-42ed-b277-be44ccb0d22a
📒 Files selected for processing (1)
ansible/roles/create-vm/tasks/main.yml
|
@sjug: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
/lgtm |
|
@ggiguash: This PR has been marked as verified by DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ggiguash, sjug The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Avoid over-deletion when multiple microshift-* VMs exist on the same libvirt host.
Summary by CodeRabbit