Skip to content

fix: add multi-arch check for DATA_SOURCE_NAME suffix#5139

Open
alexandermamaniy wants to merge 1 commit into
RedHatQE:mainfrom
alexandermamaniy:fix/datasource-name-single-arch-vmexport-test
Open

fix: add multi-arch check for DATA_SOURCE_NAME suffix#5139
alexandermamaniy wants to merge 1 commit into
RedHatQE:mainfrom
alexandermamaniy:fix/datasource-name-single-arch-vmexport-test

Conversation

@alexandermamaniy

@alexandermamaniy alexandermamaniy commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

fix: add multi-arch check for DATA_SOURCE_NAME suffix

What this PR does / why we need it:

The current generate_linux_instance_type_os_matrix() function appends the {arch} suffix to DataSource names without validating whether the cluster is multi-arch or single-arch.

This causes kubernetes.dynamic.exceptions.ResourceNotFoundError: Resource DataSource openshift-virtualization-os-images/rhel9-s390x does not exist because:

  • Single-arch clusters use DataSource names without architecture suffixes (e.g., rhel9)
  • Multi-arch clusters use DataSource names with architecture suffixes (e.g., rhel9-s390x, rhel9-amd64, rhel9-arm64)

This PR adds a multi-arch check before appending the {arch} suffix to DATA_SOURCE_NAME, fixing test_vmexport_snapshot_manifests failures on single-arch s390x clusters.

Which issue(s) this PR fixes:

Fixes test_vmexport_snapshot_manifests failures on single-arch s390x clusters

Special notes for reviewer:
  • The fix introduces an is_multi_arch flag that checks len(get_cluster_architecture()) > 1 to determine cluster type.
  • Unit tests were updated to mock get_cluster_architecture() to simulate multi-arch behavior and verify the suffix logic works correctly.
jira-ticket:

NONE

Signed-off-by: Alexander Mamani alexander.mamani@ibm.com

Summary by CodeRabbit

  • Bug Fixes

    • Improved multi-architecture detection so data source names receive an architecture suffix only when the cluster reports multiple architectures, preventing incorrect or misleading naming.
  • Tests

    • Updated unit tests to simulate multi-architecture clusters and validate the conditional naming and flag behavior under those scenarios.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR makes generate_linux_instance_type_os_matrix detect cluster architectures via get_cluster_architecture() and append an -{arch_suffix} to DATA_SOURCE_NAME only when arch_suffix is provided and the cluster reports multiple architectures; tests are updated to mock that call.

Changes

Multi-architecture suffix handling

Layer / File(s) Summary
Import and multi-arch detection logic
utilities/os_utils.py
get_cluster_architecture is imported and used to compute is_multi_arch = len(get_cluster_architecture()) > 1. DATA_SOURCE_NAME is built with -{arch_suffix} only when arch_suffix is provided and is_multi_arch is true; otherwise the base data_source_name is used.
Test updates for multi-arch detection
utilities/unittests/test_os_utils.py
Two existing tests are patched to mock utilities.os_utils.get_cluster_architecture and set its return to {"amd64", "arm64"} to verify data source name suffix behavior in multi-architecture scenarios.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • geetikakay
  • rnetser
  • dshchedr
  • RoniKishner
  • vsibirsk
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly describes the main change: adding a multi-arch check before appending the DATA_SOURCE_NAME suffix, matching the core fix in both modified files.
Description check ✅ Passed Description includes all required sections with detailed context: what the PR does, which issue it fixes, special notes for reviewer, and jira-ticket field marked NONE.
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 No new test files or test functions added under tests/ directory. Modified unit test file (utilities/unittests/test_os_utils.py) is excluded per check instructions.

✏️ 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.

@codecov

codecov Bot commented Jun 7, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5139      +/-   ##
==========================================
- Coverage   98.67%   98.66%   -0.02%     
==========================================
  Files          25       25              
  Lines        2487     2463      -24     
==========================================
- Hits         2454     2430      -24     
  Misses         33       33              
Flag Coverage Δ
utilities 98.66% <100.00%> (-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.

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

@openshift-virtualization-qe-bot-5

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
  • dshchedr
  • geetikakay
  • rnetser
  • 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.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Tip

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
echo "=== Direct callers of generate_linux_instance_type_os_matrix ==="
rg -rn "generate_linux_instance_type_os_matrix" --type=py -C2

echo ""
echo "=== Same-file callers in utilities/os_utils.py ==="
rg -n "generate_linux_instance_type_os_matrix" utilities/os_utils.py -C2

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

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

echo ""
echo "=== Tests that import or call generate_linux_instance_type_os_matrix ==="
rg -rn "generate_linux_instance_type_os_matrix" tests/ --type=py

echo ""
echo "=== conftest files that call generate_linux_instance_type_os_matrix ==="
rg -rn "generate_linux_instance_type_os_matrix" --include="conftest.py"

echo ""
echo "=== vmexport test file ==="
fd "test_vmexport" tests/ --type f

Length of output: 12370


🏁 Script executed:

#!/bin/bash
echo "=== Find vmexport test files ==="
fd "vmexport\|vm_export" tests/ --type f

echo ""
echo "=== Search for generate_linux_instance_type_os_matrix callers in pytest_utils ==="
rg -n "generate_linux_instance_type_os_matrix\|def n\b\|instance_type_rhel_os_matrix\|instance_type_fedora_os_matrix\|instance_type_centos_os_matrix" utilities/pytest_utils.py -C3

echo ""
echo "=== What function in pytest_utils calls n() ==="
rg -n "= n(" utilities/pytest_utils.py -C5

echo ""
echo "=== Tests using instance_type_rhel_os_matrix or related py_config keys ==="
rg -rn "instance_type_rhel_os_matrix\|instance_type_fedora_os_matrix\|instance_type_centos_os_matrix" tests/ --type=py -l

echo ""
echo "=== conftest.py files using instance_type_rhel_os_matrix or related ==="
rg -rn "instance_type_rhel_os_matrix\|instance_type_fedora_os_matrix\|instance_type_centos_os_matrix" --type=py

echo ""
echo "=== DATA_SOURCE_NAME in tests ==="
rg -rn "DATA_SOURCE_NAME\|data_source_name" tests/ --type=py -l

echo ""
echo "=== test_vmexport_snapshot_manifests ==="
rg -rn "test_vmexport_snapshot_manifests\|vmexport_snapshot" tests/ --type=py

echo ""
echo "=== Is n() (generate_linux_instance_type_os_matrix) the alias? ==="
rg -n "^n = \|^def n\b\|^n=" utilities/os_utils.py

Length of output: 2034


🏁 Script executed:

#!/bin/bash
echo "=== Find vmexport test files ==="
fd "vm_export" tests/ --type f

echo ""
echo "=== check utilities/os_utils.py around line 256-300 ==="
sed -n '250,310p' utilities/os_utils.py

echo ""
echo "=== Search instance_type_rhel_os_matrix usage ==="
grep -rn "instance_type_rhel_os_matrix" tests/ 2>/dev/null | head -30

echo ""
echo "=== Search instance_type_fedora_os_matrix usage ==="  
grep -rn "instance_type_fedora_os_matrix" tests/ 2>/dev/null | head -30

echo ""
echo "=== Search instance_type_centos_os_matrix usage ==="
grep -rn "instance_type_centos_os_matrix" tests/ 2>/dev/null | head -30

echo ""
echo "=== DATA_SOURCE_NAME usage in tests ==="
grep -rn "DATA_SOURCE_NAME" tests/ 2>/dev/null | head -30

echo ""
echo "=== vmexport snapshot test ==="
grep -rn "vmexport_snapshot\|vmexport.*snapshot\|snapshot.*manifests" tests/ 2>/dev/null | head -20

echo ""
echo "=== instance_type_rhel_os_matrix in conftest ==="
grep -rn "instance_type_rhel_os_matrix\|instance_type_fedora\|instance_type_centos" --include="conftest.py" . 2>/dev/null | head -30

echo ""
echo "=== pytest_utils function that uses n() ==="
grep -n "instance_type_rhel_os_matrix\|instance_type_fedora_os_matrix\|instance_type_centos" utilities/pytest_utils.py | head -30

Length of output: 15655


🏁 Script executed:

#!/bin/bash
echo "=== Get PR details for inline comment ==="
gh pr view 5139 --json headRefOid,files

echo ""
echo "=== Get the diff to find first changed line ==="
gh pr diff 5139 --name-only

echo ""
echo "=== Check if test_rhel_os is smoke AND gating ==="
grep -n "pytest.mark.smoke\|pytest.mark.gating" tests/infrastructure/instance_types/supported_os/test_rhel_os.py 2>/dev/null | head -20

echo ""
echo "=== Check numa tests for gating ==="
grep -rn "pytest.mark.gating" tests/infrastructure/numa/ 2>/dev/null | head -10

echo ""
echo "=== Get PR diff for first changed file lines ==="
gh api repos/RedHatQE/openshift-virtualization-tests/pulls/5139/files --jq '.[0] | {filename, patch: .patch[0:500]}'

Length of output: 1958


🏁 Script executed:

#!/bin/bash
# Post inline review comment on the first changed line of utilities/os_utils.py
# The first addition is: "from utilities.architecture import get_cluster_architecture" at new file line 8

COMMIT_SHA="d8352f71335d4eb3b866c66071261ecc391fb565"
PR_NUMBER=5139
REPO="RedHatQE/openshift-virtualization-tests"

BODY="## Test Execution Plan

**Run smoke tests: True**
Dependency path: \`tests/infrastructure/instance_types/supported_os/test_rhel_os.py\` (\`@pytest.mark.smoke\`) → \`instance_type_rhel_os_matrix__module__\` fixture (\`tests/infrastructure/instance_types/supported_os/conftest.py\`) → reads \`DATA_SOURCE_NAME\` from \`py_config[\"instance_type_rhel_os_matrix\"]\` → set by \`generate_linux_instance_type_os_matrix()\` in \`utilities/pytest_utils.py\` → **modified symbol** in \`utilities/os_utils.py\`

**Run gating tests: True**
Dependency path: same as above — \`test_rhel_os.py\` carries both \`@pytest.mark.smoke\` and \`@pytest.mark.gating\`

**Affected tests to run**
- \`tests/infrastructure/instance_types/supported_os/test_rhel_os.py\` (smoke, gating) — consumes \`DATA_SOURCE_NAME\` from \`instance_type_rhel_os_matrix__module__\`
- \`tests/infrastructure/instance_types/supported_os/test_centos_os.py\` — consumes \`DATA_SOURCE_NAME\` from \`instance_type_centos_os_matrix__module__\`
- \`tests/infrastructure/instance_types/supported_os/test_fedora_os.py\` — consumes \`DATA_SOURCE_NAME\` from \`instance_type_fedora_os_matrix__module__\`
- \`tests/infrastructure/numa/\` (all tests) — consume \`DATA_SOURCE_NAME\` via \`instance_type_rhel_os_matrix__module__\` in \`tests/infrastructure/numa/conftest.py\`

Run on **single-arch s390x** cluster (the fixed scenario) and **multi-arch** cluster to confirm both paths produce correct DataSource names."

gh api \
  repos/${REPO}/pulls/${PR_NUMBER}/reviews \
  --method POST \
  --field commit_id="${COMMIT_SHA}" \
  --field body="" \
  --field event="COMMENT" \
  --field "comments[][path]=utilities/os_utils.py" \
  --field "comments[][line]=8" \
  --field "comments[][side]=RIGHT" \
  --field "comments[][body]=${BODY}"

Length of output: 3887




🧠 Learnings used
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 0
File: :0-0
Timestamp: 2025-12-16T10:28:54.212Z
Learning: In the openshift-virtualization-tests repository, when determining smoke test impact for test execution plans, only set "Run smoke tests: True" if there is a verified, traceable dependency path from smoke tests to the changed code. Session-scoped fixtures or infrastructure-sounding changes do NOT automatically imply smoke test impact - the dependency chain must be explicitly verified using shell scripts before recommending smoke test execution.

Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 0
File: :0-0
Timestamp: 2026-04-30T13:42:43.892Z
Learning: In the openshift-virtualization-tests repository, when processing test execution plan requests for PRs that introduce NEW test classes or test files (not just modifications to existing tests), always verify STD-first workflow compliance as part of the analysis: (1) check if the new test class has actual implementation code (assertions, test logic) — if so, it needs a prior STD PR, (2) check if the test file has a module docstring with STP or Jira/RFE link, (3) check if `What this PR does / why we need it:` in the PR description has meaningful content. Flag any violation even when the bot's primary request is only for a test execution plan. These checks should be appended to the test execution plan inline comment.

Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 0
File: :0-0
Timestamp: 2025-12-22T15:56:00.157Z
Learning: In the openshift-virtualization-tests repository, when responding to test execution plan requests from openshift-virtualization-qe-bot-3, do NOT use "REQUEST_CHANGES" review type if the PR author has already marked the PR as verified (e.g., with `/verified` command). Test execution plans are informational guides, not blocking requirements. Use COMMENT event for informational test plans, or only REQUEST_CHANGES if there are actual code issues that need to be addressed before merging.

Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 3062
File: conftest.py:333-333
Timestamp: 2025-12-16T20:11:03.645Z
Learning: In the openshift-virtualization-tests repository, when determining smoke test impact for changes affecting py_config["os_login_param"], follow this verification methodology: (1) Find all smoke tests: `rg "pytest.mark.smoke" --type=py -B2 | grep "def test_"`, (2) For each smoke test file, search for VM creation patterns: `rg "VirtualMachineForTests|running_vm|VirtualMachineForTestsFromTemplate|wait_for_ssh|check_ssh_connectivity"`, (3) Trace the dependency chain: smoke test → VirtualMachineForTests/running_vm() → wait_for_ssh_connectivity() (default enabled) → vm.login_params property → py_config["os_login_param"][vm.os_flavor], (4) Check utilities/virt.py for login_params usage: `rg "os_login_param|login_params" utilities/virt.py -C3`. Any smoke test creating VMs with default SSH connectivity checks (running_vm with check_ssh_connectivity=True) depends on os_login_param, even if the test doesn't directly reference it.

Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 5039
File: tests/network/l2_bridge/nad_ref_change/lib_helpers.py:1-1
Timestamp: 2026-06-02T21:17:09.602Z
Learning: In RedHatQE/openshift-virtualization-tests, when a PR only relocates functions to shared libraries and updates import paths in test files (no logic change), do NOT flag the callers as requiring full test re-execution. At most, run `pytest --collect-only` to verify the new import paths resolve correctly. Only require full re-execution of caller tests when the moved function's implementation changes behavior.

Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4954
File: .flake8:4-4
Timestamp: 2026-06-01T14:00:52.523Z
Learning: In RedHatQE/openshift-virtualization-tests, the smoke-marked test files (tests/storage/cdi_clone/test_clone.py, tests/storage/cdi_upload/test_upload_virtctl.py, tests/virt/cluster/common_templates/rhel/test_rhel_os_support.py, tests/virt/node/general/test_container_disk_vm.py) have traceable dependency paths to utilities/storage.py, utilities/hco.py (wait_for_hco_conditions), utilities/infra.py, and utilities/virt.py via direct imports and via tests/storage/conftest.py. Do not conclude "no smoke dependency path" without verifying these transitive imports.

Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 3062
File: conftest.py:333-333
Timestamp: 2025-12-16T15:09:49.597Z
Learning: In the openshift-virtualization-tests repository, when conftest.py or utilities/bitwarden.py changes affect py_config["os_login_param"], smoke test impact must be determined by: (1) finding all smoke tests using `rg "pytest.mark.smoke"`, (2) checking each for VM creation patterns (VirtualMachineForTests, running_vm, VirtualMachineForTestsFromTemplate), (3) tracing whether running_vm is called with default check_ssh_connectivity=True, which accesses vm.login_params property that reads py_config["os_login_param"][vm.os_flavor]. The dependency chain is: smoke test → VM creation → running_vm → wait_for_ssh_connectivity → vm.login_params → os_login_param. Any smoke test creating VMs with SSH connectivity (the default) depends on os_login_param.

Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 0
File: :0-0
Timestamp: 2025-12-16T14:00:59.076Z
Learning: In the openshift-virtualization-tests repository, when responding to test execution plan requests from openshift-virtualization-qe-bot-3, CodeRabbit must post ONLY an inline review comment on the Files Changed tab and then stop immediately without generating any follow-up comments in the PR discussion thread. No acknowledgment messages, no confirmation of posting, no explanation - silence after posting the inline review equals success. Additional comments create empty/meaningless reviews that clutter the PR.

Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 0
File: :0-0
Timestamp: 2026-05-29T11:02:22.804Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, version-bump PRs that update the main branch to reference a new CNV release (e.g., "Update project `main` to reference cnv 5.0") do NOT add new test files or test modules. These PRs only update metadata (pyproject.toml, tox.ini, .coderabbit.yaml) and clean up resolved Jira fixtures/markers in existing files. The "Stp Link Required" pre-merge check may incorrectly flag hundreds of "newly added" test files as a false positive due to the base-branch comparison shifting after branching — this should be ignored for such PRs.

Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 0
File: :0-0
Timestamp: 2026-04-03T18:43:06.192Z
Learning: In `scripts/tests_analyzer/pytest_marker_analyzer.py` in the openshift-virtualization-tests repository, `conftest_resolved=True` is an intentional trade-off: once a conftest pathway is resolved, it stops scanning further dependency paths (including non-conftest ones). Removing this flag causes 21 false positive regressions on 150 PRs (measured). The false negative risk — a 2+ level transitive chain through both conftest and non-conftest paths — is considered theoretical. Do not flag `conftest_resolved=True` as hiding non-conftest dependency paths; this behavior is deliberate and empirically validated.

Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 0
File: :0-0
Timestamp: 2025-09-29T19:05:24.987Z
Learning: The test execution plan for PR `#1904` focuses on cluster-type conditional logic where nmstate functionality is bypassed on cloud clusters (Azure/AWS) but fully functional on bare-metal/PSI clusters, requiring different test strategies for each environment type.

Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 0
File: :0-0
Timestamp: 2025-12-16T14:06:22.391Z
Learning: In the openshift-virtualization-tests repository, when posting test execution plan inline review comments using GitHub API, the full test execution plan content must go in the `comments[].body` field (which appears on Files Changed tab), NOT in the top-level `body` field (which appears in PR discussion thread). The top-level `body` field should be omitted or left empty to avoid posting redundant comments in the PR discussion thread.

Learnt from: CR
Repo: RedHatQE/openshift-virtualization-tests PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-05-18T15:22:26.757Z
Learning: Applies to tests/**/test_*.py : New feature tests must follow the STD-first workflow: (1) STP (Software Test Plan) reviewed and approved, (2) STD (Software Test Description) placeholder tests with docstrings and `__test__ = False` reviewed, (3) Implementation only after STD review. Never submit test implementation without prior STD review.

Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4328
File: tests/network/flat_overlay/test_multi_network_policy.py:32-32
Timestamp: 2026-04-14T16:15:36.741Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, when reviewing any PR with "Quarantine" in the title or a `quarantine` label, always verify compliance with docs/QUARANTINE_GUIDELINES.md:
- Category 1 (Product Bug): must use `pytest.mark.jira("CNV-XXXXX", run=False)` — the `pytest_jira` plugin conditionally skips the test when the Jira issue is open. Do NOT suggest replacing this with `xfail`.
- Category 2 (Automation Issue): must use `pytest.mark.xfail(run=False, reason=...)` — pytest itself handles the skip.
Flag any quarantine PR that uses the wrong category marker, is missing a Jira ticket reference, or uses `run=False` in the wrong context. Raising these compliance questions is always appropriate for quarantine PRs, even if the final resolution confirms the marker is correct.

Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 4118
File: utilities/database.py:0-0
Timestamp: 2026-03-17T01:32:13.674Z
Learning: In RedHatQE/openshift-virtualization-tests, maintainer dshchedr prefers CodeRabbit to post targeted inline comments on the Files changed tab for each applicable location rather than aggregating multiple issues into a single discussion thread.

Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 4118
File: utilities/database.py:0-0
Timestamp: 2026-03-17T01:32:13.674Z
Learning: In RedHatQE/openshift-virtualization-tests, maintainer dshchedr prefers CodeRabbit to post targeted inline comments on the Files Changed tab at each applicable location rather than aggregating multiple issues into a single PR discussion thread reply.

Learnt from: servolkov
Repo: RedHatQE/openshift-virtualization-tests PR: 1776
File: libs/net/node_network.py:25-31
Timestamp: 2025-08-20T23:43:28.117Z
Learning: In the RedHatQE/openshift-virtualization-tests project, servolkov's team always uses bare metal (BM) clusters with IPv4 setup in their testing environment, making defensive checks for IPv4 data presence potentially redundant in their networking code.

Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 3371
File: scripts/tests_analyzer/compare_coderabbit_decisions.py:199-289
Timestamp: 2026-01-13T10:06:14.822Z
Learning: In the openshift-virtualization-tests repository, user rnetser prefers to keep pagination loops inline rather than extracting them into generic helper functions when the loops have different URL patterns and unique post-processing logic, as the inline approach improves readability and makes each endpoint's behavior more explicit.

Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 3228
File: .coderabbit.yaml:30-41
Timestamp: 2026-01-05T10:33:55.037Z
Learning: In the openshift-virtualization-tests repository, user rnetser prefers minimal pre-merge checks in CodeRabbit configuration: only docstrings enforcement (80% threshold) is needed, not title or description checks.

Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 2469
File: utilities/sanity.py:139-142
Timestamp: 2025-11-08T07:36:57.616Z
Learning: In the openshift-virtualization-tests repository, user rnetser prefers to keep refactoring PRs (like PR `#2469`) strictly focused on moving/organizing code into more granular modules without adding new functionality, error handling, or behavioral changes. Such improvements should be handled in separate PRs.

Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 1160
File: tests/storage/storage_migration/test_mtc_storage_class_migration.py:165-176
Timestamp: 2025-06-17T07:45:37.776Z
Learning: In the openshift-virtualization-tests repository, user jpeimer prefers explicit fixture parameters over composite fixtures in test methods, even when there are many parameters, as they find this approach more readable and maintainable for understanding test dependencies.

Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 3571
File: tests/storage/storage_migration/utils.py:158-167
Timestamp: 2026-01-25T13:18:26.819Z
Learning: In the openshift-virtualization-tests repository, user jpeimer prefers to avoid nitpicky style changes (e.g., removing `.keys()` from dict membership checks) because verifying every change is expensive. Be cautious about suggesting low-impact stylistic improvements that require verification overhead.

Learnt from: akri3i
Repo: RedHatQE/openshift-virtualization-tests PR: 1210
File: tests/virt/cluster/general/mass_machine_type_transition_tests/conftest.py:24-64
Timestamp: 2025-06-23T19:28:20.281Z
Learning: In OpenShift Virtualization mass machine type transition tests, the machine type glob pattern "pc-q35-rhel8.*.*" is intentionally hard-coded in the kubevirt_api_lifecycle_automation_job as it's used only once for this specific test case, with plans to update it in the future if the job needs to support other machine types.

Learnt from: RoniKishner
Repo: RedHatQE/openshift-virtualization-tests PR: 1411
File: utilities/os_utils.py:246-279
Timestamp: 2025-07-22T17:13:59.166Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, CentOS preferences follow the format "centos-stream<version>" (e.g., "centos-stream9", "centos-stream10"). The generate_instance_type_centos_os_matrix function correctly uses regex to extract numeric versions and constructs the latest version string in the same format as the input preferences for proper comparison.

Learnt from: vamsikrishna-siddu
Repo: RedHatQE/openshift-virtualization-tests PR: 2199
File: tests/storage/test_online_resize.py:108-113
Timestamp: 2025-09-28T14:43:07.181Z
Learning: In the openshift-virtualization-tests repo, PR `#2199` depends on PR `#2139` which adds architecture-specific OS_FLAVOR attributes to the Images.Cirros class (OS_FLAVOR_CIRROS for x86_64/ARM64, OS_FLAVOR_FEDORA for s390x), enabling conditional logic based on the underlying OS flavor in tests.

Learnt from: SiboWang1997
Repo: RedHatQE/openshift-virtualization-tests PR: 1566
File: tests/global_config_x86_64.py:29-29
Timestamp: 2025-07-25T01:59:02.180Z
Learning: In the openshift-virtualization-tests repo, the s390x architecture still relies on Fedora 41 images, while only x86_64 is updated to Fedora 42 in PR `#1566`.

Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 983
File: utilities/constants.py:163-168
Timestamp: 2025-05-18T07:36:10.674Z
Learning: In the OpenShift Virtualization tests, architecture constants like X86_64, AMD_64, ARM_64, and S390X need to be included in the get_test_images_arch_class() validation check to be fully supported.

Learnt from: RoniKishner
Repo: RedHatQE/openshift-virtualization-tests PR: 4196
File: utilities/pytest_utils.py:522-527
Timestamp: 2026-03-22T12:40:15.236Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, CentOS Stream VirtualMachineClusterPreferences do NOT have architecture-specific variants for any architecture (including ARM64 and s390x). Preferences use generic names like "centos.stream9" and "centos.stream10" without any architecture suffix. Therefore, in `utilities/pytest_utils.py`, the call to `generate_linux_instance_type_os_matrix` for CentOS Stream should always use `arch_suffix=None` (or omit the parameter entirely) — never passing cpu_arch as arch_suffix.

Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 3883
File: tests/global_config_s390x.py:16-22
Timestamp: 2026-02-23T16:30:33.855Z
Learning: On s390x clusters, Fedora VirtualMachineClusterPreference uses architecture-specific preference names with the s390x suffix (e.g., "fedora.42.s390x"), similar to RHEL 9/10 preferences. This differs from CentOS Stream which uses generic preference names without architecture suffixes on s390x. In tests/global_config_s390x.py and utilities/pytest_utils.py, Fedora instance type matrix generation should include arch_suffix=S390X on s390x clusters.

Learnt from: vamsikrishna-siddu
Repo: RedHatQE/openshift-virtualization-tests PR: 2199
File: tests/storage/test_online_resize.py:108-113
Timestamp: 2025-09-28T14:43:07.181Z
Learning: In the openshift-virtualization-tests repo, PR `#2199` depends on PR `#2139` which adds the OS_FLAVOR attribute to the Images.Cirros class, making Images.Cirros.OS_FLAVOR available for conditional logic in tests.

Learnt from: hmeir
Repo: RedHatQE/openshift-virtualization-tests PR: 4972
File: utilities/pytest_utils.py:601-601
Timestamp: 2026-05-25T10:32:29.973Z
Learning: In RedHatQE/openshift-virtualization-tests, `py_config["cpu_arch"]` intentionally stores a `list[str]` when running in multiarch mode (multiple architectures in `--cpu-arch`) and a plain `str` for single-arch runs. All consumers that treat it as a scalar string (e.g., `utilities/virt.py`, `utilities/cpu.py`, `libs/vm/vm.py`, template tests) are single-arch-only code paths and must not be called on multiarch clusters. Similarly, the `nodes_cpu_architecture` fixture (which simply returns `py_config["cpu_arch"]`) is not intended for use in multiarch cluster test scenarios. Do not flag the list/scalar duality as a type-contract bug; it is by design.

Learnt from: yossisegev
Repo: RedHatQE/openshift-virtualization-tests PR: 4810
File: libs/vm/factory.py:33-34
Timestamp: 2026-05-17T14:45:01.442Z
Learning: In RedHatQE/openshift-virtualization-tests, the `fedora_image()` function in `libs/vm/factory.py` intentionally uses `py_config["cpu_arch"]` for image selection, and callers are responsible for ensuring the spec they provide (including `vmi_spec.architecture`) is consistent with the test configuration's CPU architecture. Do not flag this as a mismatch issue.

Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 3755
File: utilities/architecture.py:10-11
Timestamp: 2026-03-15T16:01:27.748Z
Learning: In RedHatQE/openshift-virtualization-tests (PR `#3755`), the `Images` variable in `utilities/constants.py` is initialized at import time using `next(iter(get_cluster_architecture())).upper()` as a transient placeholder only. Before any tests run, `update_cpu_arch_related_config()` in `utilities/pytest_utils.py` (called from `pytest_sessionstart`) re-assigns `constants_module.Images = getattr(constants_module.ArchImages, arch.upper())` with the correct architecture derived from `--cpu-arch` CLI option or cluster detection. Do not flag the import-time `next(iter(...))` call as nondeterministic — the authoritative assignment happens in `update_cpu_arch_related_config` before test collection/execution.

Comment thread utilities/os_utils.py
Comment on lines +300 to +302
DATA_SOURCE_NAME: f"{data_source_name}-{arch_suffix}"
if arch_suffix and is_multi_arch
else data_source_name,

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.

a simpler fix would be to update update_cpu_arch_related_config in
https://github.com/RedHatQE/openshift-virtualization-tests/blob/main/utilities/pytest_utils.py#L618
make it if py_config["cluster_type"] == ARM64: instead of if py_config["cluster_type"] != AMD_64

@alexandermamaniy alexandermamaniy Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @vsibirsk, I tried your approach but for single-arch s390x cluster need the cpu_arch=arch parameter to be passed to generate_instance_type_matrix_dicts in order to generate the VM Preference with s390x suffix, but the s390x DataSource suffix is not needed for single-arch s390x cluster.

If py_config["cluster_type"] == ARM64, i would be skipping cpu_arch='s390x'.
As result, cpu_arch=None, so arch_preference=preference instead of arch_preference=f"{preference}.s390x" . Causing test failures when pick the wrong VM Preference(amd64 without s390x suffix)

As @geetikakay said, the DataSource suffix need to be decouple from VM preferences.

Comment thread utilities/os_utils.py
@openshift-virtualization-qe-bot

Copy link
Copy Markdown

Clean rebase detected — no code changes compared to previous head (d8352f7).
The following labels were preserved: verified, changes-requested-vsibirsk, commented-geetikakay, commented-coderabbitai[bot], lgtm-coderabbitai[bot], commented-alexandermamaniy.

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

Caution

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

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

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

Add test coverage for single-architecture cluster behavior.

Both modified tests simulate multi-arch clusters ({"amd64", "arm64"}), but the PR fixes a bug that occurred on single-arch s390x clusters. The new is_multi_arch gating logic needs validation for the single-arch case.

Add a test case that verifies:

  • Mock get_cluster_architecture() to return a single architecture (e.g., {"s390x"})
  • Call generate_linux_instance_type_os_matrix() with arch_suffix="s390x"
  • Assert that DATA_SOURCE_NAME does NOT include the -s390x suffix

This ensures the bug fix is correctly tested and prevents future regressions.

🧪 Suggested test case
`@patch`("utilities.os_utils.get_cluster_architecture")
def test_single_arch_cluster_omits_data_source_suffix(self, mock_get_cluster_arch):
    """Single-arch cluster should not append arch suffix to DATA_SOURCE_NAME."""
    mock_get_cluster_arch.return_value = {"s390x"}  # Single architecture
    result = generate_linux_instance_type_os_matrix(
        os_name="rhel",
        preferences=[RHEL10_PREFERENCE],
        arch_suffix="s390x",
    )

    config = result[0][f"{RHEL10_PREFERENCE}.s390x"]
    assert config["preference"] == f"{RHEL10_PREFERENCE}.s390x"
    assert config["DATA_SOURCE_NAME"] == "rhel10", "Single-arch must not add suffix"
🤖 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/unittests/test_os_utils.py` around lines 336 - 363, Add a new unit
test that mocks utilities.os_utils.get_cluster_architecture to return a
single-architecture set (e.g., {"s390x"}) and calls
generate_linux_instance_type_os_matrix with arch_suffix="s390x"; then assert the
returned config (keyed by f"{RHEL10_PREFERENCE}.s390x") keeps preference as
f"{RHEL10_PREFERENCE}.s390x" but that config["DATA_SOURCE_NAME"] equals "rhel10"
(i.e., no "-s390x" suffix) to validate the single-arch gating in
generate_linux_instance_type_os_matrix.
🤖 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.

Outside diff comments:
In `@utilities/unittests/test_os_utils.py`:
- Around line 336-363: Add a new unit test that mocks
utilities.os_utils.get_cluster_architecture to return a single-architecture set
(e.g., {"s390x"}) and calls generate_linux_instance_type_os_matrix with
arch_suffix="s390x"; then assert the returned config (keyed by
f"{RHEL10_PREFERENCE}.s390x") keeps preference as f"{RHEL10_PREFERENCE}.s390x"
but that config["DATA_SOURCE_NAME"] equals "rhel10" (i.e., no "-s390x" suffix)
to validate the single-arch gating in generate_linux_instance_type_os_matrix.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6e8f240a-09c2-436f-b4fe-a987f09441cc

📥 Commits

Reviewing files that changed from the base of the PR and between d8352f7 and 375708c.

📒 Files selected for processing (2)
  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: can-be-merged
  • GitHub Check: tox
  • GitHub Check: verify-bugs-are-open
  • GitHub Check: build-container
  • GitHub Check: can-be-merged
🧰 Additional context used
📓 Path-based instructions (3)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Never add linter suppressions like # noqa, # type: ignore, or # pylint: disable. Fix the code instead. If you believe a rule is wrong, ask the user for explicit approval.
Search the codebase for existing implementations before writing new code. Check utilities/, libs/, tests/, and pyproject.toml dependencies. Never duplicate logic—extract to shared modules. Use pyhelper_utils.shell.run_command for shell commands instead of subprocess.run, and use ocp-resources classes instead of raw YAML dicts.
Type hints are MANDATORY. Use mypy strict mode in libs/ and all new public functions under utilities. Use TYPE_CHECKING for type-only imports to avoid runtime overhead and circular imports.
Write Google-format docstrings for all public functions with non-obvious return values or side effects.
Always use uv run to execute commands. Never execute python, pip, pytest, tox, or pre-commit directly. Use uv run python, uv run pytest, uv run tox, uv run pre-commit, and uv add for package installation.
Always use absolute imports. Never use relative imports.
Prefer specific imports using from module import func for functions and constants. Use from package import module (then module.Name) when retaining the module name meaningfully improves readability. Never use bare import module without a from clause.
Always use named arguments for function calls with more than one argument.
Never use single-letter variable names. Always use descriptive, meaningful names.
No dead code. Every function, variable, and fixture must be used or removed. Code marked with # skip-unused-code is excluded from dead code analysis (enforced via custom ruff plugin).
Prefer direct attribute access using foo.attr. Save to variables only when reusing the same attribute multiple times improves readability or extracting clarifies intent.
Imports must always be at the top of the module. Do not import inside functions.
No defensive programming. Fail...

Files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
utilities/unittests/**

⚙️ CodeRabbit configuration file

utilities/unittests/**: ## Unit Tests — Relaxed Rules
Files under utilities/unittests/ are unit tests for shared utilities.
Do NOT enforce:

  • STD docstring format (Preconditions/Steps/Expected sections)
  • STP link requirements
  • RFE/Jira link requirements
  • Coverage tracking rules
    These rules apply only to feature/integration tests under tests/.
    DO still enforce: code quality, type hints, naming conventions, and all other coding standards.

Files:

  • utilities/unittests/test_os_utils.py
**

⚙️ CodeRabbit configuration file

**: ## PR Template Validation
Check the PR description for required sections from .github/pull_request_template.md.
Required sections (must be present, even if empty):

  • ##### What this PR does / why we need it: — MUST be present AND have meaningful content.
    Flag as HIGH if the section is missing, empty, whitespace-only, contains only HTML comments,
    or contains only placeholder tokens such as TBD, TBA, N/A, -, , none, or ..
  • ##### Which issue(s) this PR fixes: — must be present (may be empty)
  • ##### Special notes for reviewer: — must be present (may be empty)
  • ##### jira-ticket: — must be present (may be empty)
    If any required section is absent, or What this PR does / why we need it: has no content,
    flag it as HIGH severity and ask the author to restore the missing template section(s).

Approval Policy

You may approve the PR when ALL of the following are true:

  • All your review comments have been addressed with either:
    • a code/doc change that fixes the issue, or
    • a substantive author response that justifies no code change.
      Thread "resolved" state alone is not sufficient.
      OR you had no review comments.
  • If you posted a test execution plan comment requesting tests, and the PR author replied
    with a comment explaining why the requested tests are not needed or were already covered,
    treat that as an acceptable response — do not block approval on the test plan alone.
  • The author's explanation must be reasonable and specific (not just "N/A" or "not needed").
    Accept explanations like: "these tests were already run in CI", "this change is docs-only",
    "the affected tests are quarantined", or "verified manually on cluster X".

Files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py

⚙️ CodeRabbit configuration file

**: # AI Review and Development Standards

Assisted-by: Claude noreply@anthropic.com

Coding standards, conventions, and review guidelines for openshift-virtualization-tests.

These rules apply to ALL contributors and review tools — human and AI alike.

Strict Rules (MANDATORY)

Linter Suppressions PROHIBITED

  • NEVER add # noqa, # type: ignore, # pylint: disable
  • NEVER disable linter/mypy rules to work around issues
  • FIX THE CODE - If linter complains, the code is wrong
  • If you think a rule is wrong: ASK the user for explicit approval

Code Reuse (Search-First Development)

Before writing ANY new code:

  1. SEARCH codebase for existing implementations
  2. CHECK utilities/ for shared functions
  3. CHECK libs/ for shared libraries
  4. CHECK tests/ for shared fixtures and helper functions
  5. CHECK pyproject.toml dependencies — project packages (e.g., pyhelper-utils, ocp-resources, openshift-python-wrapper) may already provide the functionality
  6. VERIFY no similar logic exists elsewhere
  7. NEVER duplicate logic - extract to shared module
  8. REUSE existing code and patterns — only write new when nothing exists

External package examples:

  • Shell commands — use pyhelper_utils.shell.run_command, NEVER use subprocess.run directly in test/utility code
  • OpenShift resources — use ocp-resources classes, NEVER construct raw YAML dicts

Python Requirements

  • Type hints MANDATORY - mypy strict mode in libs/, all new public functions under utilities MUST be typed
  • Use TYPE_CHECKING for type-only imports - wrap imports needed solely for type hints in if TYPE_CHECKING: to avoid runtime overhead and circular imports
  • Google-format docstrings REQUIRED - for all public functions with non-obvious return values OR side effects
  • No defensive programming - fail-fast, don't hide bugs with fake defaults (see exceptions below)
  • ALWAYS use uv run -...

Files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
🧠 Learnings (33)
📚 Learning: 2026-01-07T11:51:57.253Z
Learnt from: qwang1
Repo: RedHatQE/openshift-virtualization-tests PR: 3301
File: utilities/unittests/test_oadp.py:5-5
Timestamp: 2026-01-07T11:51:57.253Z
Learning: In utilities/unittests/test_oadp.py and similar test files in this repo, include a # flake8: noqa: E402 directive to suppress E402 warnings caused by pre-commit checks. This is needed because mock setup must precede imports to avoid circular dependencies, and Ruff may report unused imports. Apply this directive to all similar test files that require imports to guard against circular import issues.

Applied to files:

  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-01-12T11:24:13.825Z
Learnt from: servolkov
Repo: RedHatQE/openshift-virtualization-tests PR: 3387
File: tests/network/provider_migration/libprovider.py:50-52
Timestamp: 2026-01-12T11:24:13.825Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, when catching exceptions in Python, use LOGGER.error before re-raising and do not replace it with LOGGER.exception in except blocks. This follows the established pattern across the codebase.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-01-12T14:25:05.723Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 3366
File: tests/storage/cdi_clone/test_clone.py:5-9
Timestamp: 2026-01-12T14:25:05.723Z
Learning: In Python tests and utility code across the repository, bitmath.parse_string_unsafe correctly parses Kubernetes quantities (e.g., '4Gi', '512Mi', PVC storage requests) without supplying system=bitmath.NIST. There are 30+ usages indicating this is the standard behavior. Reviewers should verify that code that builds or compares quantity strings does not pass the NIST parameter, and if a new test relies on quantity parsing, assume no NIST parameter is required unless explicitly documented.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-01-20T01:03:13.139Z
Learnt from: servolkov
Repo: RedHatQE/openshift-virtualization-tests PR: 3387
File: tests/network/provider_migration/libprovider.py:1-8
Timestamp: 2026-01-20T01:03:13.139Z
Learning: In the openshift-virtualization-tests repository, Python imports should consistently use module-level imports for the logging module (i.e., import logging) rather than from logging import ... The established pattern spans 270+ files and should not be flagged for refactoring. Apply this guideline to Python files across the repo (e.g., tests/network/provider_migration/libprovider.py).

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-01-21T21:26:41.805Z
Learnt from: geetikakay
Repo: RedHatQE/openshift-virtualization-tests PR: 3559
File: utilities/infra.py:251-254
Timestamp: 2026-01-21T21:26:41.805Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, when reviewing Python code, recognize that with Python 3.14 the syntax 'except ValueError, TypeError:' is valid if there is no 'as' clause, and should not be flagged as Python 2 syntax. If you use an 'as' binding (e.g., 'except (ValueError, TypeError) as e:'), parentheses are required. Ensure this pattern is version-consistent and not flagged as Python 2 syntax when 'as' is absent.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-01-25T13:18:21.675Z
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 3571
File: tests/storage/storage_migration/utils.py:158-167
Timestamp: 2026-01-25T13:18:21.675Z
Learning: In reviews of the openshift-virtualization-tests repo (and similar Python code), avoid suggesting minor stylistic changes that require extra verification (e.g., removing dict.keys() checks for membership) unless the change has clear correctness or maintainability impact. Focus on fixes with observable behavior, security, performance, or maintainability benefits; defer low-impact style tweaks that are costly to verify.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-02-18T06:35:39.536Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 3847
File: utilities/virt.py:2449-2453
Timestamp: 2026-02-18T06:35:39.536Z
Learning: In Python code, a function named clearly and self-descriptively can be deemed not to require a docstring. However, treat this as a context-specific guideline and not a universal rule. For public APIs or functions with side effects, prefer concise docstrings explaining behavior, inputs, outputs, and side effects. This guidance is based on the example in utilities/virt.py from RedHatQE/openshift-virtualization-tests where validate_libvirt_persistent_domain(vm, admin_client) was considered self-documenting.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-02-23T16:33:22.070Z
Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 3883
File: utilities/pytest_utils.py:441-463
Timestamp: 2026-02-23T16:33:22.070Z
Learning: In Python code reviews, the guideline to always use named arguments for multi-argument calls does not apply to built-ins or methods that have positional-only parameters (those defined with a / in their signature). Do not flag or require named arguments for calls like dict.get(key, default=None, /), list.pop(), str.split(sep, maxsplit) and similar built-ins that cannot accept keyword arguments. Apply the named-argument rule only to functions/methods that explicitly accept keyword arguments.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-03-17T01:32:02.617Z
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 4118
File: utilities/database.py:0-0
Timestamp: 2026-03-17T01:32:02.617Z
Learning: In RedHatQE/openshift-virtualization-tests, when reviewing Python files, post targeted inline comments on the Files changed tab at the exact location (file and line) of the issue rather than opening a single discussion thread for multiple issues. This should be done for each applicable location to improve traceability and clarity. If multiple issues exist in the same file, address them with separate inline comments pointing to the specific lines.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-03-17T01:32:02.617Z
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 4118
File: utilities/database.py:0-0
Timestamp: 2026-03-17T01:32:02.617Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, CodeRabbit should post targeted inline comments at each applicable location in the Files Changed tab, rather than aggregating multiple issues into a single PR discussion thread reply. This guideline applies to all Python files (any file ending in .py) changed in a PR; for non-Python files, follow the same inline-comment-at-location principle if relevant.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-05-04T13:45:29.122Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4725
File: utilities/console.py:54-59
Timestamp: 2026-05-04T13:45:29.122Z
Learning: During review of RedHatQE/openshift-virtualization-tests “lint-cleanup” PRs (e.g., changes targeting lint issues like stale noqa/utf-8 headers), do not flag existing `# type: ignore` directives that were already present before the PR and were not introduced or modified by the PR. Only raise findings for `# type: ignore` suppressions that the PR itself adds, changes, or otherwise makes newly effective (i.e., they appear in the diff as additions/edits).

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-05-04T13:45:33.892Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4725
File: tests/virt/cluster/common_templates/centos/test_centos_os_support.py:78-83
Timestamp: 2026-05-04T13:45:33.892Z
Learning: When reviewing lint-cleanup or formatting-only pull requests in this repo (e.g., changes like removing/updating `# noqa` comments or UTF-8 headers), do not raise findings for code patterns that already existed before the PR. Specifically, if a problematic construct such as `.is_connective(tcp_timeout=120)` was present in the base branch, suppress that finding and only raise issues when the PR itself introduces or modifies that construct (i.e., the diff adds/changes the call or its arguments). Apply this rule across all Python files (`**/*.py`).

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-05-05T17:01:15.294Z
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 4739
File: tests/virt/node/descheduler/conftest.py:2-2
Timestamp: 2026-05-05T17:01:15.294Z
Learning: In this repo’s Python code, it’s acceptable (and preferred by convention) to build `run_command` inputs using `shlex.split(f"<command> {arg}")` rather than converting to direct list literals like `['oc', 'adm', 'uncordon', name]`. During code review, generally don’t flag `shlex.split(...)` usage for `run_command` calls and don’t suggest replacing it with list literals; the string-form pattern is used to keep commands readable and consistent with how they’re typed in a terminal.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-05-08T12:49:20.694Z
Learnt from: geetikakay
Repo: RedHatQE/openshift-virtualization-tests PR: 4788
File: utilities/os_utils.py:257-262
Timestamp: 2026-05-08T12:49:20.694Z
Learning: In RedHatQE/openshift-virtualization-tests, the Ruff flake8-boolean-trap rules FBT001/FBT002 are intentionally not enabled (pyproject.toml does not select the FBT rules; confirmed via `ruff check --show-settings`). Therefore, do not flag boolean positional parameters as FBT001/FBT002 violations in this repository. If Ruff configuration changes and starts selecting FBT rules, this exception should be reconsidered.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-05-12T05:10:24.601Z
Learnt from: acinko-rh
Repo: RedHatQE/openshift-virtualization-tests PR: 4780
File: tests/storage/utils.py:568-572
Timestamp: 2026-05-12T05:10:24.601Z
Learning: In this repository, Ruff rule UP043 ("unnecessary default type arguments") is enforced. When annotating `collections.abc.Generator` return types, prefer the single-parameter form `Generator[YieldType]` rather than `Generator[YieldType, None, None]`. Explicit `None, None` for the SendType and ReturnType are unnecessary defaults (per PEP 696) and will trigger UP043. Apply this consistently across all Python files.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-05-13T19:23:09.603Z
Learnt from: Anatw
Repo: RedHatQE/openshift-virtualization-tests PR: 4833
File: tests/network/localnet/migration_stuntime/libstuntime.py:25-25
Timestamp: 2026-05-13T19:23:09.603Z
Learning: In this repository, do not recommend adding `from __future__ import annotations` to fix forward-reference type annotation issues (e.g., Ruff UP037). Follow the established convention: use quoted string type annotations for forward references when the referenced class/type is defined later in the same file (e.g., `"ContinuousPing"`), and prefer `typing.Self` for self-referential return types.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-05-18T06:30:56.781Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4819
File: utilities/unittests/test_bitwarden.py:207-207
Timestamp: 2026-05-18T06:30:56.781Z
Learning: During Ruff/lint rule-enablement PRs in this repository (e.g., when introducing a new rule like PLC0415), it’s acceptable to keep CI green by adding per-line, targeted suppressions for pre-existing violations: add only `# noqa: <single-ruff-rule-id>` at the end of the specific violating line. In this PR context, reviewers should NOT flag these targeted `# noqa: PLC0415` comments as policy violations, assuming the suppression is for a pre-existing issue and is documented in the PR description as a candidate for follow-up cleanup. Do not allow blanket `# noqa` (without a specific rule) or `per-file-ignores`; those remain disallowed.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-05-18T06:31:12.015Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4819
File: utilities/unittests/test_pytest_utils.py:270-270
Timestamp: 2026-05-18T06:31:12.015Z
Learning: In RedHatQE/openshift-virtualization-tests, if a PR is a Ruff rule-enforcement PR and its “Special notes for reviewer” documents that pre-existing Ruff violations are being temporarily handled via per-line suppressions (e.g., `# noqa: PLC0415`) to keep CI green, reviewers should treat those specific `# noqa: <rule>` comments as an agreed, temporary mechanism. Do not flag them as code-quality issues and do not recommend removing, consolidating, or refactoring those suppressions within the same PR; cleanup/remediation is expected to happen in dedicated follow-up PRs instead.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-05-18T06:31:15.083Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4819
File: utilities/unittests/test_data_collector.py:304-304
Timestamp: 2026-05-18T06:31:15.083Z
Learning: When reviewing Python code in this repository for Ruff/linter rule rollouts, do not treat temporary suppression comments as violations in the specific migration scenario where a PR enables a new Ruff rule (e.g., PLC0415) and the PR description explicitly documents that all *pre-existing* violations are being annotated with `# noqa: <RULE>` as a short-lived measure. In that case, only flag `# noqa: <RULE>` suppressions that are newly introduced on code that did not previously violate the rule—i.e., verify via the PR diff against the prior state (and/or prior Ruff findings) that the suppressed line was already violating before the rule was enabled. Ignore suppressions that are covering violations that existed before the new rule rollout and were intentionally bulk-added for cleanup in follow-up PRs.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-05-18T06:31:20.848Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4819
File: utilities/unittests/test_hco.py:501-501
Timestamp: 2026-05-18T06:31:20.848Z
Learning: When reviewing Python code in RedHatQE/openshift-virtualization-tests, avoid flagging Ruff `# noqa: <RULE>` suppressions as issues if they were intentionally added as a temporary measure to keep CI green after a PR enables a new Ruff/lint rule (e.g., PLC0415) and the PR description documents this under "Special notes for reviewer". Treat these suppressions as deferred technical debt. Only flag `# noqa: PLC0415` (and similar rule-specific suppressions) when they are newly introduced without an accompanying documented intent in the PR (and thus appear to be masking a new violation rather than a pre-existing one).

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-05-18T09:09:09.479Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4878
File: utilities/unittests/test_pytest_utils.py:2194-2197
Timestamp: 2026-05-18T09:09:09.479Z
Learning: In this repository (RedHatQE/openshift-virtualization-tests), do not flag missing return type annotations or missing argument type annotations as Ruff “ANN” rule violations (e.g., ANN001/ANN002/ANN201/ANN202). The repo’s Ruff configuration does not enable ANN rules and only uses `extend-select = ["PLC0415"]`, so missing type annotations should not be treated as ANN lint failures during code review.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-05-19T07:48:17.119Z
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 4784
File: libs/vm/affinity.py:104-104
Timestamp: 2026-05-19T07:48:17.119Z
Learning: When using Kubernetes API models like `NodeSelectorRequirement` or `LabelSelectorRequirement` with operators `Exists` or `DoesNotExist`, the `values` field must not be non-empty. It is valid for `values` to be omitted / left as `None` (Python) / passed as `null`—Kubernetes rejects non-empty `values` for these operators, but does not require the field to be present or explicitly set to an empty list. In code reviews, do not treat missing `values=[]` for `Exists`/`DoesNotExist` as a validation issue; only flag cases where `values` is provided with actual elements.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-05-19T07:48:17.119Z
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 4784
File: libs/vm/affinity.py:104-104
Timestamp: 2026-05-19T07:48:17.119Z
Learning: When constructing Kubernetes `NodeSelectorRequirement` (or `LabelSelectorRequirement`) objects in code, do not treat `values` being omitted, `None`, or an empty list as an API-validation problem when the requirement’s operator is `Exists` or `DoesNotExist`. Per the Kubernetes API spec, these operators only require that the `values` array is not non-empty (i.e., it must be empty); they do not require the field to be explicitly present as `[]`. Therefore, reviewers should not flag `values=None`/missing `values` for `Exists`/`DoesNotExist`.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-05-26T15:52:31.613Z
Learnt from: rlobillo
Repo: RedHatQE/openshift-virtualization-tests PR: 4983
File: utilities/hco.py:376-378
Timestamp: 2026-05-26T15:52:31.613Z
Learning: For Python files in this repo, don’t raise review findings for missing type hints or missing/Google-style docstrings on an existing function when the PR’s only functional change is adding one or more new parameters to that function and the PR does not otherwise refactor or substantially rewrite its body/signature. Treat type-annotation/docstring improvements as out of scope for focused parameter-add PRs and defer them to a follow-up. Only raise missing type-hint or docstring issues when the PR introduces an entirely new function or substantially rewrites an existing one.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-01-19T07:53:55.780Z
Learnt from: qwang1
Repo: RedHatQE/openshift-virtualization-tests PR: 3301
File: utilities/unittests/test_oadp.py:48-57
Timestamp: 2026-01-19T07:53:55.780Z
Learning: Enforce that pytest markers (e.g., marker requirement for integration tests) apply only to integration/functional tests under the tests/ directory. Unit tests located in utilities/unittests/ must not use pytest markers, following repository convention. For all unit test files under utilities/unittests (and subdirectories), do not require or mandate markers; for integration tests under tests/ and its subdirectories, ensure markers are used as per the project rule.

Applied to files:

  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-02-18T06:34:38.042Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 3847
File: tests/virt/cluster/common_templates/utils.py:58-58
Timestamp: 2026-02-18T06:34:38.042Z
Learning: In RedHatQE/openshift-virtualization-tests, treat 'public' functions as those defined in any Python files under libs/ or utilities/ (any depth). Functions inside nested test directories (e.g., tests/virt/cluster/common_templates/, tests/virt/node/, etc.) are test helpers and do not require Google-format docstrings unless explicitly requested. Use this rule during reviews to decide whether to enforce docstrings on public API functions in libs/utilities.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-02-23T21:16:51.920Z
Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 3883
File: utilities/unittests/test_os_utils.py:358-371
Timestamp: 2026-02-23T21:16:51.920Z
Learning: In the openshift-virtualization-tests repository, the guideline to require named arguments for function calls with more than one argument does not apply to unit tests under utilities/unittests/. For these tests, allow standard pytest patterns like pytest.raises(ExceptionType, match="pattern") without requiring named parameters. This exception applies specifically to files under utilities/unittests/ and does not generalize beyond that directory.

Applied to files:

  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-03T15:38:22.954Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4701
File: utilities/unittests/test_database.py:12-12
Timestamp: 2026-05-03T15:38:22.954Z
Learning: In RedHatQE/openshift-virtualization-tests unit tests under `utilities/unittests/`, it’s intentional/pre-existing to use `sys.path.insert(0, ...)` in cases where tests need to import local modules. In lint-cleanup PRs, reviewers should not flag this `sys.path` manipulation as a violation. Also, don’t re-add `# noqa: E402` or other import-order suppressions if `ruff/flake8` no longer reports E402 for that import—handle any broader refactor (to remove the `sys.path` hack) in a dedicated follow-up.

Applied to files:

  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-18T06:31:30.830Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4819
File: utilities/unittests/test_sanity.py:22-22
Timestamp: 2026-05-18T06:31:30.830Z
Learning: In this repo’s unit test files under `utilities/unittests/`, treat `# noqa: PLC0415` (import-outside-top-level) suppressions as intentional and do not flag them as violations when enabling Ruff’s PLC0415 rule incrementally. These suppressions are expected as temporary measures and are documented in the PR description; they should only be targeted for later cleanup follow-ups.
Also, allow imports placed inside unit test methods under `utilities/unittests/` when they are intentionally positioned to run after `patch` decorators are applied—especially when the imported module has import-time side effects.

Applied to files:

  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-03T15:38:09.624Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4701
File: tests/virt/node/general/test_windows_vtpm_bitlocker.py:50-52
Timestamp: 2026-05-03T15:38:09.624Z
Learning: During review of PRs that are lint cleanups or tooling/version bumps, do not flag code-quality issues for patterns that pre-existed before the PR. Specifically, if the diff does not introduce/modify constructs such as nested `if` blocks or unnecessary list comprehensions, treat them as known/deferred and leave them for dedicated follow-up cleanup PRs. Only raise issues when the PR itself adds, changes, or refactors the problematic code.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-05-15T18:42:02.504Z
Learnt from: geetikakay
Repo: RedHatQE/openshift-virtualization-tests PR: 4860
File: utilities/hco.py:385-389
Timestamp: 2026-05-15T18:42:02.504Z
Learning: In this repository, under the Python `utilities/` directory (utility/helper modules, not tests), do not flag bare `assert` statements as correctness or style issues. The codebase conventionally uses `assert` in these utilities (e.g., `utilities/virt.py`, `utilities/infra.py`, etc.) and does not enforce running Python with `-O`/`PYTHONOPTIMIZE`, so the usual “asserts may be stripped” concern should not be treated as a review blocker here.

Applied to files:

  • utilities/unittests/test_os_utils.py
  • utilities/os_utils.py
📚 Learning: 2026-05-18T10:38:33.820Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4884
File: .coderabbit.yaml:79-80
Timestamp: 2026-05-18T10:38:33.820Z
Learning: In this repo, pytest tests are expected to live only in files named `test_*.py`. When applying CodeRabbit STP case B (newly added `def test_*` inside an existing test file), scope the check to existing files that match `test_*.py` and do not broaden it to newly added `def test_*` found in other non-`test_*.py` Python files.

Applied to files:

  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-06-01T06:43:07.271Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4908
File: utilities/unittests/test_pytest_utils.py:374-374
Timestamp: 2026-06-01T06:43:07.271Z
Learning: In RedHatQE/openshift-virtualization-tests, do not require STP/RFE/Jira traceability links in unit test function docstrings for any `test_*.py` file under `utilities/unittests/` (including subdirectories). Only integration/functional tests under the repository’s `tests/` directory should be checked for STP/RFE/Jira traceability links; therefore, missing STP/RFE/Jira docstring links in `utilities/unittests/**/test_*.py` should not be flagged.

Applied to files:

  • utilities/unittests/test_os_utils.py
🪛 GitHub Check: can-be-merged
utilities/os_utils.py

[error] 302-302: Unresolved review conversation found in PR (#5139 (comment)).


[error] 302-302: Unresolved review conversation found in PR (#5139 (comment)).

🔇 Additional comments (1)
utilities/os_utils.py (1)

8-8: LGTM!

Also applies to: 293-293, 300-302

…NAME

Single-arch clusters use DataSource names without architecture suffixes (e.g., 'rhel9'), while multi-arch clusters include the suffix (e.g., 'rhel9-arm64', 'rhel9-s390x' ).
Add multi-arch check before appending suffix, fixing test_vmexport_snapshot_manifests failures on single-arch s390x clusters.

- utilities/os_utils.py: Add is_multi_arch flag in generate_linux_instance_type_os_matrix() to check cluster architecture via get_cluster_architecture() before appending {arch} suffix to DATA_SOURCE_NAME
- utilities/unittests/test_os_utils.py: Mock get_cluster_architecture() to return multi-arch cluster ({"amd64", "arm64"}) in tests that verify arch suffix is correctly appended to DataSource names for ARM arch_suffix tests

Signed-off-by: Alexander Mamani <alexander.mamani@ibm.com>
@alexandermamaniy alexandermamaniy force-pushed the fix/datasource-name-single-arch-vmexport-test branch from 375708c to 45c95bb Compare June 9, 2026 15:47
@openshift-virtualization-qe-bot-4

Copy link
Copy Markdown

Clean rebase detected — no code changes compared to previous head (375708c).
The following labels were preserved: verified, changes-requested-vsibirsk, commented-geetikakay, commented-coderabbitai[bot], lgtm-coderabbitai[bot], commented-alexandermamaniy.

@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: 1

Caution

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

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

336-353: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

MEDIUM: Add single-arch regression coverage for the new branch

These changes validate only the multi-arch path. Please add a single-arch case (len(get_cluster_architecture()) == 1) to verify DATA_SOURCE_NAME stays unsuffixed for the fixed scenario.

Suggested additional test
+    `@patch`("utilities.os_utils.get_cluster_architecture")
+    def test_arch_suffix_omitted_from_data_source_on_single_arch_cluster(self, mock_get_cluster_arch):
+        """Single-arch cluster keeps DataSource unsuffixed even when arch_suffix is provided."""
+        mock_get_cluster_arch.return_value = {"s390x"}
+        result = generate_linux_instance_type_os_matrix(
+            os_name="rhel",
+            preferences=[RHEL10_PREFERENCE],
+            arch_suffix="s390x",
+        )
+
+        config = result[0][f"{RHEL10_PREFERENCE}.s390x"]
+        assert config["DATA_SOURCE_NAME"] == "rhel10"
🤖 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/unittests/test_os_utils.py` around lines 336 - 353, Add a new unit
test for the single-arch case by mocking get_cluster_architecture to return a
single element (e.g., {"amd64"}) and calling
generate_linux_instance_type_os_matrix with os_name="rhel",
preferences=[RHEL10_PREFERENCE], and arch_suffix=ARM_64 (and appropriate
add_arch_suffix setting if relevant); assert that the resulting config's
DATA_SOURCE_NAME equals the unsuffixed value "rhel10" (i.e., no "-{ARM_64}"
suffix) while keeping other existing assertions (e.g., preference handling)
consistent with the single-arch behavior.
🤖 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/os_utils.py`:
- Around line 293-302: The code unconditionally calls get_cluster_architecture()
to set is_multi_arch even when arch_suffix is falsy, causing unnecessary
external lookups; change the logic in the loop that builds preference_config so
that get_cluster_architecture() is only invoked when arch_suffix and
add_arch_suffix are truthy (e.g., compute is_multi_arch lazily or guard the call
inside the branch that uses arch_suffix), and ensure DATA_SOURCE_NAME still
falls back to data_source_name when arch_suffix is not present; update
references around the variables arch_suffix, add_arch_suffix, is_multi_arch,
_format_data_source_name(), PREFERENCE_STR and DATA_SOURCE_NAME so behavior is
unchanged for suffixed paths but avoids the cluster lookup for the default
(non-suffixed) path.

---

Outside diff comments:
In `@utilities/unittests/test_os_utils.py`:
- Around line 336-353: Add a new unit test for the single-arch case by mocking
get_cluster_architecture to return a single element (e.g., {"amd64"}) and
calling generate_linux_instance_type_os_matrix with os_name="rhel",
preferences=[RHEL10_PREFERENCE], and arch_suffix=ARM_64 (and appropriate
add_arch_suffix setting if relevant); assert that the resulting config's
DATA_SOURCE_NAME equals the unsuffixed value "rhel10" (i.e., no "-{ARM_64}"
suffix) while keeping other existing assertions (e.g., preference handling)
consistent with the single-arch behavior.
🪄 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: a8545675-dc7d-43e8-854d-cafb01104218

📥 Commits

Reviewing files that changed from the base of the PR and between 375708c and 45c95bb.

📒 Files selected for processing (2)
  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (4)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Never add linter suppressions like # noqa, # type: ignore, or # pylint: disable. Fix the code instead. If you believe a rule is wrong, ask the user for explicit approval.
Search the codebase for existing implementations before writing new code. Check utilities/, libs/, tests/, and pyproject.toml dependencies. Never duplicate logic—extract to shared modules. Use pyhelper_utils.shell.run_command for shell commands instead of subprocess.run, and use ocp-resources classes instead of raw YAML dicts.
Type hints are MANDATORY. Use mypy strict mode in libs/ and all new public functions under utilities. Use TYPE_CHECKING for type-only imports to avoid runtime overhead and circular imports.
Write Google-format docstrings for all public functions with non-obvious return values or side effects.
Always use uv run to execute commands. Never execute python, pip, pytest, tox, or pre-commit directly. Use uv run python, uv run pytest, uv run tox, uv run pre-commit, and uv add for package installation.
Always use absolute imports. Never use relative imports.
Prefer specific imports using from module import func for functions and constants. Use from package import module (then module.Name) when retaining the module name meaningfully improves readability. Never use bare import module without a from clause.
Always use named arguments for function calls with more than one argument.
Never use single-letter variable names. Always use descriptive, meaningful names.
No dead code. Every function, variable, and fixture must be used or removed. Code marked with # skip-unused-code is excluded from dead code analysis (enforced via custom ruff plugin).
Prefer direct attribute access using foo.attr. Save to variables only when reusing the same attribute multiple times improves readability or extracting clarifies intent.
Imports must always be at the top of the module. Do not import inside functions.
No defensive programming. Fail...

Files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
**

⚙️ CodeRabbit configuration file

**: ## PR Template Validation
Check the PR description for required sections from .github/pull_request_template.md.
Required sections (must be present, even if empty):

  • ##### What this PR does / why we need it: — MUST be present AND have meaningful content.
    Flag as HIGH if the section is missing, empty, whitespace-only, contains only HTML comments,
    or contains only placeholder tokens such as TBD, TBA, N/A, -, , none, or ..
  • ##### Which issue(s) this PR fixes: — must be present (may be empty)
  • ##### Special notes for reviewer: — must be present (may be empty)
  • ##### jira-ticket: — must be present (may be empty)
    If any required section is absent, or What this PR does / why we need it: has no content,
    flag it as HIGH severity and ask the author to restore the missing template section(s).

Approval Policy

You may approve the PR when ALL of the following are true:

  • All your review comments have been addressed with either:
    • a code/doc change that fixes the issue, or
    • a substantive author response that justifies no code change.
      Thread "resolved" state alone is not sufficient.
      OR you had no review comments.
  • If you posted a test execution plan comment requesting tests, and the PR author replied
    with a comment explaining why the requested tests are not needed or were already covered,
    treat that as an acceptable response — do not block approval on the test plan alone.
  • The author's explanation must be reasonable and specific (not just "N/A" or "not needed").
    Accept explanations like: "these tests were already run in CI", "this change is docs-only",
    "the affected tests are quarantined", or "verified manually on cluster X".

Files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py

⚙️ CodeRabbit configuration file

**: # AI Review and Development Standards

Assisted-by: Claude noreply@anthropic.com

Coding standards, conventions, and review guidelines for openshift-virtualization-tests.

These rules apply to ALL contributors and review tools — human and AI alike.

Strict Rules (MANDATORY)

Linter Suppressions PROHIBITED

  • NEVER add # noqa, # type: ignore, # pylint: disable
  • NEVER disable linter/mypy rules to work around issues
  • FIX THE CODE - If linter complains, the code is wrong
  • If you think a rule is wrong: ASK the user for explicit approval

Code Reuse (Search-First Development)

Before writing ANY new code:

  1. SEARCH codebase for existing implementations
  2. CHECK utilities/ for shared functions
  3. CHECK libs/ for shared libraries
  4. CHECK tests/ for shared fixtures and helper functions
  5. CHECK pyproject.toml dependencies — project packages (e.g., pyhelper-utils, ocp-resources, openshift-python-wrapper) may already provide the functionality
  6. VERIFY no similar logic exists elsewhere
  7. NEVER duplicate logic - extract to shared module
  8. REUSE existing code and patterns — only write new when nothing exists

External package examples:

  • Shell commands — use pyhelper_utils.shell.run_command, NEVER use subprocess.run directly in test/utility code
  • OpenShift resources — use ocp-resources classes, NEVER construct raw YAML dicts

Python Requirements

  • Type hints MANDATORY - mypy strict mode in libs/, all new public functions under utilities MUST be typed
  • Use TYPE_CHECKING for type-only imports - wrap imports needed solely for type hints in if TYPE_CHECKING: to avoid runtime overhead and circular imports
  • Google-format docstrings REQUIRED - for all public functions with non-obvious return values OR side effects
  • No defensive programming - fail-fast, don't hide bugs with fake defaults (see exceptions below)
  • ALWAYS use uv run -...

Files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
utilities/unittests/**/*.py

📄 CodeRabbit inference engine (Custom checks)

Skip STP/RFE/Jira link requirements entirely for unit test files under utilities/unittests/ directory

Files:

  • utilities/unittests/test_os_utils.py
utilities/unittests/**

⚙️ CodeRabbit configuration file

utilities/unittests/**: ## Unit Tests — Relaxed Rules
Files under utilities/unittests/ are unit tests for shared utilities.
Do NOT enforce:

  • STD docstring format (Preconditions/Steps/Expected sections)
  • STP link requirements
  • RFE/Jira link requirements
  • Coverage tracking rules
    These rules apply only to feature/integration tests under tests/.
    DO still enforce: code quality, type hints, naming conventions, and all other coding standards.

Files:

  • utilities/unittests/test_os_utils.py
🧠 Learnings (33)
📚 Learning: 2026-01-12T11:24:13.825Z
Learnt from: servolkov
Repo: RedHatQE/openshift-virtualization-tests PR: 3387
File: tests/network/provider_migration/libprovider.py:50-52
Timestamp: 2026-01-12T11:24:13.825Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, when catching exceptions in Python, use LOGGER.error before re-raising and do not replace it with LOGGER.exception in except blocks. This follows the established pattern across the codebase.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-01-12T14:25:05.723Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 3366
File: tests/storage/cdi_clone/test_clone.py:5-9
Timestamp: 2026-01-12T14:25:05.723Z
Learning: In Python tests and utility code across the repository, bitmath.parse_string_unsafe correctly parses Kubernetes quantities (e.g., '4Gi', '512Mi', PVC storage requests) without supplying system=bitmath.NIST. There are 30+ usages indicating this is the standard behavior. Reviewers should verify that code that builds or compares quantity strings does not pass the NIST parameter, and if a new test relies on quantity parsing, assume no NIST parameter is required unless explicitly documented.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-01-20T01:03:13.139Z
Learnt from: servolkov
Repo: RedHatQE/openshift-virtualization-tests PR: 3387
File: tests/network/provider_migration/libprovider.py:1-8
Timestamp: 2026-01-20T01:03:13.139Z
Learning: In the openshift-virtualization-tests repository, Python imports should consistently use module-level imports for the logging module (i.e., import logging) rather than from logging import ... The established pattern spans 270+ files and should not be flagged for refactoring. Apply this guideline to Python files across the repo (e.g., tests/network/provider_migration/libprovider.py).

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-01-21T21:26:41.805Z
Learnt from: geetikakay
Repo: RedHatQE/openshift-virtualization-tests PR: 3559
File: utilities/infra.py:251-254
Timestamp: 2026-01-21T21:26:41.805Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, when reviewing Python code, recognize that with Python 3.14 the syntax 'except ValueError, TypeError:' is valid if there is no 'as' clause, and should not be flagged as Python 2 syntax. If you use an 'as' binding (e.g., 'except (ValueError, TypeError) as e:'), parentheses are required. Ensure this pattern is version-consistent and not flagged as Python 2 syntax when 'as' is absent.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-01-25T13:18:21.675Z
Learnt from: jpeimer
Repo: RedHatQE/openshift-virtualization-tests PR: 3571
File: tests/storage/storage_migration/utils.py:158-167
Timestamp: 2026-01-25T13:18:21.675Z
Learning: In reviews of the openshift-virtualization-tests repo (and similar Python code), avoid suggesting minor stylistic changes that require extra verification (e.g., removing dict.keys() checks for membership) unless the change has clear correctness or maintainability impact. Focus on fixes with observable behavior, security, performance, or maintainability benefits; defer low-impact style tweaks that are costly to verify.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-02-18T06:35:39.536Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 3847
File: utilities/virt.py:2449-2453
Timestamp: 2026-02-18T06:35:39.536Z
Learning: In Python code, a function named clearly and self-descriptively can be deemed not to require a docstring. However, treat this as a context-specific guideline and not a universal rule. For public APIs or functions with side effects, prefer concise docstrings explaining behavior, inputs, outputs, and side effects. This guidance is based on the example in utilities/virt.py from RedHatQE/openshift-virtualization-tests where validate_libvirt_persistent_domain(vm, admin_client) was considered self-documenting.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-02-23T16:33:22.070Z
Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 3883
File: utilities/pytest_utils.py:441-463
Timestamp: 2026-02-23T16:33:22.070Z
Learning: In Python code reviews, the guideline to always use named arguments for multi-argument calls does not apply to built-ins or methods that have positional-only parameters (those defined with a / in their signature). Do not flag or require named arguments for calls like dict.get(key, default=None, /), list.pop(), str.split(sep, maxsplit) and similar built-ins that cannot accept keyword arguments. Apply the named-argument rule only to functions/methods that explicitly accept keyword arguments.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-03-17T01:32:02.617Z
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 4118
File: utilities/database.py:0-0
Timestamp: 2026-03-17T01:32:02.617Z
Learning: In RedHatQE/openshift-virtualization-tests, when reviewing Python files, post targeted inline comments on the Files changed tab at the exact location (file and line) of the issue rather than opening a single discussion thread for multiple issues. This should be done for each applicable location to improve traceability and clarity. If multiple issues exist in the same file, address them with separate inline comments pointing to the specific lines.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-03-17T01:32:02.617Z
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 4118
File: utilities/database.py:0-0
Timestamp: 2026-03-17T01:32:02.617Z
Learning: In the RedHatQE/openshift-virtualization-tests repository, CodeRabbit should post targeted inline comments at each applicable location in the Files Changed tab, rather than aggregating multiple issues into a single PR discussion thread reply. This guideline applies to all Python files (any file ending in .py) changed in a PR; for non-Python files, follow the same inline-comment-at-location principle if relevant.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-04T13:45:29.122Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4725
File: utilities/console.py:54-59
Timestamp: 2026-05-04T13:45:29.122Z
Learning: During review of RedHatQE/openshift-virtualization-tests “lint-cleanup” PRs (e.g., changes targeting lint issues like stale noqa/utf-8 headers), do not flag existing `# type: ignore` directives that were already present before the PR and were not introduced or modified by the PR. Only raise findings for `# type: ignore` suppressions that the PR itself adds, changes, or otherwise makes newly effective (i.e., they appear in the diff as additions/edits).

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-04T13:45:33.892Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4725
File: tests/virt/cluster/common_templates/centos/test_centos_os_support.py:78-83
Timestamp: 2026-05-04T13:45:33.892Z
Learning: When reviewing lint-cleanup or formatting-only pull requests in this repo (e.g., changes like removing/updating `# noqa` comments or UTF-8 headers), do not raise findings for code patterns that already existed before the PR. Specifically, if a problematic construct such as `.is_connective(tcp_timeout=120)` was present in the base branch, suppress that finding and only raise issues when the PR itself introduces or modifies that construct (i.e., the diff adds/changes the call or its arguments). Apply this rule across all Python files (`**/*.py`).

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-05T17:01:15.294Z
Learnt from: dshchedr
Repo: RedHatQE/openshift-virtualization-tests PR: 4739
File: tests/virt/node/descheduler/conftest.py:2-2
Timestamp: 2026-05-05T17:01:15.294Z
Learning: In this repo’s Python code, it’s acceptable (and preferred by convention) to build `run_command` inputs using `shlex.split(f"<command> {arg}")` rather than converting to direct list literals like `['oc', 'adm', 'uncordon', name]`. During code review, generally don’t flag `shlex.split(...)` usage for `run_command` calls and don’t suggest replacing it with list literals; the string-form pattern is used to keep commands readable and consistent with how they’re typed in a terminal.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-08T12:49:20.694Z
Learnt from: geetikakay
Repo: RedHatQE/openshift-virtualization-tests PR: 4788
File: utilities/os_utils.py:257-262
Timestamp: 2026-05-08T12:49:20.694Z
Learning: In RedHatQE/openshift-virtualization-tests, the Ruff flake8-boolean-trap rules FBT001/FBT002 are intentionally not enabled (pyproject.toml does not select the FBT rules; confirmed via `ruff check --show-settings`). Therefore, do not flag boolean positional parameters as FBT001/FBT002 violations in this repository. If Ruff configuration changes and starts selecting FBT rules, this exception should be reconsidered.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-12T05:10:24.601Z
Learnt from: acinko-rh
Repo: RedHatQE/openshift-virtualization-tests PR: 4780
File: tests/storage/utils.py:568-572
Timestamp: 2026-05-12T05:10:24.601Z
Learning: In this repository, Ruff rule UP043 ("unnecessary default type arguments") is enforced. When annotating `collections.abc.Generator` return types, prefer the single-parameter form `Generator[YieldType]` rather than `Generator[YieldType, None, None]`. Explicit `None, None` for the SendType and ReturnType are unnecessary defaults (per PEP 696) and will trigger UP043. Apply this consistently across all Python files.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-13T19:23:09.603Z
Learnt from: Anatw
Repo: RedHatQE/openshift-virtualization-tests PR: 4833
File: tests/network/localnet/migration_stuntime/libstuntime.py:25-25
Timestamp: 2026-05-13T19:23:09.603Z
Learning: In this repository, do not recommend adding `from __future__ import annotations` to fix forward-reference type annotation issues (e.g., Ruff UP037). Follow the established convention: use quoted string type annotations for forward references when the referenced class/type is defined later in the same file (e.g., `"ContinuousPing"`), and prefer `typing.Self` for self-referential return types.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-18T06:30:56.781Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4819
File: utilities/unittests/test_bitwarden.py:207-207
Timestamp: 2026-05-18T06:30:56.781Z
Learning: During Ruff/lint rule-enablement PRs in this repository (e.g., when introducing a new rule like PLC0415), it’s acceptable to keep CI green by adding per-line, targeted suppressions for pre-existing violations: add only `# noqa: <single-ruff-rule-id>` at the end of the specific violating line. In this PR context, reviewers should NOT flag these targeted `# noqa: PLC0415` comments as policy violations, assuming the suppression is for a pre-existing issue and is documented in the PR description as a candidate for follow-up cleanup. Do not allow blanket `# noqa` (without a specific rule) or `per-file-ignores`; those remain disallowed.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-18T06:31:12.015Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4819
File: utilities/unittests/test_pytest_utils.py:270-270
Timestamp: 2026-05-18T06:31:12.015Z
Learning: In RedHatQE/openshift-virtualization-tests, if a PR is a Ruff rule-enforcement PR and its “Special notes for reviewer” documents that pre-existing Ruff violations are being temporarily handled via per-line suppressions (e.g., `# noqa: PLC0415`) to keep CI green, reviewers should treat those specific `# noqa: <rule>` comments as an agreed, temporary mechanism. Do not flag them as code-quality issues and do not recommend removing, consolidating, or refactoring those suppressions within the same PR; cleanup/remediation is expected to happen in dedicated follow-up PRs instead.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-18T06:31:15.083Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4819
File: utilities/unittests/test_data_collector.py:304-304
Timestamp: 2026-05-18T06:31:15.083Z
Learning: When reviewing Python code in this repository for Ruff/linter rule rollouts, do not treat temporary suppression comments as violations in the specific migration scenario where a PR enables a new Ruff rule (e.g., PLC0415) and the PR description explicitly documents that all *pre-existing* violations are being annotated with `# noqa: <RULE>` as a short-lived measure. In that case, only flag `# noqa: <RULE>` suppressions that are newly introduced on code that did not previously violate the rule—i.e., verify via the PR diff against the prior state (and/or prior Ruff findings) that the suppressed line was already violating before the rule was enabled. Ignore suppressions that are covering violations that existed before the new rule rollout and were intentionally bulk-added for cleanup in follow-up PRs.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-18T06:31:20.848Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4819
File: utilities/unittests/test_hco.py:501-501
Timestamp: 2026-05-18T06:31:20.848Z
Learning: When reviewing Python code in RedHatQE/openshift-virtualization-tests, avoid flagging Ruff `# noqa: <RULE>` suppressions as issues if they were intentionally added as a temporary measure to keep CI green after a PR enables a new Ruff/lint rule (e.g., PLC0415) and the PR description documents this under "Special notes for reviewer". Treat these suppressions as deferred technical debt. Only flag `# noqa: PLC0415` (and similar rule-specific suppressions) when they are newly introduced without an accompanying documented intent in the PR (and thus appear to be masking a new violation rather than a pre-existing one).

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-18T09:09:09.479Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4878
File: utilities/unittests/test_pytest_utils.py:2194-2197
Timestamp: 2026-05-18T09:09:09.479Z
Learning: In this repository (RedHatQE/openshift-virtualization-tests), do not flag missing return type annotations or missing argument type annotations as Ruff “ANN” rule violations (e.g., ANN001/ANN002/ANN201/ANN202). The repo’s Ruff configuration does not enable ANN rules and only uses `extend-select = ["PLC0415"]`, so missing type annotations should not be treated as ANN lint failures during code review.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-19T07:48:17.119Z
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 4784
File: libs/vm/affinity.py:104-104
Timestamp: 2026-05-19T07:48:17.119Z
Learning: When using Kubernetes API models like `NodeSelectorRequirement` or `LabelSelectorRequirement` with operators `Exists` or `DoesNotExist`, the `values` field must not be non-empty. It is valid for `values` to be omitted / left as `None` (Python) / passed as `null`—Kubernetes rejects non-empty `values` for these operators, but does not require the field to be present or explicitly set to an empty list. In code reviews, do not treat missing `values=[]` for `Exists`/`DoesNotExist` as a validation issue; only flag cases where `values` is provided with actual elements.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-19T07:48:17.119Z
Learnt from: azhivovk
Repo: RedHatQE/openshift-virtualization-tests PR: 4784
File: libs/vm/affinity.py:104-104
Timestamp: 2026-05-19T07:48:17.119Z
Learning: When constructing Kubernetes `NodeSelectorRequirement` (or `LabelSelectorRequirement`) objects in code, do not treat `values` being omitted, `None`, or an empty list as an API-validation problem when the requirement’s operator is `Exists` or `DoesNotExist`. Per the Kubernetes API spec, these operators only require that the `values` array is not non-empty (i.e., it must be empty); they do not require the field to be explicitly present as `[]`. Therefore, reviewers should not flag `values=None`/missing `values` for `Exists`/`DoesNotExist`.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-26T15:52:31.613Z
Learnt from: rlobillo
Repo: RedHatQE/openshift-virtualization-tests PR: 4983
File: utilities/hco.py:376-378
Timestamp: 2026-05-26T15:52:31.613Z
Learning: For Python files in this repo, don’t raise review findings for missing type hints or missing/Google-style docstrings on an existing function when the PR’s only functional change is adding one or more new parameters to that function and the PR does not otherwise refactor or substantially rewrite its body/signature. Treat type-annotation/docstring improvements as out of scope for focused parameter-add PRs and defer them to a follow-up. Only raise missing type-hint or docstring issues when the PR introduces an entirely new function or substantially rewrites an existing one.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-02-18T06:34:38.042Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 3847
File: tests/virt/cluster/common_templates/utils.py:58-58
Timestamp: 2026-02-18T06:34:38.042Z
Learning: In RedHatQE/openshift-virtualization-tests, treat 'public' functions as those defined in any Python files under libs/ or utilities/ (any depth). Functions inside nested test directories (e.g., tests/virt/cluster/common_templates/, tests/virt/node/, etc.) are test helpers and do not require Google-format docstrings unless explicitly requested. Use this rule during reviews to decide whether to enforce docstrings on public API functions in libs/utilities.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-03T15:38:09.624Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4701
File: tests/virt/node/general/test_windows_vtpm_bitlocker.py:50-52
Timestamp: 2026-05-03T15:38:09.624Z
Learning: During review of PRs that are lint cleanups or tooling/version bumps, do not flag code-quality issues for patterns that pre-existed before the PR. Specifically, if the diff does not introduce/modify constructs such as nested `if` blocks or unnecessary list comprehensions, treat them as known/deferred and leave them for dedicated follow-up cleanup PRs. Only raise issues when the PR itself adds, changes, or refactors the problematic code.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-15T18:42:02.504Z
Learnt from: geetikakay
Repo: RedHatQE/openshift-virtualization-tests PR: 4860
File: utilities/hco.py:385-389
Timestamp: 2026-05-15T18:42:02.504Z
Learning: In this repository, under the Python `utilities/` directory (utility/helper modules, not tests), do not flag bare `assert` statements as correctness or style issues. The codebase conventionally uses `assert` in these utilities (e.g., `utilities/virt.py`, `utilities/infra.py`, etc.) and does not enforce running Python with `-O`/`PYTHONOPTIMIZE`, so the usual “asserts may be stripped” concern should not be treated as a review blocker here.

Applied to files:

  • utilities/os_utils.py
  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-01-07T11:51:57.253Z
Learnt from: qwang1
Repo: RedHatQE/openshift-virtualization-tests PR: 3301
File: utilities/unittests/test_oadp.py:5-5
Timestamp: 2026-01-07T11:51:57.253Z
Learning: In utilities/unittests/test_oadp.py and similar test files in this repo, include a # flake8: noqa: E402 directive to suppress E402 warnings caused by pre-commit checks. This is needed because mock setup must precede imports to avoid circular dependencies, and Ruff may report unused imports. Apply this directive to all similar test files that require imports to guard against circular import issues.

Applied to files:

  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-01-19T07:53:55.780Z
Learnt from: qwang1
Repo: RedHatQE/openshift-virtualization-tests PR: 3301
File: utilities/unittests/test_oadp.py:48-57
Timestamp: 2026-01-19T07:53:55.780Z
Learning: Enforce that pytest markers (e.g., marker requirement for integration tests) apply only to integration/functional tests under the tests/ directory. Unit tests located in utilities/unittests/ must not use pytest markers, following repository convention. For all unit test files under utilities/unittests (and subdirectories), do not require or mandate markers; for integration tests under tests/ and its subdirectories, ensure markers are used as per the project rule.

Applied to files:

  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-02-23T21:16:51.920Z
Learnt from: vsibirsk
Repo: RedHatQE/openshift-virtualization-tests PR: 3883
File: utilities/unittests/test_os_utils.py:358-371
Timestamp: 2026-02-23T21:16:51.920Z
Learning: In the openshift-virtualization-tests repository, the guideline to require named arguments for function calls with more than one argument does not apply to unit tests under utilities/unittests/. For these tests, allow standard pytest patterns like pytest.raises(ExceptionType, match="pattern") without requiring named parameters. This exception applies specifically to files under utilities/unittests/ and does not generalize beyond that directory.

Applied to files:

  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-03T15:38:22.954Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4701
File: utilities/unittests/test_database.py:12-12
Timestamp: 2026-05-03T15:38:22.954Z
Learning: In RedHatQE/openshift-virtualization-tests unit tests under `utilities/unittests/`, it’s intentional/pre-existing to use `sys.path.insert(0, ...)` in cases where tests need to import local modules. In lint-cleanup PRs, reviewers should not flag this `sys.path` manipulation as a violation. Also, don’t re-add `# noqa: E402` or other import-order suppressions if `ruff/flake8` no longer reports E402 for that import—handle any broader refactor (to remove the `sys.path` hack) in a dedicated follow-up.

Applied to files:

  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-18T06:31:30.830Z
Learnt from: EdDev
Repo: RedHatQE/openshift-virtualization-tests PR: 4819
File: utilities/unittests/test_sanity.py:22-22
Timestamp: 2026-05-18T06:31:30.830Z
Learning: In this repo’s unit test files under `utilities/unittests/`, treat `# noqa: PLC0415` (import-outside-top-level) suppressions as intentional and do not flag them as violations when enabling Ruff’s PLC0415 rule incrementally. These suppressions are expected as temporary measures and are documented in the PR description; they should only be targeted for later cleanup follow-ups.
Also, allow imports placed inside unit test methods under `utilities/unittests/` when they are intentionally positioned to run after `patch` decorators are applied—especially when the imported module has import-time side effects.

Applied to files:

  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-05-18T10:38:33.820Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4884
File: .coderabbit.yaml:79-80
Timestamp: 2026-05-18T10:38:33.820Z
Learning: In this repo, pytest tests are expected to live only in files named `test_*.py`. When applying CodeRabbit STP case B (newly added `def test_*` inside an existing test file), scope the check to existing files that match `test_*.py` and do not broaden it to newly added `def test_*` found in other non-`test_*.py` Python files.

Applied to files:

  • utilities/unittests/test_os_utils.py
📚 Learning: 2026-06-01T06:43:07.271Z
Learnt from: rnetser
Repo: RedHatQE/openshift-virtualization-tests PR: 4908
File: utilities/unittests/test_pytest_utils.py:374-374
Timestamp: 2026-06-01T06:43:07.271Z
Learning: In RedHatQE/openshift-virtualization-tests, do not require STP/RFE/Jira traceability links in unit test function docstrings for any `test_*.py` file under `utilities/unittests/` (including subdirectories). Only integration/functional tests under the repository’s `tests/` directory should be checked for STP/RFE/Jira traceability links; therefore, missing STP/RFE/Jira docstring links in `utilities/unittests/**/test_*.py` should not be flagged.

Applied to files:

  • utilities/unittests/test_os_utils.py
🔇 Additional comments (1)
utilities/os_utils.py (1)

8-8: LGTM!

Comment thread utilities/os_utils.py
Comment on lines +293 to +302
is_multi_arch = len(get_cluster_architecture()) > 1

for preference in preferences:
arch_preference = f"{preference}.{arch_suffix}" if arch_suffix and add_arch_suffix else preference
data_source_name = _format_data_source_name(preference_name=preference)
preference_config: dict[str, Any] = {
PREFERENCE_STR: arch_preference,
DATA_SOURCE_NAME: f"{data_source_name}-{arch_suffix}" if arch_suffix else data_source_name,
DATA_SOURCE_NAME: f"{data_source_name}-{arch_suffix}"
if arch_suffix and is_multi_arch
else data_source_name,

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

HIGH: Avoid unconditional cluster lookup on the default path

Line 293 calls get_cluster_architecture() even when arch_suffix is not provided. That introduces an unnecessary external dependency and can fail callers that only need the non-suffixed path.

Proposed fix
-    is_multi_arch = len(get_cluster_architecture()) > 1
+    is_multi_arch = bool(arch_suffix) and len(get_cluster_architecture()) > 1

As per coding guidelines: “Function behavior must be controlled via explicit arguments, not hardcoded internally.”

🤖 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/os_utils.py` around lines 293 - 302, The code unconditionally calls
get_cluster_architecture() to set is_multi_arch even when arch_suffix is falsy,
causing unnecessary external lookups; change the logic in the loop that builds
preference_config so that get_cluster_architecture() is only invoked when
arch_suffix and add_arch_suffix are truthy (e.g., compute is_multi_arch lazily
or guard the call inside the branch that uses arch_suffix), and ensure
DATA_SOURCE_NAME still falls back to data_source_name when arch_suffix is not
present; update references around the variables arch_suffix, add_arch_suffix,
is_multi_arch, _format_data_source_name(), PREFERENCE_STR and DATA_SOURCE_NAME
so behavior is unchanged for suffixed paths but avoids the cluster lookup for
the default (non-suffixed) path.

Source: Coding guidelines

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.

9 participants