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
This commit is contained in:
Chris Behrens
2012-07-26 08:59:24 +00:00
parent 16d948d8c8
commit 6a982343ab
2 changed files with 2 additions and 7 deletions

View File

@@ -200,7 +200,8 @@ class VirtualInterfaceMacAddressException(NovaException):
class GlanceConnectionFailed(NovaException):
message = _("Connection to glance failed") + ": %(reason)s"
message = _("Connection to glance host %(host)s:%(port)s failed: "
"%(reason)s")
class MelangeConnectionFailed(NovaException):

View File

@@ -20,7 +20,6 @@ import ast
import contextlib
import cPickle as pickle
import functools
import mox
import os
import re
@@ -31,7 +30,6 @@ from nova import context
from nova import db
from nova import exception
from nova import flags
from nova.image import glance
from nova.openstack.common import importutils
from nova.openstack.common import jsonutils
from nova.openstack.common import log as logging
@@ -2053,8 +2051,6 @@ class VmUtilsTestCase(test.TestCase):
def test_upload_image(self):
"""Ensure image properties include instance system metadata
as well as few local settings."""
def fake_pick_glance_api_server():
return ("host", 80)
def fake_instance_system_metadata_get(context, uuid):
return dict(image_a=1, image_b=2, image_c='c', d='d')
@@ -2076,8 +2072,6 @@ class VmUtilsTestCase(test.TestCase):
def fake_dumps(thing):
return thing
self.stubs.Set(glance, "pick_glance_api_server",
fake_pick_glance_api_server)
self.stubs.Set(db, "instance_system_metadata_get",
fake_instance_system_metadata_get)
self.stubs.Set(vm_utils, "get_sr_path", fake_get_sr_path)