From 421638863f0d2b15126e56b55021e789ab4aeab8 Mon Sep 17 00:00:00 2001 From: Emanuele Prella Date: Fri, 27 Nov 2026 09:38:47 +0100 Subject: [PATCH] fix(datavolume): update default api_name to "storage" and clarify usage --- docs/common-patterns.md | 5 ++--- ocp_resources/datavolume.py | 18 ++++-------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/docs/common-patterns.md b/docs/common-patterns.md index 72fe0c5ee8..1ef0eddcda 100644 --- a/docs/common-patterns.md +++ b/docs/common-patterns.md @@ -363,15 +363,15 @@ dv = DataVolume( storage_class="ocs-storagecluster-ceph-rbd-virtualization", access_modes=DataVolume.AccessMode.RWX, volume_mode=DataVolume.VolumeMode.BLOCK, - api_name="storage", ) dv.deploy() dv.wait_for_dv_success(timeout=600) ``` -Always pass `api_name="storage"` explicitly — the default will change in a future release. Use `source_dict={"blank": {}}` for empty disks, or `source_dict={"pvc": {"name": "source-pvc", "namespace": "default"}}` for cloning. +DataVolumes use `spec.storage` by default. Pass `api_name="pvc"` to use `spec.pvc`. Use `source_dict={"blank": {}}` for empty disks, or `source_dict={"pvc": {"name": "source-pvc", "namespace": "default"}}` for cloning. - **Clone a DataVolume:** + ```python dv_clone = DataVolume( client=client, @@ -382,7 +382,6 @@ Always pass `api_name="storage"` explicitly — the default will change in a fut storage_class="ocs-storagecluster-ceph-rbd-virtualization", access_modes=DataVolume.AccessMode.RWX, volume_mode=DataVolume.VolumeMode.BLOCK, - api_name="storage", ) ``` diff --git a/ocp_resources/datavolume.py b/ocp_resources/datavolume.py index d451084dc0..4de5299ba5 100644 --- a/ocp_resources/datavolume.py +++ b/ocp_resources/datavolume.py @@ -95,7 +95,7 @@ def __init__( multus_annotation: str | None = None, bind_immediate_annotation: bool | None = None, preallocation: bool | None = None, - api_name: str | None = None, + api_name: str | None = "storage", checkpoints: list[Any] | None = None, final_checkpoint: bool | None = None, priority_class_name: str | None = None, @@ -124,8 +124,8 @@ def __init__( bind_immediate_annotation (bool, default: None): when WaitForFirstConsumer is set in StorageClass and DV should be bound immediately. preallocation (bool, default: None): preallocate disk space. - api_name (str | None, default: None): api used for DV (e.g., "storage", "pvc"). - NOTE: Currently defaults to "pvc" if not specified. Default will change to "storage" in a future release. + api_name (str | None, default: "storage"): Target section of the DataVolume spec ("storage" or "pvc"). + Pass None to omit the target section. checkpoints (list[Any], default: None): list of DataVolumeCheckpoints for snapshot operations. final_checkpoint (bool, default: None): indicates whether the current DataVolumeCheckpoint is the final one. priority_class_name (str, default: None): priority class name for the DataVolume pod. @@ -148,17 +148,7 @@ def __init__( self.multus_annotation = multus_annotation self.bind_immediate_annotation = bind_immediate_annotation self.preallocation = preallocation - if api_name is None: - warn( - "The default 'api_name' will change from 'pvc' to 'storage' in a future release. " - "To maintain existing behavior and suppress this warning, " - "explicitly set api_name='pvc' in your constructor call.", - FutureWarning, - stacklevel=2, - ) - self.api_name = "pvc" - else: - self.api_name = api_name + self.api_name = api_name self.checkpoints = checkpoints self.final_checkpoint = final_checkpoint self.priority_class_name = priority_class_name