Skip to content

Fix VM preference resolution in downward metrics fixture#4016

Open
aditi-sharma-1 wants to merge 1 commit intoRedHatQE:mainfrom
aditi-sharma-1:s390x-downward-metrics-preference
Open

Fix VM preference resolution in downward metrics fixture#4016
aditi-sharma-1 wants to merge 1 commit intoRedHatQE:mainfrom
aditi-sharma-1:s390x-downward-metrics-preference

Conversation

@aditi-sharma-1
Copy link
Contributor

@aditi-sharma-1 aditi-sharma-1 commented Mar 1, 2026

This change updates the preferred_preference_for_rhel_version fixture. When the cluster architecture is s390x, it checks for an architecture-specific VirtualMachineClusterPreference (for example, rhel.9.s390x). If the architecture preference does not exist (for example, rhel.8 on s390x), the logic falls back to the base preference (rhel.8).

Behavior for other architectures remains unchanged.

Short description:
More details:
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

    • Added support for S390X architecture-specific virtual machine preferences with custom naming conventions.
  • Tests

    • Enhanced test coverage for architecture-specific preference resolution logic.

This change updates the preferred_preference_for_rhel_version fixture.
When the cluster architecture is s390x, it checks for an architecture-specific
VirtualMachineClusterPreference (for example, rhel.9.s390x).
If the architecture preference does not exist (for example,
rhel.8 on s390x), the logic falls back to the base preference(rhel.8).

Behavior for other architectures remains unchanged.

Signed-off-by: Aditi Sharma <Aditi.Sharma@ibm.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 1, 2026

📝 Walkthrough

Walkthrough

Test file updated to support S390X cluster architecture detection. New imports added for get_cluster_architecture and S390X constants. The preference resolution logic in preferred_preference_for_rhel_version now checks cluster architecture and attempts to resolve S390X-specific VirtualMachineClusterPreferences with a specialized naming convention before falling back to standard resolution paths.

Changes

Cohort / File(s) Summary
S390X Architecture Support
tests/infrastructure/vhostmd/test_downwardmetrics_virtio.py
Added cluster architecture detection and introduced conditional preference resolution for S390X clusters. Logic now checks if cluster architecture is S390X and constructs preference names using a special <base>.<S390X> format with early return behavior before standard fallback path.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description provides a clear explanation of the change and its rationale, but the template sections are incomplete—only the introductory text is filled in, while required sections like 'Short description', 'More details', 'What this PR does / why we need it', issue tracking, and reviewer notes lack substantive content. Complete the template sections: fill in 'Short description', 'More details', and 'What this PR does / why we need it' with substantive content; specify which issue(s) this fixes; add any special notes for reviewers; and provide the jira-ticket URL or write 'NONE' if not tracked.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: fixing VM preference resolution in a downward metrics fixture, which matches the behavioral change described in the summary.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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-4

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, conflict labels
  5. Verified: PR must be marked as verified (if verification is enabled)

📊 Review Process

Approvers and Reviewers

Approvers:

  • dshchedr
  • myakove
  • rnetser
  • vsibirsk

Reviewers:

  • RoniKishner
  • dshchedr
  • geetikakay
  • rnetser
  • vsibirsk
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve

💡 Tips

  • WIP Status: Use /wip when your PR is not ready for review
  • Verification: The verified label is automatically removed on each new commit
  • 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

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

⚠️ Outside diff range comments (1)
tests/infrastructure/vhostmd/test_downwardmetrics_virtio.py (1)

132-141: 🧹 Nitpick | 🔵 Trivial

OPTIONAL: Improve error message to show all attempted preference names.

The fallback logic is correct—S390X is properly defined as the string constant "s390x" in utilities/constants.py and works correctly in both the comparison (line 132) and f-string interpolation (line 134). The code correctly implements the documented behavior where RHEL 8 lacks an s390x-specific preference while RHEL 9/10 have them.

One optional improvement: when the fallback fails on s390x clusters, the error only mentions the base preference_name, not the s390x-specific name that was tried first. This makes debugging harder. Consider tracking attempted names for clarity:

Suggested improvement
`@pytest.fixture`()
def preferred_preference_for_rhel_version(rhel_version, unprivileged_client):
    preference_name = re.sub(r"(\D+)(\d+)", r"\1.\2", rhel_version)
+   attempted_names = [preference_name]
    if get_cluster_architecture() == S390X:
+       s390x_preference_name = f"{preference_name}.{S390X}"
+       attempted_names.insert(0, s390x_preference_name)
        preference_object = VirtualMachineClusterPreference(
-           name=f"{preference_name}.{S390X}", client=unprivileged_client
+           name=s390x_preference_name, client=unprivileged_client
        )
        if preference_object.exists:
            return preference_object
    preference_object = VirtualMachineClusterPreference(name=preference_name, client=unprivileged_client)
    if preference_object.exists:
        return preference_object
-   raise ResourceNotFoundError(f"VirtualMachineClusterPreference {preference_name} not found")
+   raise ResourceNotFoundError(f"VirtualMachineClusterPreference not found. Attempted: {attempted_names}")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/infrastructure/vhostmd/test_downwardmetrics_virtio.py` around lines 132
- 141, The ResourceNotFoundError message should include all preference names
that were attempted; update the logic around VirtualMachineClusterPreference
(the S390X branch and the fallback) to collect attempted names (e.g.,
f"{preference_name}.{S390X}" when get_cluster_architecture() == S390X and
preference_name) and, if neither exists, raise ResourceNotFoundError with a
message listing both attempted names so callers can see which specific s390x and
base preference lookups failed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@tests/infrastructure/vhostmd/test_downwardmetrics_virtio.py`:
- Around line 132-141: The ResourceNotFoundError message should include all
preference names that were attempted; update the logic around
VirtualMachineClusterPreference (the S390X branch and the fallback) to collect
attempted names (e.g., f"{preference_name}.{S390X}" when
get_cluster_architecture() == S390X and preference_name) and, if neither exists,
raise ResourceNotFoundError with a message listing both attempted names so
callers can see which specific s390x and base preference lookups failed.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 05a8bf6 and e51249c.

📒 Files selected for processing (1)
  • tests/infrastructure/vhostmd/test_downwardmetrics_virtio.py

@pytest.fixture()
def preferred_preference_for_rhel_version(rhel_version, unprivileged_client):
preference_name = re.sub(r"(\D+)(\d+)", r"\1.\2", rhel_version)
if get_cluster_architecture() == S390X:
Copy link
Collaborator

Choose a reason for hiding this comment

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

please use get_cluster_architecture fixture

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.

6 participants