From 98ca117fd2d92d8638fa12a5ecdaa7a6cc4a9cc4 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 aa5582cea7..ca8faf2133 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2742,6 +2742,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 035356a8cf..e61337da42 100644 --- a/tests/infrastructure/golden_images/test_common_templates_data_volumes.py +++ b/tests/infrastructure/golden_images/test_common_templates_data_volumes.py @@ -17,9 +17,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( @@ -29,6 +29,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 569f0666db..136478d087 100644 --- a/tests/storage/conftest.py +++ b/tests/storage/conftest.py @@ -492,11 +492,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 242551b759..fa4f7876dd 100644 --- a/utilities/storage.py +++ b/utilities/storage.py @@ -583,12 +583,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,