Adding retry ability to cinderclient calls

All cinderclient calls wrapped in execute_with_retry
method to avoid occasional errors

partially implements bp clients-calls-retry

Change-Id: I02fbffe536630aa742d2a33aef78d48c22bf4124
This commit is contained in:
Andrey Pavlov 2015-04-24 12:48:29 +03:00
parent c6727664b6
commit 981745dae8
3 changed files with 5 additions and 4 deletions

View File

@ -193,7 +193,7 @@ def _get_cinder_limits():
avail_limits = {} avail_limits = {}
cinder = cinder_client.client() cinder = cinder_client.client()
lim = {} lim = {}
for l in cinder.limits.get().absolute: for l in b.execute_with_retries(cinder.limits.get).absolute:
lim[l.name] = l.value lim[l.name] = l.value
avail_limits['volumes'] = _sub_limit(lim['maxTotalVolumes'], avail_limits['volumes'] = _sub_limit(lim['maxTotalVolumes'],

View File

@ -22,6 +22,7 @@ from sahara import exceptions as ex
from sahara.i18n import _ from sahara.i18n import _
from sahara.i18n import _LE from sahara.i18n import _LE
from sahara.utils import cluster_progress_ops as cpo from sahara.utils import cluster_progress_ops as cpo
from sahara.utils.openstack import base as b
from sahara.utils.openstack import cinder from sahara.utils.openstack import cinder
from sahara.utils.openstack import nova from sahara.utils.openstack import nova
from sahara.utils import poll_utils from sahara.utils import poll_utils
@ -123,7 +124,7 @@ def _create_attach_volume(ctx, instance, size, volume_type,
if volume_local_to_instance: if volume_local_to_instance:
kwargs['scheduler_hints'] = {'local_to_instance': instance.instance_id} kwargs['scheduler_hints'] = {'local_to_instance': instance.instance_id}
volume = cinder.client().volumes.create(**kwargs) volume = b.execute_with_retries(cinder.client().volumes.create, **kwargs)
conductor.append_volume(ctx, instance, volume.id) conductor.append_volume(ctx, instance, volume.id)
_await_available(volume) _await_available(volume)
@ -237,7 +238,7 @@ def _delete_volume(volume_id):
LOG.debug("Deleting volume {volume}".format(volume=volume_id)) LOG.debug("Deleting volume {volume}".format(volume=volume_id))
volume = cinder.get_volume(volume_id) volume = cinder.get_volume(volume_id)
try: try:
volume.delete() b.execute_with_retries(volume.delete)
except Exception: except Exception:
LOG.error(_LE("Can't delete volume {volume}").format( LOG.error(_LE("Can't delete volume {volume}").format(
volume=volume.id)) volume=volume.id))

View File

@ -98,4 +98,4 @@ def check_cinder_exists():
def get_volume(volume_id): def get_volume(volume_id):
return client().volumes.get(volume_id) return base.execute_with_retries(client().volumes.get, volume_id)