Skip to content

PERFSCALE-2110: Ansible: scope create-vm teardown to target VM#6531

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
sjug:perfscale-2110-scope-vm-teardown
Apr 20, 2026
Merged

PERFSCALE-2110: Ansible: scope create-vm teardown to target VM#6531
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
sjug:perfscale-2110-scope-vm-teardown

Conversation

@sjug

@sjug sjug commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

Avoid over-deletion when multiple microshift-* VMs exist on the same libvirt host.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced VM management with improved safety checks during cleanup operations to ensure tasks execute only when required VMs are detected.

Only destroy/undefine the VM named by vm_name instead of every
microshift-* VM on the host.
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 18, 2026
@openshift-ci-robot

openshift-ci-robot commented Apr 18, 2026

Copy link
Copy Markdown

@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.

Details

In response to this:

Avoid over-deletion when multiple microshift-* VMs exist on the same libvirt host.

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.

@openshift-ci openshift-ci Bot requested review from ggiguash and jogeo April 18, 2026 00:34
@coderabbitai

coderabbitai Bot commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This change simplifies VM cleanup logic in an Ansible playbook by replacing regex-based discovery of multiple VMs matching a pattern with a single vm_name variable approach, and adds conditional guards to ensure operations only execute when the target VM is present.

Changes

Cohort / File(s) Summary
VM Cleanup Refactoring
ansible/roles/create-vm/tasks/main.yml
Removed regex-based discovery of microshift-* VMs; replaced multi-VM iteration with single vm_name variable targeting. Added conditional checks using default([]) to guard destroy and undefine operations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 10
✅ Passed checks (10 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: scoping the VM teardown to a single target VM instead of all microshift-* VMs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Stable And Deterministic Test Names ✅ Passed Custom check for Ginkgo test name stability is not applicable; PR modifies only Ansible playbook YAML files, no Go test files.
Test Structure And Quality ✅ Passed PR involves Ansible role modification to create-vm tasks; no Ginkgo test code changes detected.
Microshift Test Compatibility ✅ Passed The custom check for MicroShift test compatibility applies only when new Ginkgo e2e tests are added. This PR modifies only an Ansible infrastructure file with no Ginkgo e2e tests added or modified, making the check inapplicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PR modifies only Ansible playbook files without adding Ginkgo e2e tests, so SNO compatibility check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies only Ansible libvirt VM task; no Kubernetes manifests, operators, controllers, or scheduling constraints present.
Ote Binary Stdout Contract ✅ Passed PR modifies only Ansible YAML configuration files, not Go code or test binaries subject to OTE Binary Stdout Contract requirements.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR modifies only Ansible playbook files for VM teardown logic. No Ginkgo e2e test files added or modified. Custom check for IPv4/IPv6 compatibility inapplicable to infrastructure changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
ansible/roles/create-vm/tasks/main.yml (1)

9-19: LGTM — teardown now correctly scoped to vm_name.

Single-VM targeting with the vm_name in (all_vms.list_vms | default([])) guard cleanly prevents collateral damage to other microshift-* VMs on the host and safely no-ops when the VM doesn't exist.

Optional nit: the identical when is duplicated across both tasks — wrapping them in a block: with a single when: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4ce2bef and 57520f6.

📒 Files selected for processing (1)
  • ansible/roles/create-vm/tasks/main.yml

@openshift-ci

openshift-ci Bot commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

@sjug: all tests passed!

Full PR test history. Your PR dashboard.

Details

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

@ggiguash

Copy link
Copy Markdown
Contributor

/lgtm
/verified by @sjug

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Apr 20, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@ggiguash: This PR has been marked as verified by @sjug.

Details

In response to this:

/lgtm
/verified by @sjug

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.

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Apr 20, 2026
@openshift-ci

openshift-ci Bot commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 20, 2026
@openshift-merge-bot openshift-merge-bot Bot merged commit fe29d2a into openshift:main Apr 20, 2026
7 checks passed
@sjug sjug deleted the perfscale-2110-scope-vm-teardown branch April 20, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants