Skip to content

Commit c3f814f

Browse files
authored
Remove DataSource storage class fallback from DV template helper (#4985)
##### 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: Since we could not decide the storage class according to the `VolumeSnapshot` that was used when creating the VM, this is the approach we decided to use. ##### 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 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Data volumes now use only an explicitly provided storage class and no longer inherit or default from referenced sources, preventing unexpected storage-class selection. * **Tests** * Test suite updated to validate scoped storage-class selection; test fixtures adjusted to consistently provide the chosen storage class across scopes. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: rkishner <rkishner@redhat.com>
1 parent c0e6a28 commit c3f814f

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
@@ -565,12 +565,11 @@ def data_volume_template_dict(
565565

566566

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

0 commit comments

Comments
 (0)