Limit number of tries to create alternate VHD blob names.
@@ -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):
