From 126335f4a7dc325f2ab1c6072335d83d928201ab Mon Sep 17 00:00:00 2001 From: Roni Kishner Date: Mon, 22 Jun 2026 20:14:38 +0300 Subject: [PATCH] [4.21] Remove DataSource storage class fallback from DV template helper (#5228) ##### What this PR does / why we need it: When calling `data_volume_template_with_source_ref_dict` we should either use it with explicit `storage_class` field, or omit the field and use the default storage class. Relying on the storage class of the DataSources can cause miss interpretations, while also causing issues since it is not possible to match the storage class to the DataSource, if a snap shot storage class is used. ##### Which issue(s) this PR fixes: Failing tests when snapshot storage classes are set. ##### Special notes for reviewer: Cherry-pick from main branch, original PR: https://github.com/RedHatQE/openshift-virtualization-tests/pull/4985 ##### jira-ticket: https://redhat.atlassian.net/browse/CNV-88988 Signed-off-by: Roni Kishner --- tests/conftest.py | 5 +++++ .../golden_images/test_common_templates_data_volumes.py | 3 ++- tests/storage/conftest.py | 5 ----- utilities/storage.py | 3 +-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 6e0afb826a..c1f01e4cdb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2799,6 +2799,11 @@ def rwx_fs_available_storage_classes_names(cluster_storage_classes_names): ] +@pytest.fixture() +def storage_class_name_scope_function(storage_class_matrix__function__): + return [*storage_class_matrix__function__][0] + + @pytest.fixture(scope="session") def rhsm_credentials_from_bitwarden(): return get_cnv_tests_secret_by_name(secret_name="RHSM_CREDENTIALS") diff --git a/tests/infrastructure/golden_images/test_common_templates_data_volumes.py b/tests/infrastructure/golden_images/test_common_templates_data_volumes.py index add79c09ac..0d8afdec21 100644 --- a/tests/infrastructure/golden_images/test_common_templates_data_volumes.py +++ b/tests/infrastructure/golden_images/test_common_templates_data_volumes.py @@ -16,9 +16,9 @@ @pytest.fixture() def vm_from_golden_image_multi_storage( - request, unprivileged_client, namespace, + storage_class_name_scope_function, golden_image_data_source_multi_storage_scope_function, ): with VirtualMachineForTests( @@ -28,6 +28,7 @@ def vm_from_golden_image_multi_storage( vm_instance_type=VirtualMachineClusterInstancetype(name=U1_SMALL), data_volume_template=data_volume_template_with_source_ref_dict( data_source=golden_image_data_source_multi_storage_scope_function, + storage_class=storage_class_name_scope_function, ), ) as vm: running_vm(vm=vm) diff --git a/tests/storage/conftest.py b/tests/storage/conftest.py index 0339c48b0d..1e8649ed23 100644 --- a/tests/storage/conftest.py +++ b/tests/storage/conftest.py @@ -475,11 +475,6 @@ def data_volume_template_metadata(multi_storage_cirros_vm): return multi_storage_cirros_vm.data_volume_template["metadata"] -@pytest.fixture() -def storage_class_name_scope_function(storage_class_matrix__function__): - return [*storage_class_matrix__function__][0] - - @pytest.fixture(scope="module") def storage_class_name_scope_module(storage_class_matrix__module__): return [*storage_class_matrix__module__][0] diff --git a/utilities/storage.py b/utilities/storage.py index 3bbeee0548..e46d8b4bc9 100644 --- a/utilities/storage.py +++ b/utilities/storage.py @@ -578,12 +578,11 @@ def data_volume_template_dict( def data_volume_template_with_source_ref_dict(data_source, storage_class=None): - source_dict = data_source.source.instance.to_dict() dv = DataVolume( name=utilities.infra.unique_name(name=data_source.name), namespace=data_source.namespace, size=get_dv_size_from_datasource(data_source=data_source), - storage_class=storage_class or source_dict["spec"].get("storageClassName"), + storage_class=storage_class, api_name="storage", source_ref={ "kind": data_source.kind,