You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by qu...@apache.org on 2017/11/08 03:36:43 UTC

[2/4] libcloud git commit: Renamed ex_retries param on destroy_node() to ex_poll_qty. Also added ex_poll_wait.

Renamed ex_retries param on destroy_node() to ex_poll_qty. Also
added ex_poll_wait.

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


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

Branch: refs/heads/trunk
Commit: aaaa10158ff91039546446309b80bf45042acf79
Parents: a71e955
Author: Lucas Di Pentima <ld...@veritasgenetics.com>
Authored: Tue Oct 31 16:49:56 2017 -0300
Committer: Quentin Pradet <qu...@apache.org>
Committed: Wed Nov 8 07:32:06 2017 +0400

----------------------------------------------------------------------
 libcloud/compute/drivers/azure_arm.py | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/aaaa1015/libcloud/compute/drivers/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/azure_arm.py b/libcloud/compute/drivers/azure_arm.py
index db7ef65..1d9da01 100644
--- a/libcloud/compute/drivers/azure_arm.py
+++ b/libcloud/compute/drivers/azure_arm.py
@@ -694,7 +694,8 @@ class AzureNodeDriver(NodeDriver):
     def destroy_node(self, node,
                      ex_destroy_nic=True,
                      ex_destroy_vhd=True,
-                     ex_retries=10):
+                     ex_poll_qty=10,
+                     ex_poll_wait=10):
         """
         Destroy a node.
 
@@ -709,8 +710,11 @@ class AzureNodeDriver(NodeDriver):
         this node (default True).
         :type node: ``bool``
 
-        :param ex_retries: Number of times to retry checking if the node is gone,
-        destroying the NIC or destroying the VHD.
+        :param ex_poll_qty: Number of retries checking if the node
+        is gone, destroying the NIC or destroying the VHD (default 10).
+        :type node: ``int``
+
+        :param ex_poll_wait: Delay in seconds between retries (default 10).
         :type node: ``int``
 
         :return: True if the destroy was successful, raises exception
@@ -740,10 +744,10 @@ class AzureNodeDriver(NodeDriver):
 
         # Poll until the node actually goes away (otherwise attempt to delete
         # NIC and VHD will fail with "resource in use" errors).
-        retries = ex_retries
+        retries = ex_poll_qty
         while do_node_polling and retries > 0:
             try:
-                time.sleep(10)
+                time.sleep(ex_poll_wait)
                 self.connection.request(
                     node.id,
                     params={"api-version": RESOURCE_API_VERSION})
@@ -761,7 +765,7 @@ class AzureNodeDriver(NodeDriver):
             node.extra["properties"]["networkProfile"]["networkInterfaces"]
         if ex_destroy_nic:
             for nic in interfaces:
-                retries = ex_retries
+                retries = ex_poll_qty
                 while retries > 0:
                     try:
                         self.ex_destroy_nic(self._to_nic(nic))
@@ -771,15 +775,15 @@ class AzureNodeDriver(NodeDriver):
                         if (h.code == 400 and
                                 h.message.startswith("[NicInUse]") and
                                 retries > 0):
-                            time.sleep(10)
+                            time.sleep(ex_poll_wait)
                         else:
                             raise
 
         # Optionally clean up OS disk VHD.
         vhd = node.extra["properties"]["storageProfile"]["osDisk"].get("vhd")
         if ex_destroy_vhd and vhd is not None:
+            retries = ex_poll_qty
             resourceGroup = node.id.split("/")[4]
-            retries = ex_retries
             while retries > 0:
                 try:
                     if self._ex_delete_old_vhd(resourceGroup, vhd["uri"]):
@@ -795,7 +799,7 @@ class AzureNodeDriver(NodeDriver):
                         # hasn't yet been released by the VM being destroyed)
                         # get raised as plain
                         # LibcloudError.  Wait a bit and try again.
-                        time.sleep(10)
+                        time.sleep(ex_poll_wait)
                     else:
                         raise
                 time.sleep(10)