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

fix(disk): implements retry mechanism for disk deletion #260

Merged
merged 1 commit into from
Jan 29, 2024
Merged
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
23 changes: 10 additions & 13 deletions riocli/disk/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,17 @@ def create_object(self, client: Client, **kwargs) -> typing.Any:
def update_object(self, client: Client, obj: typing.Any) -> typing.Any:
pass

def delete_object(self, client: Client, obj: typing.Any) -> typing.Any:
self._poll_till_available(client, obj)
def delete_object(self, client: Client, obj: typing.Any, sleep_interval=10, retries=12) -> typing.Any:
volume_instance = client.get_volume_instance(obj.internalDeploymentGUID)
volume_instance.destroy_volume_instance()

def _poll_till_available(self, client: Client, obj: typing.Any, sleep_interval=5, retries=20):
dep_guid = obj.internalDeploymentGUID
deployment = client.get_deployment(deployment_id=dep_guid)

for _ in range(retries):
status = deployment.get_status().status
if status != 'Available':
sleep(sleep_interval)
continue
for attempt in range(retries):
sleep(sleep_interval)
try:
volume_instance.destroy_volume_instance()
except Exception as e:
if attempt == retries - 1:
raise e
else:
return

@classmethod
def pre_process(cls, client: Client, d: typing.Dict) -> None:
Expand Down
Loading