Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add deprecation warning for remove garbage collector dead code #2253

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ocp_resources/datavolume.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from ocp_resources.persistent_volume_claim import PersistentVolumeClaim
from ocp_resources.resource import NamespacedResource, Resource
from timeout_sampler import TimeoutExpiredError, TimeoutSampler
from warnings import warn

gc_deprecatio_warning = ("garbage collector is removed in version v1.62 and going to be deprecated", DeprecationWarning)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo deprecation



class DataVolume(NamespacedResource):
Expand Down Expand Up @@ -281,7 +284,7 @@ def wait_for_dv_success(
Args:
timeout (int): Time to wait for the DataVolume to succeed.
failure_timeout (int): Time to wait for the DataVolume to have not Pending/None status
dv_garbage_collection_enabled (bool, default: False): if True, expect that DV will disappear after success
dv_garbage_collection_enabled (bool, default: False): garbage collector is removed in version v1.62 and going to be deprecated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v1.62 refers to what version? CDI/Kubevirt etc? Is it going to be removed or already removed?

stop_status_func (function): function that is called inside the TimeoutSampler
if it returns True - stop the Sampler and raise TimeoutExpiredError
Example:
Expand All @@ -307,6 +310,8 @@ def test_dv():
wait_timeout=timeout,
func=lambda: self.exists,
):
if dv_garbage_collection_enabled is not None:
warn(gc_deprecatio_warning)
# DV reach success if the status is Succeeded, or if DV garbage collection enabled and the DV does not exist
if sample and sample.get("status", {}).get("phase") == self.Status.SUCCEEDED:
break
Expand Down Expand Up @@ -341,6 +346,7 @@ def delete(self, wait=False, timeout=TIMEOUT_4MINUTES, body=None):
"""
# if garbage collector is enabled, DV will be deleted after success
if self.exists:
warn(gc_deprecatio_warning)
return super().delete(wait=wait, timeout=timeout, body=body)
rnetser marked this conversation as resolved.
Show resolved Hide resolved
else:
return self.pvc.delete(wait=wait, timeout=timeout, body=body)