Skip to content

Commit

Permalink
fix(disk): implements retrues 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 authored and pallabpain committed Jan 29, 2024
1 parent 7bf2c94 commit 625008f
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 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)
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
def delete_object(self, client: Client, obj: typing.Any, sleep_interval=10, retries=12) -> typing.Any:
for attempt in range(retries):
sleep(sleep_interval)
try:
volume_instance = client.get_volume_instance(obj.internalDeploymentGUID)
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 625008f

Please sign in to comment.