From 616060db65ac3f12c0a71fd21f8156c6e993d7ab Mon Sep 17 00:00:00 2001 From: kairat_kushaev Date: Thu, 3 Nov 2016 13:21:05 +0300 Subject: [PATCH] Do not use service catalog for cache client Previously cache client used endpoints from service catalog to request cache items from node. It works perfectly on devstack but it doesn't work when an OpenStack cloud is deployed with HA (3/5/7 controllers). We need to use -H option instead. This option makes cache management client interact with the local endpoint which is more appropriate as image cache is local to each node/controller. Change-Id: I355fb36d9af7e06dcac70b8263dc1a2b915ffc8f Closes-Bug: #1634486 --- glance/image_cache/client.py | 3 ++- glance/tests/unit/test_image_cache_client.py | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/glance/image_cache/client.py b/glance/image_cache/client.py index 3cf7bfaf6f..22160152db 100644 --- a/glance/image_cache/client.py +++ b/glance/image_cache/client.py @@ -128,4 +128,5 @@ def get_client(host, port=None, timeout=None, use_ssl=False, username=None, auth_token=auth_token or os.getenv('OS_TOKEN'), creds=creds, - insecure=insecure) + insecure=insecure, + configure_via_auth=False) diff --git a/glance/tests/unit/test_image_cache_client.py b/glance/tests/unit/test_image_cache_client.py index 883200c8d9..c3ea9db337 100644 --- a/glance/tests/unit/test_image_cache_client.py +++ b/glance/tests/unit/test_image_cache_client.py @@ -116,6 +116,15 @@ class GetClientTestCase(utils.BaseTestCase): ).creds self.assertEqual(expected_creds, creds) + def test_get_client_using_provided_host(self): + cli = client.get_client(self.host) + cli._do_request = mock.MagicMock() + cli.configure_from_url = mock.MagicMock() + cli.auth_plugin.management_url = mock.MagicMock() + cli.do_request("GET", "/queued_images") + self.assertFalse(cli.configure_from_url.called) + self.assertFalse(client.get_client(self.host).configure_via_auth) + def test_get_client_client_configuration_error(self): self.assertRaises(exception.ClientConfigurationError, client.get_client, self.host, username='name',