Skip to content

Commit 4358d01

Browse files
authored
[4.22] Remove DataSource storage class fallback from DV template helper (#4985) (#5156)
##### 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: #4985 ##### jira-ticket: <!-- 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". --> https://redhat.atlassian.net/browse/CNV-88988 Signed-off-by: Roni Kishner <rkishner@redhat.com>
1 parent d7b823d commit 4358d01

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

tests/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2629,6 +2629,11 @@ def rwx_fs_available_storage_classes_names(cluster_storage_classes_names):
26292629
]
26302630

26312631

2632+
@pytest.fixture()
2633+
def storage_class_name_scope_function(storage_class_matrix__function__):
2634+
return [*storage_class_matrix__function__][0]
2635+
2636+
26322637
@pytest.fixture(scope="session")
26332638
def rhsm_credentials_from_bitwarden():
26342639
return get_cnv_tests_secret_by_name(secret_name="RHSM_CREDENTIALS")

tests/infrastructure/golden_images/test_common_templates_data_volumes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
@pytest.fixture()
1717
def vm_from_golden_image_multi_storage(
18-
request,
1918
unprivileged_client,
2019
namespace,
20+
storage_class_name_scope_function,
2121
golden_image_data_source_multi_storage_scope_function,
2222
):
2323
with VirtualMachineForTests(
@@ -27,6 +27,7 @@ def vm_from_golden_image_multi_storage(
2727
vm_instance_type=VirtualMachineClusterInstancetype(name=U1_SMALL),
2828
data_volume_template=data_volume_template_with_source_ref_dict(
2929
data_source=golden_image_data_source_multi_storage_scope_function,
30+
storage_class=storage_class_name_scope_function,
3031
),
3132
) as vm:
3233
running_vm(vm=vm)

tests/storage/conftest.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -497,11 +497,6 @@ def data_volume_template_metadata(multi_storage_cirros_vm):
497497
return multi_storage_cirros_vm.data_volume_template["metadata"]
498498

499499

500-
@pytest.fixture()
501-
def storage_class_name_scope_function(storage_class_matrix__function__):
502-
return [*storage_class_matrix__function__][0]
503-
504-
505500
@pytest.fixture(scope="module")
506501
def storage_class_name_scope_module(storage_class_matrix__module__):
507502
return [*storage_class_matrix__module__][0]

utilities/storage.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,12 +564,11 @@ def data_volume_template_dict(
564564

565565

566566
def data_volume_template_with_source_ref_dict(data_source, storage_class=None):
567-
source_dict = data_source.source.instance.to_dict()
568567
dv = DataVolume(
569568
name=utilities.infra.unique_name(name=data_source.name),
570569
namespace=data_source.namespace,
571570
size=get_dv_size_from_datasource(data_source=data_source),
572-
storage_class=storage_class or source_dict["spec"].get("storageClassName"),
571+
storage_class=storage_class,
573572
api_name="storage",
574573
source_ref={
575574
"kind": data_source.kind,

0 commit comments

Comments
 (0)