From 0c59003b1cc2ce17e3215e6c69b0dc2407f1b38b Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Thu, 26 Jul 2012 08:59:24 +0000 Subject: Refactor glance image service code Fixes bug 1029397 This adds better retry support, making sure that if we need to retry requests to glance, we cycle through all hosts before potentially attemping the hosts that failed. The old random selection could cause immediate retrying of the same host that failed. This also adds logging of the host:port that failed and fixes a bug in the retry test, which didn't actually successfully test retrying. Tests for new code added. Change-Id: I400616081e1e547b9ca2e0be622889d3a399a5bf --- nova/virt/xenapi/vm_utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 9d340861d..bfbffd8cd 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -560,7 +560,8 @@ def upload_image(context, session, instance, vdi_uuids, image_id): LOG.debug(_("Asking xapi to upload %(vdi_uuids)s as" " ID %(image_id)s"), locals(), instance=instance) - glance_host, glance_port = glance.pick_glance_api_server() + glance_api_servers = glance.get_api_servers() + glance_host, glance_port = glance_api_servers.next() # TODO(sirp): this inherit-image-property code should probably go in # nova/compute/manager so it can be shared across hypervisors @@ -916,8 +917,10 @@ def _fetch_vhd_image(context, session, instance, image_id): 'sr_path': get_sr_path(session), 'auth_token': getattr(context, 'auth_token', None)} + glance_api_servers = glance.get_api_servers() + def pick_glance(params): - glance_host, glance_port = glance.pick_glance_api_server() + glance_host, glance_port = glance_api_servers.next() params['glance_host'] = glance_host params['glance_port'] = glance_port -- cgit