Skip to content

Commit

Permalink
fix(disk): implements retries for deleting disk
Browse files Browse the repository at this point in the history
This update implements a retry mechanism for the disk deletion operation
through the "rio apply" command. This enhancement ensures that deletion
attempts are systematically retried in the occurrence of errors,
irrespective of the existing disk status.

Wrike Ticket: https://www.wrike.com/open.htm?id=1160572877
  • Loading branch information
RomilShah committed Jan 29, 2024
1 parent 7bf2c94 commit 37de60a
Showing 1 changed file with 10 additions and 13 deletions.
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

0 comments on commit 37de60a

Please sign in to comment.