Cap vm extension install to 1 attempt

- Fail async op at first chance to preserve traceback
This commit is contained in:
Fred Park 2017-03-15 13:22:26 -07:00
Родитель a06377a93e
Коммит 9dfccad392
2 изменённых файлов: 23 добавлений и 15 удалений

Просмотреть файл

@ -799,9 +799,13 @@ def create_storage_cluster(
async_ops['vmext'] = {}
for i in range(rfs.storage_cluster.vm_count):
# install vm extension
async_ops['vmext'][i] = resource.AsyncOperation(functools.partial(
async_ops['vmext'][i] = resource.AsyncOperation(
functools.partial(
_create_virtual_machine_extension, compute_client, rfs,
bootstrap_file, blob_urls, vms[i].name, disk_map, private_ips, i))
bootstrap_file, blob_urls, vms[i].name, disk_map,
private_ips, i),
max_retries=0,
)
logger.debug('waiting for virtual machine extensions to be created')
for offset in async_ops['vmext']:
# refresh public ip for vm
@ -1042,9 +1046,13 @@ def resize_storage_cluster(
async_ops['vmext'] = {}
for i in new_vms:
# install vm extension
async_ops['vmext'][i] = resource.AsyncOperation(functools.partial(
async_ops['vmext'][i] = resource.AsyncOperation(
functools.partial(
_create_virtual_machine_extension, compute_client, rfs,
bootstrap_file, blob_urls, vms[i].name, disk_map, private_ips, i))
bootstrap_file, blob_urls, vms[i].name, disk_map, private_ips,
i),
max_retries=0,
)
logger.debug('adding {} bricks to gluster volume'.format(
len(async_ops['vmext'])))
# execute special add brick script

Просмотреть файл

@ -84,13 +84,6 @@ class AsyncOperation(object):
while True:
if self._noop:
return self._op # will return None
if (self._max_retries >= 0 and
self._retry_count > self._max_retries):
raise RuntimeError(
('Ran out of retry attempts invoking {}(args={} '
'kwargs={})').format(
self._partial.func.__name__, self._partial.args,
self._partial.keywords))
self._invoke()
try:
return self._op.result()
@ -98,9 +91,16 @@ class AsyncOperation(object):
msrestazure.azure_exceptions.CloudError) as e:
if e.status_code == 404 and not self._retry_notfound:
raise
logger.error('Async operation failed: {}'.format(e))
self._op = None
self._retry_count += 1
if (self._max_retries >= 0 and
self._retry_count > self._max_retries):
logger.error(
('Ran out of retry attempts invoking {}(args={} '
'kwargs={})').format(
self._partial.func.__name__, self._partial.args,
self._partial.keywords))
raise
self._op = None
logger.debug(
('Attempting retry of operation: {}, retry_count={} '
'max_retries={}').format(