libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From quent...@apache.org
Subject [1/5] libcloud git commit: Retry _ex_delete_old_vhd when it returns False.
Date Mon, 06 Nov 2017 15:09:08 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 5aa717271 -> 42709622c


Retry _ex_delete_old_vhd when it returns False.

Signed-off-by: Quentin Pradet <quentinp@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/a0e34e31
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/a0e34e31
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/a0e34e31

Branch: refs/heads/trunk
Commit: a0e34e3120eb25fbb7011a8d667427b51d047208
Parents: 5aa7172
Author: Peter Amstutz <pamstutz@veritasgenetics.com>
Authored: Wed Oct 18 11:31:26 2017 -0400
Committer: Quentin Pradet <quentinp@apache.org>
Committed: Mon Nov 6 19:00:41 2017 +0400

----------------------------------------------------------------------
 libcloud/compute/drivers/azure_arm.py | 35 +++++++++++++++---------------
 1 file changed, 18 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/a0e34e31/libcloud/compute/drivers/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/azure_arm.py b/libcloud/compute/drivers/azure_arm.py
index b4a31c5..c59d9d7 100644
--- a/libcloud/compute/drivers/azure_arm.py
+++ b/libcloud/compute/drivers/azure_arm.py
@@ -766,23 +766,23 @@ class AzureNodeDriver(NodeDriver):
         # Optionally clean up OS disk VHD.
         vhd = node.extra["properties"]["storageProfile"]["osDisk"].get("vhd")
         if ex_destroy_vhd and vhd is not None:
+            resourceGroup = node.id.split("/")[4]
             while True:
                 try:
-                    resourceGroup = node.id.split("/")[4]
-                    self._ex_delete_old_vhd(
-                        resourceGroup,
-                        vhd["uri"])
-                    break
+                    if self._ex_delete_old_vhd(
+                            resourceGroup,
+                            vhd["uri"]):
+                        break
+                    # Unfortunately lease errors usually result in it returning
+                    # "False" with no more information.  Need to wait and try
+                    # again.
                 except LibcloudError as e:
                     if "LeaseIdMissing" in str(e):
-                        # Unfortunately lease errors
-                        # (which occur if the vhd blob
-                        # hasn't yet been released by the VM being destroyed)
-                        # get raised as plain
-                        # LibcloudError.  Wait a bit and try again.
-                        time.sleep(10)
+                        # If we get an lease error, need to wait and try again.
+                        pass
                     else:
                         raise
+                time.sleep(10)
 
         return True
 
@@ -1948,9 +1948,8 @@ class AzureNodeDriver(NodeDriver):
                 keys["key1"],
                 host="%s.blob%s" % (storageAccount,
                                     self.connection.storage_suffix))
-            blobdriver.delete_object(blobdriver.get_object(blobContainer,
-                                                           blob))
-            return True
+            return blobdriver.delete_object(
+                blobdriver.get_object(blobContainer, blob))
         except ObjectDoesNotExistError:
             return True
 
@@ -2086,10 +2085,12 @@ class AzureNodeDriver(NodeDriver):
                                   ex_blob_container,
                                   name,
                                   n)
-                self._ex_delete_old_vhd(ex_resource_group, instance_vhd)
-                return instance_vhd
+                if self._ex_delete_old_vhd(ex_resource_group, instance_vhd):
+                    # We were able to remove it or it doesn't exist.
+                    return instance_vhd
             except LibcloudError:
-                n += 1
+                pass
+            n += 1
 
 
 def _split_blob_uri(uri):


Mime
View raw message