[4.22] [Storage] Use source_dict for DataVolume source specification, refactor create_dv #5443#5528
Conversation
…or create_dv (RedHatQE#5443) `DataVolume` `source` argument is deprecated and needs to be replaced by the `source_dict` Refactor `create_dv` and all `DataVolume` instantiations to use `source_dict=` with `construct_datavolume_source_dict()` instead of the legacy `source=`. **Why:** The old `create_dv` interface mixed source specification, artifactory lifecycle, and annotation handling into a single flat parameter list. This made it unclear which parameters applied to which source types and coupled every caller to artifactory internals. **Changes:** - Extract `construct_datavolume_source_dict()` as a pure function for building DataVolume source dicts from typed parameters (`http`, `registry`, `pvc`, `blank`, `upload`) - Refactor `create_dv` to accept `source_dict=` directly, own artifactory lifecycle in `try/finally`, use generic `annotations` dict instead of `multus_annotation`/`bind_immediate`, and add full type hints - Rename parameters for consistency: `secret` → `secret_name`, `cert_configmap` → `cert_configmap_name`, `source_pvc` → `source_pvc_name`, `source_namespace` → `source_pvc_namespace` - Remove unused `hostpath_node` parameter - Migrate all 36 caller files to the new interface ##### Which issue(s) this PR fixes: ##### Special notes for reviewer: - The two commits are stacked: first refactors `create_dv` and updates callers using `create_dv`, second migrates direct `DataVolume()` instantiations to use `construct_datavolume_source_dict()` - No behavioral changes — all callers produce the same `DataVolume` specs as before - This change is needed as preparation for specifying the `architecture` in DV spec. <!-- full-ticket-url needs to be provided. This would add a link to the pull request to the jira and close it when the pull request is merged If the task is not tracked by a Jira ticket, just write "NONE". --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> * **New Features** * Added a shared helper to standardize DataVolume `source` setup for HTTP, registry, blank, PVC, and upload scenarios. * Standardized bind-immediate behavior using DataVolume annotations. * **Bug Fixes** * Corrected TLS/auth wiring by consistently using named secret and cert config-map references. * Improved Artifactory-backed image handling by enabling Artifactory mode where applicable. * Updated source PVC identification to use explicit name/namespace fields. * **Tests** * Refreshed many fixtures and helpers to use the unified `source_dict` flow and new parameter names. * Added unit tests validating the new source configuration helper, including URL validation behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Jenia Peimer <jpeimer@redhat.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
… conftest Centralize utilities.storage and utilities.ssp mocking in conftest.py, removing redundant mocking from individual test files. This allows imports to be at the top of each module, fixing ruff E402 violations. Also removes stale noqa comments and replaces deprecated IOError with OSError. Assisted-by: Claude <noreply@anthropic.com> Signed-off-by: Jenia Peimer <jpeimer@redhat.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (5)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Report bugs in Issues Welcome! 🎉This pull request will be automatically processed with the following features: 🔄 Automatic Actions
📋 Available CommandsPR Status Management
Review & Approval
Testing & Validation
Container Operations
Cherry-pick Operations
Branch Management
Label Management
✅ Merge RequirementsThis PR will be automatically approved when the following conditions are met:
📊 Review ProcessApprovers and ReviewersApprovers:
Reviewers:
Available Labels
AI Features
Security Checks
💡 Tips
📌 Additional InformationCustom Commands:
For more information, please refer to the project documentation or contact the maintainers. |
|
/build-and-push-container |
|
New container for quay.io/openshift-cnv/openshift-virtualization-tests:pr-5528 published |
|
/verified
openshift-virtualization-tests-runner/5876 |
Test execution plan request detailsCRITICAL: You MUST post an inline review comment on the first changed line of the first file. As an expert software testing engineer, analyze all modified files in this PR and create a targeted test execution plan. Analysis Requirements:
Output rules: Your deliverable: Test Execution Plan
Use these formats:
Real test commands (MANDATORY when changes affect session/runtime code): When the affected code runs at session/collection time (conftest fixtures, pytest plugins,
Example output for a session-startup fix: Guidelines:
Hardware-Related Checks (SR-IOV, GPU, DPDK): When PR modifies fixtures for hardware-specific resources:
CRITICAL WORKFLOW COMPLETION RULES: When responding to this test execution plan request, you MUST follow these rules EXACTLY:
ABSOLUTE PROHIBITIONS (violating these creates empty/meaningless reviews):
Remember: The pull request review is visible to users. Additional comments are redundant noise. CRITICAL — Verification rules for smoke and gating decisions: |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
git fetch origin pull/5528/head:pr5528 2>&1 | tail -5
git checkout pr5528 2>&1 | tail -5
echo "---- Files changed ----"
git diff --name-only origin/main...pr5528 | tail -200
echo "---- create_dv related diff in utilities/storage.py ----"
git diff origin/main...pr5528 --unified=0 -- utilities/storage.py | grep -E '^[+-]def |^[+-]class ' || true
echo "---- conftest diff ----"
git diff origin/main...pr5528 -- utilities/unittests/conftest.py | head -100
echo "---- callers of create_dv ----"
rg -l 'create_dv' --type py | head -50Length of output: 2578
If this recurs, please check the CodeRabbit GitHub App installation/credentials for this repository. I can retry the analysis once repository access is restored — just re-trigger with |
|
/lgtm |
1 similar comment
|
/lgtm |
|
/approve |
|
Successfully removed PR tag: quay.io/openshift-cnv/openshift-virtualization-tests:pr-5528. |
|
New container for quay.io/openshift-cnv/openshift-virtualization-tests:cnv-4.22 published |
What this PR does / why we need it:
Manual cherry-pick: #5443
Additional change (not in original PR), needed to fix the pre-commit:
Fix ruff E402 (module-level import not at top of file) lint errors across utilities/unittests/. The original PR introduced test_storage.py which had an E402 violation, and a ruff version bump exposed latent E402 violations in other unittest files by auto-removing stale # noqa: E402 comments.
Fix: Centralize utilities.storage and utilities.ssp sys.modules mocking in utilities/unittests/conftest.py (alongside the existing mocks for utilities.hco, utilities.infra, utilities.virt). This removes redundant mocking from individual test files, allowing their imports to be at the top of each module. Also replaces deprecated IOError with OSError in test_data_collector.py.
Which issue(s) this PR fixes:
Special notes for reviewer:
jira-ticket: