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/06 15:09:08 UTC

[1/5] libcloud git commit: Retry _ex_delete_old_vhd when it returns False.

Repository: libcloud
Updated Branches:
  refs/heads/trunk 5aa717271 -> 42709622c


Retry _ex_delete_old_vhd when it returns False.

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/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 <pa...@veritasgenetics.com>
Authored: Wed Oct 18 11:31:26 2017 -0400
Committer: Quentin Pradet <qu...@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):


[2/5] libcloud git commit: Fix bug in Azure blob store request signing preventing delete_object() from working.

Posted by qu...@apache.org.
Fix bug in Azure blob store request signing preventing delete_object() from working.

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/152a5e0b
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/152a5e0b
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/152a5e0b

Branch: refs/heads/trunk
Commit: 152a5e0ba2175f702f44d5b63569cfc28df650a4
Parents: a0e34e3
Author: Peter Amstutz <pa...@veritasgenetics.com>
Authored: Wed Oct 18 20:15:16 2017 +0000
Committer: Quentin Pradet <qu...@apache.org>
Committed: Mon Nov 6 19:01:11 2017 +0400

----------------------------------------------------------------------
 libcloud/common/azure.py | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/152a5e0b/libcloud/common/azure.py
----------------------------------------------------------------------
diff --git a/libcloud/common/azure.py b/libcloud/common/azure.py
index 4884f32..6dc44f0 100644
--- a/libcloud/common/azure.py
+++ b/libcloud/common/azure.py
@@ -193,6 +193,10 @@ class AzureConnection(ConnectionUserAndKey):
             header = header.lower()  # Just for safety
             if header in headers_copy:
                 special_header_values.append(headers_copy[header])
+            elif header == "content-length" and method not in ("GET", "HEAD"):
+                # Must be '0' unless method is GET or HEAD
+                # https://docs.microsoft.com/en-us/rest/api/storageservices/authentication-for-the-azure-storage-services
+                special_header_values.append('0')
             else:
                 special_header_values.append('')
 


[4/5] libcloud git commit: Added test for _get_instance_vhd() retries.

Posted by qu...@apache.org.
Added test for _get_instance_vhd() retries.

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/b50f0b33
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/b50f0b33
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/b50f0b33

Branch: refs/heads/trunk
Commit: b50f0b33e1de12ccdb961d59ec82c7dbfcb4ea6a
Parents: ffce9f9
Author: Lucas Di Pentima <ld...@veritasgenetics.com>
Authored: Tue Oct 31 12:36:06 2017 -0300
Committer: Quentin Pradet <qu...@apache.org>
Committed: Mon Nov 6 19:01:13 2017 +0400

----------------------------------------------------------------------
 libcloud/test/compute/test_azure_arm.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/b50f0b33/libcloud/test/compute/test_azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_azure_arm.py b/libcloud/test/compute/test_azure_arm.py
index 3367125..a32917d 100644
--- a/libcloud/test/compute/test_azure_arm.py
+++ b/libcloud/test/compute/test_azure_arm.py
@@ -21,6 +21,7 @@ from datetime import datetime
 import mock
 
 from libcloud.common.exceptions import BaseHTTPError
+from libcloud.common.types import LibcloudError
 from libcloud.compute.base import (NodeLocation, NodeSize, VolumeSnapshot,
                                    StorageVolume)
 from libcloud.compute.drivers.azure_arm import AzureImage, NodeAuthPassword
@@ -491,6 +492,21 @@ class AzureNodeDriverTests(LibcloudTestCase):
                                                     ex_storage_account='sga1')
             self.assertEqual(vhd_url, 'https://sga1.blob.core.chinacloudapi.cn/vhds/test1-os_0.vhd')
 
+    def test_get_instance_vhd__retries_ten_times(self):
+        with mock.patch.object(self.driver, '_ex_delete_old_vhd') as m:
+            # 10 retries are OK
+            m.side_effect = [False] * 9 + [True]
+            vhd_url = self.driver._get_instance_vhd(name='test1',
+                                                    ex_resource_group='000000',
+                                                    ex_storage_account='sga1')
+            self.assertEqual(vhd_url, 'https://sga1.blob.core.windows.net/vhds/test1-os_9.vhd')
+            # Fail on the 11th
+            m.side_effect = [False] * 10 + [True]
+            with self.assertRaises(LibcloudError):
+                self.driver._get_instance_vhd(name='test1',
+                                              ex_resource_group='000000',
+                                              ex_storage_account='sga1')
+
 
 class AzureMockHttp(MockHttp):
     fixtures = ComputeFileFixtures('azure_arm')


[3/5] libcloud git commit: Limit number of tries to create alternate VHD blob names.

Posted by qu...@apache.org.
Limit number of tries to create alternate VHD blob names.

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/ffce9f97
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/ffce9f97
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/ffce9f97

Branch: refs/heads/trunk
Commit: ffce9f97946382c7eda10e5c3929f7cf01687c8e
Parents: 152a5e0
Author: Peter Amstutz <pa...@veritasgenetics.com>
Authored: Thu Oct 19 16:22:19 2017 -0400
Committer: Quentin Pradet <qu...@apache.org>
Committed: Mon Nov 6 19:01:13 2017 +0400

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


http://git-wip-us.apache.org/repos/asf/libcloud/blob/ffce9f97/libcloud/compute/drivers/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/azure_arm.py b/libcloud/compute/drivers/azure_arm.py
index c59d9d7..fcc9ef3 100644
--- a/libcloud/compute/drivers/azure_arm.py
+++ b/libcloud/compute/drivers/azure_arm.py
@@ -2076,7 +2076,8 @@ class AzureNodeDriver(NodeDriver):
     def _get_instance_vhd(self, name, ex_resource_group, ex_storage_account,
                           ex_blob_container="vhds"):
         n = 0
-        while True:
+        errors = []
+        while n < 10:
             try:
                 instance_vhd = "https://%s.blob%s" \
                                "/%s/%s-os_%i.vhd" \
@@ -2086,11 +2087,15 @@ class AzureNodeDriver(NodeDriver):
                                   name,
                                   n)
                 if self._ex_delete_old_vhd(ex_resource_group, instance_vhd):
-                    # We were able to remove it or it doesn't exist.
+                    # We were able to remove it or it doesn't exist,
+                    # so we can use it.
                     return instance_vhd
-            except LibcloudError:
-                pass
+            except LibcloudError as lce:
+                errors.append(str(lce))
             n += 1
+        raise LibcloudError("Unable to find a name for a VHD to use for "
+                            "instance in 10 tries, errors were:\n  - %s" %
+                            ("\n  - ".join(errors)))
 
 
 def _split_blob_uri(uri):


[5/5] libcloud git commit: Add changes for #1137

Posted by qu...@apache.org.
Add changes for #1137

Closes #1137


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

Branch: refs/heads/trunk
Commit: 42709622c906481a6e2b3932c3155ad4ba5e33e9
Parents: b50f0b3
Author: Quentin Pradet <qu...@apache.org>
Authored: Mon Nov 6 19:04:26 2017 +0400
Committer: Quentin Pradet <qu...@apache.org>
Committed: Mon Nov 6 19:04:26 2017 +0400

----------------------------------------------------------------------
 CHANGES.rst | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/42709622/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 529d595..add7274 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -83,6 +83,9 @@ Compute
   (LIBCLOUD-944, GITHUB-1107)
   [Gareth Mcfarlane]
 
+- [ARM] Fix delete_old_vhd (GITHUB-1137)
+  [Peter Amstutz, Lucas Di Pentima]
+
 Storage
 ~~~~~~~