Skip to content

Obs metrics nad swap vnic info#5222

Closed
OhadRevah wants to merge 8 commits into
RedHatQE:mainfrom
OhadRevah:obs-metrics-nad-swap-vnic-info
Closed

Obs metrics nad swap vnic info#5222
OhadRevah wants to merge 8 commits into
RedHatQE:mainfrom
OhadRevah:obs-metrics-nad-swap-vnic-info

Conversation

@OhadRevah

@OhadRevah OhadRevah commented Jun 15, 2026

Copy link
Copy Markdown
Contributor
What this PR does / why we need it:
Which issue(s) this PR fixes:
Special notes for reviewer:
jira-ticket:

Summary by CodeRabbit

  • New Features

    • Enhanced virtual machine network attachment definition reference updates with automatic migration handling.
    • Added L2 bridge network configuration support with VLAN management.
  • Improvements

    • Reorganized network utility imports and fixtures for better maintainability.
    • Strengthened network condition monitoring during VM migrations.

azhivovk and others added 8 commits May 31, 2026 12:42
These modules have no dependency on test-specific code.
Moving them to libs/net/ makes them importable from any test suite
without cross-package imports.

Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Asia Khromov <azhivovk@redhat.com>
Add cluster_vlan_iterator() to libs/net/cluster.py.
The underlying VLAN list is read from py_config once via a cached
helper; each call returns a fresh generator so every fixture
invocation starts from the beginning.

Add next_vlan_index_number fixture to tests/conftest.py using this
helper so any test suite can allocate cluster VLANs without
cross-package imports.

Network tests continue to use their own fixture in
tests/network/conftest.py and will be adjusted in a follow-up.

Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Asia Khromov <azhivovk@redhat.com>
Wait condition helpers use vm.vmi which exists on both
BaseVirtualMachine and VirtualMachineForTests.
Widen the type to VirtualMachine so any subclass can be passed
without a type error.

Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Asia Khromov <azhivovk@redhat.com>
Implement test_metric_kubevirt_vm_vnic_info_after_nad_swap to verify
that kubevirt_vm_vnic_info and kubevirt_vmi_vnic_info metric labels
update correctly after swapping the VM secondary network NAD reference
and completing the triggered live migration.

Signed-off-by: Ohad <orevah@redhat.com>
Assisted-by: claude code claude-opus-4-6
- Use BaseVirtualMachine via base_vmspec/fedora_vm for vm_for_nad_swap_test
- Reuse update_nad_references from tests/utils.py in post_nad_swap_vm
- Fix validate_vnic_info to poll until metric matches expected values
  instead of breaking on the first (possibly stale) result
- Fix import style per AGENTS.md (from libs.net import ... as libnncp)
- Restore original STD steps in test docstring

Signed-off-by: Ohad <orevah@redhat.com>
Assisted-by: claude code claude-opus-4-6
Move update_nad_references to libs/net/vmspec.py to eliminate identical
copies in tests/utils.py and tests/network/l2_bridge/nad_ref_change/lib_helpers.py.
The function is used by both network and observability team directories,
so it belongs in a shared module per project conventions.

assisted by: claude code claude-opus-4-6
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Signed-off-by: Ohad <orevah@redhat.com>
Signed-off-by: Ohad <orevah@redhat.com>
Move update_nad_references to libs/net/vmspec.py to eliminate identical
copies in tests/utils.py, tests/network/l2_bridge/nad_ref_change/lib_helpers.py,
and tests/network/libs/nad_ref.py. The function is used across network and
observability team directories, so it belongs in a shared module.
Also adds fail-fast validation: raises ValueError for missing networks,
non-Multus networks, and unmatched interface names.

assisted by: claude code claude-opus-4-6
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Signed-off-by: Ohad <orevah@redhat.com>
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@OhadRevah OhadRevah closed this Jun 15, 2026
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 23e7d2f3-9da6-4022-833d-ef235cfbeecd

📥 Commits

Reviewing files that changed from the base of the PR and between eee54e9 and 30dbdcd.

📒 Files selected for processing (23)
  • libs/net/apimachinery.py
  • libs/net/nodenetworkconfigurationpolicy.py
  • libs/net/vmspec.py
  • tests/conftest.py
  • tests/network/bgp/conftest.py
  • tests/network/conftest.py
  • tests/network/l2_bridge/bandwidth/conftest.py
  • tests/network/l2_bridge/conftest.py
  • tests/network/l2_bridge/migration_stuntime/conftest.py
  • tests/network/l2_bridge/nad_ref_change/conftest.py
  • tests/network/l2_bridge/nad_ref_change/test_nad_ref_change.py
  • tests/network/libs/cloudinit.py
  • tests/network/libs/cluster_user_defined_network.py
  • tests/network/libs/nad_ref.py
  • tests/network/localnet/conftest.py
  • tests/network/localnet/ipam/conftest.py
  • tests/network/localnet/liblocalnet.py
  • tests/network/localnet/nad_ref_change/test_nad_ref_change.py
  • tests/network/utils.py
  • tests/observability/metrics/conftest.py
  • tests/observability/metrics/test_vms_metrics.py
  • tests/observability/metrics/utils.py
  • tests/utils.py

📝 Walkthrough

Walkthrough

Helpers previously scattered across tests/network/libs/ are promoted into libs/net/: update_nad_references moves into libs/net/vmspec.py and get_vlan_index_number moves into tests/utils.py. The bridge_nncp, bridge_nad_a, and bridge_nad_b fixtures are consolidated into the top-level tests/conftest.py. The observability vNIC metric test gains a full NAD-swap fixture chain and validate_vnic_info is rewritten to poll.

Changes

Promote helpers to libs.net and wire NAD-swap observability test

Layer / File(s) Summary
Core helper promotion: update_nad_references and VLAN generator
libs/net/vmspec.py, tests/utils.py, tests/network/utils.py
update_nad_references is added to libs/net/vmspec.py with deepcopy, Multus networkName patching, and MigrationRequired condition waiting. get_vlan_index_number moves from tests/network/utils.py into tests/utils.py. The old implementations are deleted.
Import retargeting across tests.network.libs consumers
libs/net/nodenetworkconfigurationpolicy.py, tests/network/libs/cloudinit.py, tests/network/libs/cluster_user_defined_network.py, tests/network/bgp/conftest.py, tests/network/l2_bridge/bandwidth/conftest.py, tests/network/l2_bridge/conftest.py, tests/network/l2_bridge/migration_stuntime/conftest.py, tests/network/localnet/conftest.py, tests/network/localnet/ipam/conftest.py, tests/network/localnet/liblocalnet.py, tests/network/l2_bridge/nad_ref_change/test_nad_ref_change.py, tests/network/localnet/nad_ref_change/test_nad_ref_change.py
All consumers of tests.network.libs.nodenetworkconfigurationpolicy, tests.network.libs.apimachinery, and tests.network.libs.nad_ref are redirected to libs.net.*.
Consolidate bridge/VLAN fixtures into top-level conftest
tests/conftest.py, tests/network/conftest.py, tests/network/l2_bridge/conftest.py, tests/network/l2_bridge/nad_ref_change/conftest.py
bridge_nncp, vlans_list, vlan_index_number, bridge_nad_a, and bridge_nad_b are added to tests/conftest.py; their duplicate definitions are removed from the network sub-conftests.
NAD-swap observability metric test and polling validate_vnic_info
tests/observability/metrics/conftest.py, tests/observability/metrics/test_vms_metrics.py, tests/observability/metrics/utils.py
vm_for_nad_swap_test, post_nad_swap_vm, and expected_vnic_info_after_swap fixtures are added; test_metric_kubevirt_vm_vnic_info_after_nad_swap is wired to use them; validate_vnic_info is changed from a single fetch + assert to a per-sample polling loop that returns on match.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • vsibirsk
  • rnetser
  • EdDev
  • orelmisan
✨ 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.

@OhadRevah OhadRevah deleted the obs-metrics-nad-swap-vnic-info branch June 15, 2026 08:02
@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
  • /security-override - Set security check runs to pass (maintainers only)
  • /security-override cancel - Re-run security checks

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
  • /cherry-pick-retry <branch> - Retry a failed cherry-pick (merged PRs only)

Branch Management

  • /rebase - Rebase this PR branch onto its base branch

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:

  • EdDev
  • dshchedr
  • myakove
  • rnetser
  • vsibirsk

Reviewers:

  • Anatw
  • EdDev
  • OhadRevah
  • RoniKishner
  • albarker-rh
  • azhivovk
  • dshchedr
  • frenzyfriday
  • hmeir
  • nirdothan
  • orelmisan
  • rlobillo
  • rnetser
  • servolkov
  • vsibirsk
  • yossisegev
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve
AI Features
  • Cherry-Pick Conflict Resolution: Enabled (claude/claude-opus-4-6[1m])
Security Checks
  • Suspicious Path Detection: Monitors paths: .claude/, .vscode/, .cursor/, .devcontainer/, .pi/, .github/workflows/, .github/actions/
  • Committer Identity Check: Verifies last committer matches PR author
  • Mandatory: Security checks block merge (use /security-override to bypass — maintainers only)

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

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.

3 participants