Skip to content

Refactor node drain function, fix compact cluster drain race#5028

Merged
rnetser merged 1 commit into
RedHatQE:mainfrom
dshchedr:fix-compact-cluster-virt-api-race
Jun 18, 2026
Merged

Refactor node drain function, fix compact cluster drain race#5028
rnetser merged 1 commit into
RedHatQE:mainfrom
dshchedr:fix-compact-cluster-virt-api-race

Conversation

@dshchedr

@dshchedr dshchedr commented May 28, 2026

Copy link
Copy Markdown
Collaborator
What this PR does / why we need it:

Split node_mgmt_console() into cordon_node() and drain_node()
Fix the flakyness when executed on compact cluster

On compact clusters, draining a node with a virt-api pod can cause webhook timeouts during VM eviction (both virt-api and VM evicted simultaneously). Add logic to drain_node() to detect and relocate virt-api pods before draining: cordon the node, delete the pod (forces rescheduling while the other replica continues serving), then proceed with drain.

Co-Authored-By: Claude Sonnet 4.5

Summary by CodeRabbit

  • Chores
    • Refactored node-management to use explicit cordon and drain workflows for more reliable maintenance.
    • Improved handling for compact-cluster scenarios during drains to avoid disrupting critical pods.
    • Updated test fixtures and helpers to pass cluster context into cordon/drain workflows, improving stability of maintenance/migration tests.

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@dshchedr, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 47 minutes and 32 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5ef4ddf6-7629-4e8d-b78b-367f9617ae69

📥 Commits

Reviewing files that changed from the base of the PR and between 27f4595 and 3092913.

📒 Files selected for processing (6)
  • tests/chaos/oadp/conftest.py
  • tests/virt/cluster/migration_and_maintenance/test_evictionstrategy.py
  • tests/virt/node/migration_and_maintenance/test_node_maintenance.py
  • tests/virt/node/migration_and_maintenance/test_post_copy_migration.py
  • tests/virt/node/migration_and_maintenance/test_vm_unscheduled_node.py
  • utilities/virt.py
📝 Walkthrough

Walkthrough

This PR refactors node management orchestration by removing the polymorphic node_mgmt_console context manager and replacing it with two specialized helpers: cordon_node and drain_node. The new helpers accept cluster-context parameters to support compact-cluster virt-api pod relocation during node drain. Tests are updated accordingly.

Changes

Node Management Refactor

Layer / File(s) Summary
Core node management context managers
utilities/virt.py
Imports VIRT_API constant. Removes node_mgmt_console(admin_client, node, node_mgmt) and adds cordon_node(admin_client, node) (cordons via oc adm cordon, uncordons and waits for scheduler recovery on exit) and drain_node(admin_client, node, hco_namespace, compact_cluster=False) (drains via oc adm drain in background, terminates drain on exit; on compact clusters, detects virt-api pod on node, cordons, deletes that pod, then proceeds to drain).
Node maintenance test helpers and methods
tests/virt/node/migration_and_maintenance/test_node_maintenance.py
drain_using_console and drain_using_console_windows helpers now accept hco_namespace and compact_cluster, wrap the drain via drain_node, and call check_migration_process_after_node_drain to validate post-drain migration state. Test methods updated to accept and pass cluster-context parameters. Cordon operations switched from node_mgmt_console(..., node_mgmt="cordon") to cordon_node.
Test fixtures across eviction, post-copy, OADP, and scheduling
tests/virt/cluster/migration_and_maintenance/test_evictionstrategy.py, tests/virt/node/migration_and_maintenance/test_post_copy_migration.py, tests/chaos/oadp/conftest.py, tests/virt/node/migration_and_maintenance/test_vm_unscheduled_node.py
Fixtures and helpers updated to accept hco_namespace and compact_cluster parameters and use drain_node (evictionstrategy, post_copy_migration, OADP conftest) or cordon_node (vm_unscheduled_node) context managers in place of node_mgmt_console.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Suggested reviewers

  • akri3i
  • RoniKishner
  • geetikakay
  • rnetser
  • SamAlber
  • sarahbx
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main changes: refactoring node_mgmt_console into separate functions and fixing a compact cluster drain race condition.
Description check ✅ Passed The description covers the main objectives, explains the problem being solved, and provides implementation details. However, it's missing the jira-ticket section required by the template.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stp Link Required ✅ Passed Diff (parent 9b93b8d..HEAD 27f4595) shows only modified files (no new tests/*.py) and parsing added lines finds no new def test_... functions.

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

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

Warning

Review ran into problems

🔥 Problems

Linked repositories: Your configuration references 1 linked repositories, but your current plan allows 0. Analyzed ``, skipped RedHatQE/openshift-virtualization-tests-design-docs.


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.

@openshift-virtualization-qe-bot

Copy link
Copy Markdown

Report bugs in Issues

Welcome! 🎉

This pull request will be automatically processed with the following features:

🔄 Automatic Actions

  • Reviewer Assignment: Reviewers are automatically assigned based on the OWNERS file in the repository root
  • Size Labeling: PR size labels (XS, S, M, L, XL, XXL) are automatically applied based on changes
  • Issue Creation: A tracking issue is created for this PR and will be closed when the PR is merged or closed
  • Branch Labeling: Branch-specific labels are applied to track the target branch
  • Auto-verification: Auto-verified users have their PRs automatically marked as verified
  • Labels: Enabled categories: branch, can-be-merged, cherry-pick, has-conflicts, hold, needs-rebase, size, verified, wip

📋 Available Commands

PR Status Management

  • /wip - Mark PR as work in progress (adds WIP: prefix to title)
  • /wip cancel - Remove work in progress status
  • /hold - Block PR merging (approvers only)
  • /hold cancel - Unblock PR merging
  • /verified - Mark PR as verified
  • /verified cancel - Remove verification status
  • /reprocess - Trigger complete PR workflow reprocessing (useful if webhook failed or configuration changed)
  • /regenerate-welcome - Regenerate this welcome message

Review & Approval

  • /lgtm - Approve changes (looks good to me)
  • /approve - Approve PR (approvers only)
  • /assign-reviewers - Assign reviewers based on OWNERS file
  • /assign-reviewer @username - Assign specific reviewer
  • /check-can-merge - Check if PR meets merge requirements

Testing & Validation

  • /retest tox - Run Python test suite with tox
  • /retest build-container - Rebuild and test container image
  • /retest verify-bugs-are-open - verify-bugs-are-open
  • /retest all - Run all available tests

Container Operations

  • /build-and-push-container - Build and push container image (tagged with PR number)
    • Supports additional build arguments: /build-and-push-container --build-arg KEY=value

Cherry-pick Operations

  • /cherry-pick <branch> - Schedule cherry-pick to target branch when PR is merged
    • Multiple branches: /cherry-pick branch1 branch2 branch3

Label Management

  • /<label-name> - Add a label to the PR
  • /<label-name> cancel - Remove a label from the PR

✅ Merge Requirements

This PR will be automatically approved when the following conditions are met:

  1. Approval: /approve from at least one approver
  2. LGTM Count: Minimum 2 /lgtm from reviewers
  3. Status Checks: All required status checks must pass
  4. No Blockers: No wip, hold, has-conflicts labels and PR must be mergeable (no conflicts)
  5. Verified: PR must be marked as verified

📊 Review Process

Approvers and Reviewers

Approvers:

  • dshchedr
  • myakove
  • rnetser
  • vsibirsk

Reviewers:

  • RoniKishner
  • SamAlber
  • akri3i
  • dshchedr
  • geetikakay
  • rnetser
  • sarahbx
  • vsibirsk
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve
AI Features
  • Cherry-Pick Conflict Resolution: Enabled (claude/claude-opus-4-6[1m])

💡 Tips

  • WIP Status: Use /wip when your PR is not ready for review
  • Verification: The verified label is removed on new commits unless the push is detected as a clean rebase
  • Cherry-picking: Cherry-pick labels are processed when the PR is merged
  • Container Builds: Container images are automatically tagged with the PR number
  • Permission Levels: Some commands require approver permissions
  • Auto-verified Users: Certain users have automatic verification and merge privileges

For more information, please refer to the project documentation or contact the maintainers.

@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.65%. Comparing base (a2dc143) to head (3092913).
⚠️ Report is 128 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5028      +/-   ##
==========================================
- Coverage   98.67%   98.65%   -0.02%     
==========================================
  Files          25       25              
  Lines        2487     2461      -26     
==========================================
- Hits         2454     2428      -26     
  Misses         33       33              
Flag Coverage Δ
utilities 98.65% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
utilities/virt.py (1)

1-1: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

HIGH: PR template required sections are not verifiable from provided PR description format.

I can’t find the required template headers/content in the supplied PR description context (especially meaningful content under What this PR does / why we need it:). Please restore/confirm the full template sections.

As per coding guidelines: "**: Required sections from .github/pull_request_template.md must be present; missing/empty What this PR does / why we need it: is HIGH severity."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@utilities/virt.py` at line 1, The PR description is missing required template
sections (particularly the "What this PR does / why we need it:" header)
mandated by .github/pull_request_template.md; update the PR description to
restore all required headers and content exactly as in the template (including
any sections prefixed with "**" and the "What this PR does / why we need it:"
block) so the required fields are verifiable, and ensure the PR body contains
meaningful content under those headers before marking the PR ready.
tests/virt/node/migration_and_maintenance/test_post_copy_migration.py (1)

1-1: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

HIGH: Restore required PR template sections in the PR description.

The provided PR description content is missing the required template headings, and What this PR does / why we need it must be present with meaningful text.

Please restore:

  • ##### What this PR does / why we need it:
  • ##### Which issue(s) this PR fixes:
  • ##### Special notes for reviewer:
  • ##### jira-ticket:

As per coding guidelines: What this PR does / why we need it must be present with meaningful content, and all listed required PR template sections must be present.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/virt/node/migration_and_maintenance/test_post_copy_migration.py` at
line 1, The PR description is missing required template headings; restore the
following sections in the PR body with meaningful content: "##### What this PR
does / why we need it:" (describe the change and rationale), "##### Which
issue(s) this PR fixes:" (link issue IDs), "##### Special notes for reviewer:"
(any testing/impact notes), and "##### jira-ticket:" (provide the Jira ID);
ensure "What this PR does / why we need it" contains a clear, non-empty
explanation before marking the PR ready.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@utilities/virt.py`:
- Around line 2166-2168: The pkill call in the terminate path is too broad and
may kill other "oc adm drain" processes; instead, record and target the specific
drain process you started (e.g., capture the subprocess.Popen object or its PID
when launching the drain) and on termination send the signal only to that PID
(or use the stored Popen.terminate()/kill()). Update the code around the
run(shlex.split('pkill -f "oc adm drain"')) call to use the tracked process/PID
from the drain-start code (reference the subprocess launch where the drain is
started and the termination logic that currently calls run(...)) so only the
intended drain for node.name is stopped. Ensure fallback handling if the PID no
longer exists.
- Around line 2119-2124: The cordon_node and drain_node context managers
currently call subprocess.run(..., shell=True) (e.g., run(f"oc adm cordon
{node.name}", shell=True)) which bypasses the repo command wrapper and may
ignore failures; replace those calls with
pyhelper_utils.shell.run_command([...]) using an explicit argument list and
check=True so failures raise; for drain_node, instead of a global pkill -f "oc
adm drain" in the finally block, capture the specific drain process you start
(e.g., via subprocess.Popen or run_command that returns a handle) and
terminate/kill only that PID on cleanup, ensuring you still log with LOGGER and
handle errors from run_command accordingly.

---

Outside diff comments:
In `@tests/virt/node/migration_and_maintenance/test_post_copy_migration.py`:
- Line 1: The PR description is missing required template headings; restore the
following sections in the PR body with meaningful content: "##### What this PR
does / why we need it:" (describe the change and rationale), "##### Which
issue(s) this PR fixes:" (link issue IDs), "##### Special notes for reviewer:"
(any testing/impact notes), and "##### jira-ticket:" (provide the Jira ID);
ensure "What this PR does / why we need it" contains a clear, non-empty
explanation before marking the PR ready.

In `@utilities/virt.py`:
- Line 1: The PR description is missing required template sections (particularly
the "What this PR does / why we need it:" header) mandated by
.github/pull_request_template.md; update the PR description to restore all
required headers and content exactly as in the template (including any sections
prefixed with "**" and the "What this PR does / why we need it:" block) so the
required fields are verifiable, and ensure the PR body contains meaningful
content under those headers before marking the PR ready.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4b2225fe-031b-4981-b895-73a9176fcf84

📥 Commits

Reviewing files that changed from the base of the PR and between 871a310 and aac1211.

📒 Files selected for processing (6)
  • tests/chaos/oadp/conftest.py
  • tests/virt/cluster/migration_and_maintenance/test_evictionstrategy.py
  • tests/virt/node/migration_and_maintenance/test_node_maintenance.py
  • tests/virt/node/migration_and_maintenance/test_post_copy_migration.py
  • tests/virt/node/migration_and_maintenance/test_vm_unscheduled_node.py
  • utilities/virt.py

Comment thread utilities/virt.py Outdated
Comment thread utilities/virt.py Outdated

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
utilities/virt.py (1)

1628-1637: ⚠️ Potential issue | 🟠 Major

HIGH: Fix NODE_PORT ip_family parsing to use NodeAddress fields (type/address), not raw entries.

ServiceForVirtualMachineForTests.service_ip() iterates vm_node.instance.status.addresses, but Node status addresses are NodeAddress objects (with type + address). Passing each entry directly to ipaddress.ip_address(...) will fail/mis-filter, and return internal_ips[0] may not be an IP string. Filter type == "InternalIP" and pass node_address.address into ipaddress.ip_address(...).

Suggested fix
         if self.service_type == Service.Type.NODE_PORT:
             vm_node = self.vm.vmi.get_node(privileged_client=admin_client)
             if ip_family:
                 internal_ips = [
-                    internal_ip
-                    for internal_ip in vm_node.instance.status.addresses
-                    if str(ipaddress.ip_address(internal_ip).version) in ip_family
+                    node_address.address
+                    for node_address in vm_node.instance.status.addresses
+                    if node_address.type == "InternalIP"
+                    and str(ipaddress.ip_address(node_address.address).version) in ip_family
                 ]
                 assert internal_ips, f"No {ip_family} addresses in node {vm_node.name}"
                 return internal_ips[0]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@utilities/virt.py` around lines 1628 - 1637, In the NODE_PORT branch of
ServiceForVirtualMachineForTests.service_ip() (the block that checks
self.service_type == Service.Type.NODE_PORT and reads
vm_node.instance.status.addresses), you must treat each entry as a NodeAddress
object and not pass the raw entry to ipaddress.ip_address; instead filter
addresses where node_address.type == "InternalIP" (or the requested type), call
ipaddress.ip_address(node_address.address) to check the IP family, and return
node_address.address (a string) rather than the raw object; update the
comprehension/loop to use node_address.address for parsing and ensure an
assertion/error if no matching addresses are found.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@utilities/virt.py`:
- Around line 2182-2195: The current compact_cluster branch only deletes the
first matching virt-api pod (inside the loop over utilities.infra.get_pods) then
breaks, which leaves a second co-located replica to be evicted during drain;
instead, cordon the node once (use cordon_node(admin_client=admin_client,
node=node) outside or around the loop) and iterate over all pods from
utilities.infra.get_pods(filtering by Pod.ApiGroup.KUBEVIRT_IO and VIRT_API and
pod.node.name == node.name), calling pod.delete(wait=True) for each and logging
via LOGGER.info for each deletion; remove the break so all matching pods on that
node are deleted while cordoned before proceeding to drain.
- Around line 2148-2154: The _uncordon_and_stabilize function is currently
decorated with `@contextmanager` but lacks a yield so its uncordon/stabilize steps
never run when called directly from cordon_node()/drain_node(); fix this by
removing the `@contextmanager` decorator and keeping _uncordon_and_stabilize as a
normal function (so run_command(...), wait_for_node_schedulable_status(...), and
wait_for_kv_stabilize(...) execute when cordon_node()/drain_node() call it), or
alternatively implement a proper context manager by adding a yield and changing
callers to use "with _uncordon_and_stabilize(...):"—prefer removing the
decorator for the minimal change.

---

Outside diff comments:
In `@utilities/virt.py`:
- Around line 1628-1637: In the NODE_PORT branch of
ServiceForVirtualMachineForTests.service_ip() (the block that checks
self.service_type == Service.Type.NODE_PORT and reads
vm_node.instance.status.addresses), you must treat each entry as a NodeAddress
object and not pass the raw entry to ipaddress.ip_address; instead filter
addresses where node_address.type == "InternalIP" (or the requested type), call
ipaddress.ip_address(node_address.address) to check the IP family, and return
node_address.address (a string) rather than the raw object; update the
comprehension/loop to use node_address.address for parsing and ensure an
assertion/error if no matching addresses are found.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 91786c68-af80-4c0c-9a7d-2550cf7184f6

📥 Commits

Reviewing files that changed from the base of the PR and between aac1211 and 27f4595.

📒 Files selected for processing (6)
  • tests/chaos/oadp/conftest.py
  • tests/virt/cluster/migration_and_maintenance/test_evictionstrategy.py
  • tests/virt/node/migration_and_maintenance/test_node_maintenance.py
  • tests/virt/node/migration_and_maintenance/test_post_copy_migration.py
  • tests/virt/node/migration_and_maintenance/test_vm_unscheduled_node.py
  • utilities/virt.py

Comment thread utilities/virt.py Outdated
Comment thread utilities/virt.py Outdated
@dshchedr

Copy link
Copy Markdown
Collaborator Author

/build-and-push-container

@openshift-virtualization-qe-bot-2

Copy link
Copy Markdown
Contributor

New container for quay.io/openshift-cnv/openshift-virtualization-tests:pr-5028 published

@dshchedr

Copy link
Copy Markdown
Collaborator Author

/verified

@openshift-virtualization-qe-bot-3

Copy link
Copy Markdown
Contributor

@coderabbitai

Test execution plan request details

CRITICAL: You MUST post an inline review comment on the first changed line of the first file.
The inline comment should contain the full Test Execution Plan (smoke decision, gating decision, and specific affected tests).
Do NOT submit a blocking review event (REQUEST_CHANGES/APPROVE).
Post a single inline PR comment on Files Changed (non-blocking COMMENT flow).

As an expert software testing engineer, analyze all modified files in this PR and create a targeted test execution plan.
You will post an inline review comment with the test execution plan on the first changed file.
If you fail to run or post a comment, retry.

Analysis Requirements:

  1. Examine code changes in each modified file

  2. Identify affected code paths, functions, and classes

  3. Analyze pytest-specific elements: fixtures (scope, dependencies), parametrization, markers, conftest changes

  4. Trace test dependencies through imports, shared utilities, fixture inheritance, fixture teardown, and yield from cleanup in conftest

  5. Detect new tests introduced in the PR

  6. Utilities and libs impact (when utilities/ or libs/ changes):
    You MUST use shell scripts (rg, git diff) to trace the full impact.
    Follow these sub-steps in order:

    6a. Identify modified symbols: For each changed file under utilities/ or libs/,
    list every modified function or method.
    Example: git diff HEAD~1 --unified=0 -- utilities/hco.py | grep '^[+-]def '

    6b. Find direct callers: Search tests and conftest for each symbol from 6a.
    Example: rg -l 'get_hco_version' tests/

    6c. Trace fixture teardown and cleanup: Find fixtures that reach
    the modified symbol through yield from or context-manager wrappers.
    Example: rg -l 'yield from.*enable_common_boot|def.*enable_common_boot' tests/

    6d. Trace same-file callers: In each changed file, find other functions
    whose body calls a modified symbol (including code after yield
    in @contextmanager helpers).
    Example: rg 'get_hco_version|enable_common_boot' utilities/hco.py

    6e. Expand transitively: If function A calls modified B, then
    tests/fixtures that call A are affected — even when the test body
    never imports B directly.

    Do NOT limit impact to tests that import the modified symbol only.

  7. Smoke test impact: Intersect the affected set from step 6 with smoke-marked tests.
    Run: rg -l '@pytest.mark.smoke' tests/
    VERIFY the above command returned actual file paths before concluding False.
    Set True if either condition is met:

    • a smoke-marked file appears in the affected set from 6b-6e, OR
    • any conftest.py in the smoke test's parent-directory hierarchy (up to repo root)
      imports or calls a modified utilities/libs symbol — including autouse fixtures
      that depend on modified functions. ALL tests in that directory and below are affected.
      Example check: for each smoke_file, scan dirname(smoke_file)/conftest.py,
      dirname(dirname(smoke_file))/conftest.py, etc. for modified symbol imports
      and autouse fixtures that depend on modified symbols.
  8. Gating test impact: Intersect the affected set from step 6 with gating-marked tests.
    Run: rg -l '@pytest.mark.gating' tests/
    Set True if a gating-marked file also appears in the affected set from 6b-6e.
    Utilities/libs changes often affect gating tests without affecting smoke tests.
    Do NOT stop analysis after concluding Run smoke tests: False.

Output rules:
Do NOT include analysis step numbers (1-8) in your visible output.

Your deliverable:
Your inline informational comment will be based on the following requirements:

Test Execution Plan

  • Run smoke tests: True / False — If True, state the dependency path (test → fixture → changed symbol). True ONLY with a verified path.
  • Run gating tests: True / False — If True, state the dependency path. True if any gating-marked test is in the affected set.
  • Affected tests to run (required when utilities/, libs/, or shared conftest changes — list concrete paths even when smoke is False)

Use these formats:

  • path/to/test_file.py - When the entire test file needs verification
  • path/to/test_file.py::TestClass::test_method - When specific test(s) needed
  • path/to/test_file.py::test_function - When specific test(s) needed
  • -m marker - When a marker covers multiple affected tests (e.g. -m gating only if ALL gating tests in scope need run)
  • Tag each listed test or group with its marker when not obvious, e.g. (gating) or (smoke)

Real test commands (MANDATORY when changes affect session/runtime code):

When the affected code runs at session/collection time (conftest fixtures, pytest plugins,
config hooks, session-scoped setup) or modifies runtime behavior that unit tests mock away,
you MUST include concrete pytest commands the PR author must run on a real cluster
to verify the change works end-to-end. Include:

  • A command for the error/fix path (the scenario the PR fixes)
  • A command for the happy path (regression: the normal case still works)
  • Use lightweight tests (e.g., --collect-only for startup failures,
    a single small test for runtime behavior)
    If the PR only changes test logic (not utilities/libs/conftest), the affected test
    paths themselves serve as the real test commands — no separate section needed.

Example output for a session-startup fix:

**Real tests (cluster required)**
Error path (the fix):
`pytest tests/storage/.../test_foo.py --storage-class-matrix=nonexistent-sc --collect-only`
Expected: ValueError with clear message, not IndexError

Happy path (regression):
`pytest tests/storage/.../test_foo.py --storage-class-matrix=<valid-sc> -k test_bar`
Expected: session starts normally

Guidelines:

  • Include tests affected directly OR via fixture setup/teardown, yield from cleanup, or transitive utility call chains (caller calls modified helper)
  • Use a full file path only if ALL tests in that file require verification
  • Use file path + test name when only specific tests use an affected fixture or utility wrapper (preferred for partial file impact)
  • If a test marker can cover multiple files/tests, provide the marker
  • Balance coverage vs over-testing - Keep descriptions minimal
  • Example: if leaf helper foo() changes, include tests whose fixture teardown calls wrapper bar() where bar() calls foo(), even when the test body only imports an unrelated symbol from the same utilities module

Hardware-Related Checks (SR-IOV, GPU, DPDK):

When PR modifies fixtures for hardware-specific resources:

  • Collection Safety: Fixtures MUST have existence checks (return None when hardware unavailable)
  • Test Plan: MUST verify both WITH and WITHOUT hardware:
    • Run affected tests on cluster WITH hardware
    • Verify collection succeeds on cluster WITHOUT hardware

CRITICAL WORKFLOW COMPLETION RULES:

When responding to this test execution plan request, you MUST follow these rules EXACTLY:

  1. YOUR ONLY DELIVERABLE: Post one non-blocking inline comment containing the test execution plan on the first changed line
  2. THEN STOP IMMEDIATELY - Do NOT generate any additional response
  3. FALLBACK ONLY: If inline comment API calls fail after retrying, post as a regular PR comment
  4. SILENCE = SUCCESS: After successfully submitting the review, your task is complete. No confirmation needed.

ABSOLUTE PROHIBITIONS (violating these creates empty/meaningless reviews):

  • ❌ Do NOT post acknowledgment messages like "Test execution plan posted", "Review posted successfully", "I've successfully posted"
  • ❌ Do NOT mention review IDs, URLs, or confirmation of posting in the PR thread
  • ❌ Do NOT add any follow-up comments after submitting the review
  • ❌ Do NOT reply to confirm task completion
  • ❌ Do NOT explain what you did - just do it and stop

Remember: The pull request review is visible to users. Additional comments are redundant noise.

CRITICAL — Verification rules for smoke and gating decisions:
- For each True decision, you must have traced a concrete path: test file → fixture → utility function → modified symbol.
- Do NOT assume impact based on scope, file proximity, or infrastructure-sounding names.
Only set True when you trace a concrete path through steps 6a-6e, then 7 or 8.
WRONG: "utilities/hco.py changed → run smoke" (no traced dependency path)
WRONG: "Run smoke tests: False" with no affected-test list when gating tests use the changed utility
RIGHT: "Run smoke tests: False, Run gating tests: True" plus tests/.../test_foo.py::TestBar::test_baz (gating)
RIGHT: "Smoke test X uses fixture Y → wrapper Z → changed function W in utilities/hco.py"

Comment thread tests/chaos/oadp/conftest.py
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# 6a: Find modified symbols in utilities/virt.py
echo "=== Modified symbols in utilities/virt.py ==="
git diff HEAD~1 --unified=0 -- utilities/virt.py | grep '^[+-]def '

# 6b: Find callers of node_mgmt_console, cordon_node, drain_node in tests/ and conftest files
echo ""
echo "=== Callers of node_mgmt_console ==="
rg -rn 'node_mgmt_console' tests/ --include='*.py' -l

echo ""
echo "=== Callers of cordon_node ==="
rg -rn 'cordon_node' tests/ --include='*.py' -l

echo ""
echo "=== Callers of drain_node ==="
rg -rn 'drain_node' tests/ --include='*.py' -l

# 6d: Same-file callers in utilities/virt.py
echo ""
echo "=== Same-file callers in utilities/virt.py ==="
rg -n 'node_mgmt_console|cordon_node|drain_node|_uncordon_and_stabilize' utilities/virt.py

# 7: Smoke test files
echo ""
echo "=== Smoke marked test files ==="
rg -l '`@pytest.mark.smoke`' tests/

# 8: Gating test files
echo ""
echo "=== Gating marked test files ==="
rg -l '`@pytest.mark.gating`' tests/

Length of output: 6581


🏁 Script executed:

#!/bin/bash
# Get the list of files changed and their first diff lines for PR 5028
gh pr diff 5028 --repo RedHatQE/openshift-virtualization-tests | head -100

# Also get the PR commits for the review API
gh api repos/RedHatQE/openshift-virtualization-tests/pulls/5028 --jq '.head.sha'

Length of output: 5034


🏁 Script executed:

#!/bin/bash
# Post inline review comment on PR 5028 on the first changed line of tests/chaos/oadp/conftest.py
COMMIT_SHA="f86011644595739725dea2c33a8e387241df10fc"
PR_NUMBER=5028
REPO="RedHatQE/openshift-virtualization-tests"

BODY='**Test Execution Plan**

**Run smoke tests: False**
No smoke-marked test file has a traced dependency path through `drain_node`, `cordon_node`, or `_uncordon_and_stabilize`.

**Run gating tests: True**
- `tests/virt/node/migration_and_maintenance/test_vm_unscheduled_node.py` → `cordon_node` (gating): test file directly calls `cordon_node` from `utilities/virt.py`
- `tests/virt/cluster/migration_and_maintenance/test_evictionstrategy.py` → fixture `drained_node` → `drain_node` (gating): fixture uses `drain_node` from `utilities/virt.py`

**Affected tests to run**

| Test path | Reason |
|---|---|
| `tests/chaos/oadp/conftest.py` + callers | fixture `drain_vm_source_node` now uses `drain_node` |
| `tests/virt/cluster/migration_and_maintenance/test_evictionstrategy.py` | fixture `drained_node` → `drain_node` (gating) |
| `tests/virt/node/migration_and_maintenance/test_node_maintenance.py` | `drain_using_console` / `drain_using_console_windows` → `drain_node`; cordon steps → `cordon_node` |
| `tests/virt/node/migration_and_maintenance/test_post_copy_migration.py` | `drained_node_with_hotplugged_vm` → `drain_node` |
| `tests/virt/node/migration_and_maintenance/test_vm_unscheduled_node.py` | directly calls `cordon_node` (gating) |

**Real tests (cluster required)**

Error/fix path — compact cluster virt-api race (the scenario this PR fixes):

Length of output: 1901


🏁 Script executed:

#!/bin/bash
COMMIT_SHA="f86011644595739725dea2c33a8e387241df10fc"
PR_NUMBER=5028
REPO="RedHatQE/openshift-virtualization-tests"

# Write body to file to avoid quoting issues
cat > /tmp/review_body.md << 'ENDOFBODY'
**Test Execution Plan**

**Run smoke tests: False**
No smoke-marked test file has a traced dependency path through `drain_node`, `cordon_node`, or `_uncordon_and_stabilize`.

**Run gating tests: True**
- `tests/virt/node/migration_and_maintenance/test_vm_unscheduled_node.py` → `cordon_node` (gating): test file directly calls `cordon_node` from `utilities/virt.py`
- `tests/virt/cluster/migration_and_maintenance/test_evictionstrategy.py` → fixture `drained_node` → `drain_node` (gating): fixture uses `drain_node` from `utilities/virt.py`

**Affected tests to run**

| Test path | Reason |
|---|---|
| `tests/chaos/oadp/conftest.py` + callers | fixture `drain_vm_source_node` now uses `drain_node` |
| `tests/virt/cluster/migration_and_maintenance/test_evictionstrategy.py` | fixture `drained_node` → `drain_node` (gating) |
| `tests/virt/node/migration_and_maintenance/test_node_maintenance.py` | `drain_using_console` / `drain_using_console_windows` → `drain_node`; cordon steps → `cordon_node` |
| `tests/virt/node/migration_and_maintenance/test_post_copy_migration.py` | `drained_node_with_hotplugged_vm` → `drain_node` |
| `tests/virt/node/migration_and_maintenance/test_vm_unscheduled_node.py` | directly calls `cordon_node` (gating) |

**Real tests (cluster required)**

Error/fix path — compact cluster virt-api race (the scenario this PR fixes):

Length of output: 1914


🏁 Script executed:

#!/bin/bash
COMMIT_SHA="f86011644595739725dea2c33a8e387241df10fc"
PR_NUMBER=5028
REPO="RedHatQE/openshift-virtualization-tests"

python3 << 'PYEOF'
import json, subprocess

comment_body = (
    "**Test Execution Plan**\n\n"
    "**Run smoke tests: False**\n"
    "No smoke-marked test file has a traced dependency path through `drain_node`, `cordon_node`, or `_uncordon_and_stabilize`.\n\n"
    "**Run gating tests: True**\n"
    "- `tests/virt/node/migration_and_maintenance/test_vm_unscheduled_node.py` \u2192 `cordon_node` (gating): test file directly calls `cordon_node` from `utilities/virt.py`\n"
    "- `tests/virt/cluster/migration_and_maintenance/test_evictionstrategy.py` \u2192 fixture `drained_node` \u2192 `drain_node` (gating): fixture uses `drain_node` from `utilities/virt.py`\n\n"
    "**Affected tests to run**\n\n"
    "| Test path | Reason |\n"
    "|---|---|\n"
    "| `tests/chaos/oadp/conftest.py` + callers | fixture `drain_vm_source_node` now uses `drain_node` |\n"
    "| `tests/virt/cluster/migration_and_maintenance/test_evictionstrategy.py` | fixture `drained_node` -> `drain_node` (gating) |\n"
    "| `tests/virt/node/migration_and_maintenance/test_node_maintenance.py` | `drain_using_console` / `drain_using_console_windows` -> `drain_node`; cordon steps -> `cordon_node` |\n"
    "| `tests/virt/node/migration_and_maintenance/test_post_copy_migration.py` | `drained_node_with_hotplugged_vm` -> `drain_node` |\n"
    "| `tests/virt/node/migration_and_maintenance/test_vm_unscheduled_node.py` | directly calls `cordon_node` (gating) |\n\n"
    "**Real tests (cluster required)**\n\n"
    "Error/fix path \u2014 compact cluster virt-api race (the scenario this PR fixes):\n\n"
    "```\npytest tests/virt/node/migration_and_maintenance/test_node_maintenance.py --tc-config compact_cluster=true -k drain\n```\n\n"
    "Expected: no webhook timeout from concurrent virt-api/VM eviction; drain completes cleanly.\n\n"
    "Happy path (regression \u2014 standard cluster drain still works):\n\n"
    "```\npytest tests/virt/cluster/migration_and_maintenance/test_evictionstrategy.py tests/virt/node/migration_and_maintenance/test_node_maintenance.py tests/virt/node/migration_and_maintenance/test_post_copy_migration.py tests/virt/node/migration_and_maintenance/test_vm_unscheduled_node.py\n```\n\n"
    "Expected: all node-drain and cordon tests pass on non-compact cluster without regression."
)

payload = {
    "commit_id": "f86011644595739725dea2c33a8e387241df10fc",
    "body": "",
    "event": "COMMENT",
    "comments": [
        {
            "path": "tests/chaos/oadp/conftest.py",
            "line": 22,
            "side": "RIGHT",
            "body": comment_body
        }
    ]
}

with open("/tmp/review_payload.json", "w") as f:
    json.dump(payload, f)

result = subprocess.run(
    ["gh", "api", "--method", "POST",
     "-H", "Accept: application/vnd.github+json",
     "/repos/RedHatQE/openshift-virtualization-tests/pulls/5028/reviews",
     "--input", "/tmp/review_payload.json",
     "--jq", ".id, .html_url"],
    capture_output=True, text=True
)
print("STDOUT:", result.stdout)
print("STDERR:", result.stderr)
print("RC:", result.returncode)
PYEOF

Length of output: 3380



@SamAlber

Copy link
Copy Markdown
Contributor

/lgtm

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 12, 2026
Comment thread utilities/virt.py Outdated
Comment thread utilities/virt.py Outdated
Comment thread utilities/virt.py
Split node_mgmt_console() into cordon_node() and drain_node().

On compact clusters, draining a node with a virt-api pod can cause webhook
timeouts during VM eviction (both virt-api and VM evicted simultaneously).
Add logic to drain_node() to detect and relocate virt-api pods before
draining: cordon the node, delete the pod (forces rescheduling while the
other replica continues serving), then proceed with drain.

Co-Authored-By: Claude Sonnet 4.5
Signed-off-by: Denys Shchedrivyi <dshchedr@redhat.com>
@dshchedr

Copy link
Copy Markdown
Collaborator Author

/build-and-push-container

@openshift-virtualization-qe-bot-2

Copy link
Copy Markdown
Contributor

New container for quay.io/openshift-cnv/openshift-virtualization-tests:pr-5028 published

@dshchedr

Copy link
Copy Markdown
Collaborator Author

/verified

@openshift-virtualization-qe-bot-3

Copy link
Copy Markdown
Contributor

@coderabbitai

Test execution plan request details

CRITICAL: You MUST post an inline review comment on the first changed line of the first file.
The inline comment should contain the full Test Execution Plan (smoke decision, gating decision, and specific affected tests).
Do NOT submit a blocking review event (REQUEST_CHANGES/APPROVE).
Post a single inline PR comment on Files Changed (non-blocking COMMENT flow).

As an expert software testing engineer, analyze all modified files in this PR and create a targeted test execution plan.
You will post an inline review comment with the test execution plan on the first changed file.
If you fail to run or post a comment, retry.

Analysis Requirements:

  1. Examine code changes in each modified file

  2. Identify affected code paths, functions, and classes

  3. Analyze pytest-specific elements: fixtures (scope, dependencies), parametrization, markers, conftest changes

  4. Trace test dependencies through imports, shared utilities, fixture inheritance, fixture teardown, and yield from cleanup in conftest

  5. Detect new tests introduced in the PR

  6. Utilities and libs impact (when utilities/ or libs/ changes):
    You MUST use shell scripts (rg, git diff) to trace the full impact.
    Follow these sub-steps in order:

    6a. Identify modified symbols: For each changed file under utilities/ or libs/,
    list every modified function or method.
    Example: git diff HEAD~1 --unified=0 -- utilities/hco.py | grep '^[+-]def '

    6b. Find direct callers: Search tests and conftest for each symbol from 6a.
    Example: rg -l 'get_hco_version' tests/

    6c. Trace fixture teardown and cleanup: Find fixtures that reach
    the modified symbol through yield from or context-manager wrappers.
    Example: rg -l 'yield from.*enable_common_boot|def.*enable_common_boot' tests/

    6d. Trace same-file callers: In each changed file, find other functions
    whose body calls a modified symbol (including code after yield
    in @contextmanager helpers).
    Example: rg 'get_hco_version|enable_common_boot' utilities/hco.py

    6e. Expand transitively: If function A calls modified B, then
    tests/fixtures that call A are affected — even when the test body
    never imports B directly.

    Do NOT limit impact to tests that import the modified symbol only.

  7. Smoke test impact: Intersect the affected set from step 6 with smoke-marked tests.
    Run: rg -l '@pytest.mark.smoke' tests/
    VERIFY the above command returned actual file paths before concluding False.
    Set True if either condition is met:

    • a smoke-marked file appears in the affected set from 6b-6e, OR
    • any conftest.py in the smoke test's parent-directory hierarchy (up to repo root)
      imports or calls a modified utilities/libs symbol — including autouse fixtures
      that depend on modified functions. ALL tests in that directory and below are affected.
      Example check: for each smoke_file, scan dirname(smoke_file)/conftest.py,
      dirname(dirname(smoke_file))/conftest.py, etc. for modified symbol imports
      and autouse fixtures that depend on modified symbols.
  8. Gating test impact: Intersect the affected set from step 6 with gating-marked tests.
    Run: rg -l '@pytest.mark.gating' tests/
    Set True if a gating-marked file also appears in the affected set from 6b-6e.
    Utilities/libs changes often affect gating tests without affecting smoke tests.
    Do NOT stop analysis after concluding Run smoke tests: False.

Output rules:
Do NOT include analysis step numbers (1-8) in your visible output.

Your deliverable:
Your inline informational comment will be based on the following requirements:

Test Execution Plan

  • Run smoke tests: True / False — If True, state the dependency path (test → fixture → changed symbol). True ONLY with a verified path.
  • Run gating tests: True / False — If True, state the dependency path. True if any gating-marked test is in the affected set.
  • Affected tests to run (required when utilities/, libs/, or shared conftest changes — list concrete paths even when smoke is False)

Use these formats:

  • path/to/test_file.py - When the entire test file needs verification
  • path/to/test_file.py::TestClass::test_method - When specific test(s) needed
  • path/to/test_file.py::test_function - When specific test(s) needed
  • -m marker - When a marker covers multiple affected tests (e.g. -m gating only if ALL gating tests in scope need run)
  • Tag each listed test or group with its marker when not obvious, e.g. (gating) or (smoke)

Real test commands (MANDATORY when changes affect session/runtime code):

When the affected code runs at session/collection time (conftest fixtures, pytest plugins,
config hooks, session-scoped setup) or modifies runtime behavior that unit tests mock away,
you MUST include concrete pytest commands the PR author must run on a real cluster
to verify the change works end-to-end. Include:

  • A command for the error/fix path (the scenario the PR fixes)
  • A command for the happy path (regression: the normal case still works)
  • Use lightweight tests (e.g., --collect-only for startup failures,
    a single small test for runtime behavior)
    If the PR only changes test logic (not utilities/libs/conftest), the affected test
    paths themselves serve as the real test commands — no separate section needed.

Example output for a session-startup fix:

**Real tests (cluster required)**
Error path (the fix):
`pytest tests/storage/.../test_foo.py --storage-class-matrix=nonexistent-sc --collect-only`
Expected: ValueError with clear message, not IndexError

Happy path (regression):
`pytest tests/storage/.../test_foo.py --storage-class-matrix=<valid-sc> -k test_bar`
Expected: session starts normally

Guidelines:

  • Include tests affected directly OR via fixture setup/teardown, yield from cleanup, or transitive utility call chains (caller calls modified helper)
  • Use a full file path only if ALL tests in that file require verification
  • Use file path + test name when only specific tests use an affected fixture or utility wrapper (preferred for partial file impact)
  • If a test marker can cover multiple files/tests, provide the marker
  • Balance coverage vs over-testing - Keep descriptions minimal
  • Example: if leaf helper foo() changes, include tests whose fixture teardown calls wrapper bar() where bar() calls foo(), even when the test body only imports an unrelated symbol from the same utilities module

Hardware-Related Checks (SR-IOV, GPU, DPDK):

When PR modifies fixtures for hardware-specific resources:

  • Collection Safety: Fixtures MUST have existence checks (return None when hardware unavailable)
  • Test Plan: MUST verify both WITH and WITHOUT hardware:
    • Run affected tests on cluster WITH hardware
    • Verify collection succeeds on cluster WITHOUT hardware

CRITICAL WORKFLOW COMPLETION RULES:

When responding to this test execution plan request, you MUST follow these rules EXACTLY:

  1. YOUR ONLY DELIVERABLE: Post one non-blocking inline comment containing the test execution plan on the first changed line
  2. THEN STOP IMMEDIATELY - Do NOT generate any additional response
  3. FALLBACK ONLY: If inline comment API calls fail after retrying, post as a regular PR comment
  4. SILENCE = SUCCESS: After successfully submitting the review, your task is complete. No confirmation needed.

ABSOLUTE PROHIBITIONS (violating these creates empty/meaningless reviews):

  • ❌ Do NOT post acknowledgment messages like "Test execution plan posted", "Review posted successfully", "I've successfully posted"
  • ❌ Do NOT mention review IDs, URLs, or confirmation of posting in the PR thread
  • ❌ Do NOT add any follow-up comments after submitting the review
  • ❌ Do NOT reply to confirm task completion
  • ❌ Do NOT explain what you did - just do it and stop

Remember: The pull request review is visible to users. Additional comments are redundant noise.

CRITICAL — Verification rules for smoke and gating decisions:
- For each True decision, you must have traced a concrete path: test file → fixture → utility function → modified symbol.
- Do NOT assume impact based on scope, file proximity, or infrastructure-sounding names.
Only set True when you trace a concrete path through steps 6a-6e, then 7 or 8.
WRONG: "utilities/hco.py changed → run smoke" (no traced dependency path)
WRONG: "Run smoke tests: False" with no affected-test list when gating tests use the changed utility
RIGHT: "Run smoke tests: False, Run gating tests: True" plus tests/.../test_foo.py::TestBar::test_baz (gating)
RIGHT: "Smoke test X uses fixture Y → wrapper Z → changed function W in utilities/hco.py"

Comment thread tests/chaos/oadp/conftest.py
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Get current PR head SHA and diff info
echo "=== Current head SHA ==="
gh api repos/RedHatQE/openshift-virtualization-tests/pulls/5028 --jq '.head.sha'

echo ""
echo "=== First changed file and lines ==="
gh pr diff 5028 --repo RedHatQE/openshift-virtualization-tests | head -50

echo ""
echo "=== Modified symbols in utilities/virt.py ==="
git diff HEAD~1 --unified=0 -- utilities/virt.py | grep '^[+-]def ' || true

echo ""
echo "=== Callers of cordon_node in tests ==="
rg -rn 'cordon_node' tests/ --include='*.py' -l

echo ""
echo "=== Callers of drain_node in tests ==="
rg -rn 'drain_node' tests/ --include='*.py' -l

echo ""
echo "=== Gating marked test files ==="
rg -l '`@pytest.mark.gating`' tests/

echo ""
echo "=== Smoke marked test files ==="
rg -l '`@pytest.mark.smoke`' tests/

echo ""
echo "=== Check if affected files have gating marks ==="
rg '`@pytest.mark.gating`' tests/virt/node/migration_and_maintenance/test_vm_unscheduled_node.py tests/virt/cluster/migration_and_maintenance/test_evictionstrategy.py tests/virt/node/migration_and_maintenance/test_node_maintenance.py tests/virt/node/migration_and_maintenance/test_post_copy_migration.py tests/chaos/oadp/conftest.py || true

echo ""
echo "=== Check if affected files have smoke marks ==="
rg '`@pytest.mark.smoke`' tests/virt/node/migration_and_maintenance/test_vm_unscheduled_node.py tests/virt/cluster/migration_and_maintenance/test_evictionstrategy.py tests/virt/node/migration_and_maintenance/test_node_maintenance.py tests/virt/node/migration_and_maintenance/test_post_copy_migration.py tests/chaos/oadp/conftest.py || true

Length of output: 4348


🏁 Script executed:

#!/bin/bash
# Get gating and smoke info, then post inline review

echo "=== Gating marks in affected files ==="
rg -n '`@pytest.mark.gating`' \
  tests/virt/node/migration_and_maintenance/test_vm_unscheduled_node.py \
  tests/virt/cluster/migration_and_maintenance/test_evictionstrategy.py \
  tests/virt/node/migration_and_maintenance/test_node_maintenance.py \
  tests/virt/node/migration_and_maintenance/test_post_copy_migration.py 2>/dev/null || echo "(none found)"

echo ""
echo "=== Smoke marks in affected files ==="
rg -n '`@pytest.mark.smoke`' \
  tests/virt/node/migration_and_maintenance/test_vm_unscheduled_node.py \
  tests/virt/cluster/migration_and_maintenance/test_evictionstrategy.py \
  tests/virt/node/migration_and_maintenance/test_node_maintenance.py \
  tests/virt/node/migration_and_maintenance/test_post_copy_migration.py 2>/dev/null || echo "(none found)"

echo ""
echo "=== All callers of drain_node ==="
rg -rn 'drain_node' tests/ --include='*.py' -l 2>/dev/null || echo "(none)"

echo ""
echo "=== All callers of cordon_node ==="
rg -rn 'cordon_node' tests/ --include='*.py' -l 2>/dev/null || echo "(none)"

echo ""
echo "=== Smoke test files in repo ==="
rg -l '`@pytest.mark.smoke`' tests/ 2>/dev/null | head -20

echo ""
echo "=== Gating test files in repo ==="
rg -l '`@pytest.mark.gating`' tests/ 2>/dev/null | head -20

Length of output: 3362


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 << 'PYEOF'
import json
import subprocess

COMMIT_SHA = "3092913480940b2b40212ec576d2690d1a6dc6cf"

comment_body = """\
**Test Execution Plan**

**Run smoke tests: False**
No traced path from any smoke-marked test file → fixture → `drain_node`/`cordon_node`/`_uncordon_and_stabilize` in `utilities/virt.py`. Smoke files (`test_rhel_os_support.py`, `test_container_disk_vm.py`, etc.) have no fixture dependency on the changed symbols.

**Run gating tests: True**
- `tests/virt/cluster/migration_and_maintenance/test_evictionstrategy.py` → fixture `drained_node` → `drain_node` (`utilities/virt.py`) — `@pytest.mark.gating` at line 104
- `tests/virt/node/migration_and_maintenance/test_vm_unscheduled_node.py` → directly calls `cordon_node` (`utilities/virt.py`) — `@pytest.mark.gating` at line 31

**Affected tests to run**

| Test path | Marker | Reason |
|---|---|---|
| `tests/virt/cluster/migration_and_maintenance/test_evictionstrategy.py` | gating | fixture `drained_node` → `drain_node` |
| `tests/virt/node/migration_and_maintenance/test_vm_unscheduled_node.py` | gating | directly calls `cordon_node` |
| `tests/virt/node/migration_and_maintenance/test_node_maintenance.py` | — | `drain_using_console`/`drain_using_console_windows` → `drain_node`; cordon steps → `cordon_node` |
| `tests/virt/node/migration_and_maintenance/test_post_copy_migration.py` | — | `drained_node_with_hotplugged_vm` → `drain_node` |
| `tests/chaos/oadp/conftest.py` + tests under `tests/chaos/oadp/` | — | fixture `drain_vm_source_node` → `drain_node` |

**Real tests (cluster required)**

Error/fix path — compact cluster virt-api race (the scenario this PR fixes):

Length of output: 2174


🏁 Script executed:

#!/bin/bash
set -euo pipefail

cat > /tmp/post_review.py << 'EOF'
import json
import subprocess

COMMIT_SHA = "3092913480940b2b40212ec576d2690d1a6dc6cf"

comment_body = (
    "**Test Execution Plan**\n\n"
    "**Run smoke tests: False**\n"
    "No traced path from any smoke-marked test file to fixture to `drain_node`/`cordon_node`/`_uncordon_and_stabilize` "
    "in `utilities/virt.py`. Smoke files (`test_rhel_os_support.py`, `test_container_disk_vm.py`, etc.) "
    "have no fixture dependency on the changed symbols.\n\n"
    "**Run gating tests: True**\n"
    "- `tests/virt/cluster/migration_and_maintenance/test_evictionstrategy.py` \u2192 fixture `drained_node` "
    "\u2192 `drain_node` (`utilities/virt.py`) \u2014 `@pytest.mark.gating` at line 104\n"
    "- `tests/virt/node/migration_and_maintenance/test_vm_unscheduled_node.py` \u2192 directly calls "
    "`cordon_node` (`utilities/virt.py`) \u2014 `@pytest.mark.gating` at line 31\n\n"
    "**Affected tests to run**\n\n"
    "| Test path | Marker | Reason |\n"
    "|---|---|---|\n"
    "| `tests/virt/cluster/migration_and_maintenance/test_evictionstrategy.py` | gating | fixture `drained_node` \u2192 `drain_node` |\n"
    "| `tests/virt/node/migration_and_maintenance/test_vm_unscheduled_node.py` | gating | directly calls `cordon_node` |\n"
    "| `tests/virt/node/migration_and_maintenance/test_node_maintenance.py` | \u2014 | `drain_using_console`/`drain_using_console_windows` \u2192 `drain_node`; cordon steps \u2192 `cordon_node` |\n"
    "| `tests/virt/node/migration_and_maintenance/test_post_copy_migration.py` | \u2014 | `drained_node_with_hotplugged_vm` \u2192 `drain_node` |\n"
    "| `tests/chaos/oadp/conftest.py` + tests under `tests/chaos/oadp/` | \u2014 | fixture `drain_vm_source_node` \u2192 `drain_node` |\n\n"
    "**Real tests (cluster required)**\n\n"
    "Error/fix path \u2014 compact cluster virt-api race (the scenario this PR fixes):\n\n"
    "```\npytest tests/virt/node/migration_and_maintenance/test_node_maintenance.py -k drain --tc-config compact_cluster=true\n```\n\n"
    "Expected: drain completes without webhook timeout from concurrent virt-api/VM eviction; "
    "virt-api pod is relocated before drain begins.\n\n"
    "Happy path (regression \u2014 standard cluster drain still works):\n\n"
    "```\npytest tests/virt/cluster/migration_and_maintenance/test_evictionstrategy.py "
    "tests/virt/node/migration_and_maintenance/test_node_maintenance.py "
    "tests/virt/node/migration_and_maintenance/test_post_copy_migration.py "
    "tests/virt/node/migration_and_maintenance/test_vm_unscheduled_node.py\n```\n\n"
    "Expected: all node-drain and cordon tests pass on non-compact cluster without regression."
)

payload = {
    "commit_id": COMMIT_SHA,
    "body": "",
    "event": "COMMENT",
    "comments": [
        {
            "path": "tests/chaos/oadp/conftest.py",
            "line": 22,
            "side": "RIGHT",
            "body": comment_body
        }
    ]
}

with open("/tmp/review_payload.json", "w") as f:
    json.dump(payload, f)

result = subprocess.run(
    [
        "gh", "api", "--method", "POST",
        "-H", "Accept: application/vnd.github+json",
        "/repos/RedHatQE/openshift-virtualization-tests/pulls/5028/reviews",
        "--input", "/tmp/review_payload.json",
        "--jq", ".id, .html_url, .state"
    ],
    capture_output=True, text=True
)
print("STDOUT:", result.stdout)
print("STDERR:", result.stderr)
print("RC:", result.returncode)
EOF

python3 /tmp/post_review.py

Length of output: 3722



@openshift-virtualization-qe-bot-3

Copy link
Copy Markdown
Contributor

/retest all

Auto-triggered: Files in this PR were modified by merged PR #4873.

Overlapping files

utilities/virt.py

@rnetser rnetser left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

/approve
/lgtm

@vsibirsk

Copy link
Copy Markdown
Collaborator

/approve

@openshift-virtualization-qe-bot-3

Copy link
Copy Markdown
Contributor

/retest all

Auto-triggered: Files in this PR were modified by merged PR #5219.

Overlapping files

utilities/virt.py

@dshchedr

Copy link
Copy Markdown
Collaborator Author

/retest verify-bugs-are-open

@dshchedr

Copy link
Copy Markdown
Collaborator Author

/check-can-merge

@rnetser rnetser left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

/approve
/lgtm

@rnetser

rnetser commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

/lgtm

@openshift-virtualization-qe-bot-6

Copy link
Copy Markdown

Successfully removed PR tag: quay.io/openshift-cnv/openshift-virtualization-tests:pr-5028.

@openshift-virtualization-qe-bot-6

Copy link
Copy Markdown

New container for quay.io/openshift-cnv/openshift-virtualization-tests:latest published

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants