Skip to content

Commit 3cd9caf

Browse files
authored
[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: #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: rkishner <rkishner@redhat.com>
1 parent a363799 commit 3cd9caf

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
@@ -2507,6 +2507,11 @@ def rwx_fs_available_storage_classes_names(cluster_storage_classes_names):
25072507
]
25082508

25092509

2510+
@pytest.fixture()
2511+
def storage_class_name_scope_function(storage_class_matrix__function__):
2512+
return [*storage_class_matrix__function__][0]
2513+
2514+
25102515
@pytest.fixture(scope="session")
25112516
def rhsm_credentials_from_bitwarden():
25122517
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
@@ -16,9 +16,9 @@
1616

1717
@pytest.fixture()
1818
def vm_from_golden_image_multi_storage(
19-
request,
2019
unprivileged_client,
2120
namespace,
21+
storage_class_name_scope_function,
2222
golden_image_data_source_multi_storage_scope_function,
2323
):
2424
with VirtualMachineForTests(
@@ -28,6 +28,7 @@ def vm_from_golden_image_multi_storage(
2828
vm_instance_type=VirtualMachineClusterInstancetype(name=U1_SMALL),
2929
data_volume_template=data_volume_template_with_source_ref_dict(
3030
data_source=golden_image_data_source_multi_storage_scope_function,
31+
storage_class=storage_class_name_scope_function,
3132
),
3233
) as vm:
3334
running_vm(vm=vm)

tests/storage/conftest.py

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

498498

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

utilities/storage.py

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

562562

563563
def data_volume_template_with_source_ref_dict(data_source, storage_class=None):
564-
source_dict = data_source.source.instance.to_dict()
565564
dv = DataVolume(
566565
name=utilities.infra.unique_name(name=data_source.name),
567566
namespace=data_source.namespace,
568567
size=get_dv_size_from_datasource(data_source=data_source),
569-
storage_class=storage_class or source_dict["spec"].get("storageClassName"),
568+
storage_class=storage_class,
570569
api_name="storage",
571570
source_ref={
572571
"kind": data_source.kind,

0 commit comments

Comments
 (0)