Merge "Fix list port failure due to dummy pod entry"

This commit is contained in:
Jenkins 2017-01-07 07:00:25 +00:00 committed by Gerrit Code Review
commit ce9ad625be
2 changed files with 25 additions and 9 deletions

View File

@ -96,13 +96,26 @@ def _safe_operation(operation_name):
if i == retries:
raise
if cfg.CONF.client.auto_refresh_endpoint:
msg = _LW("%(exception)s, "
"update endpoint and try again") % {
"exception": e.message}
LOG.warning(msg)
LOG.warning(_LW('%(exception)s, '
'update endpoint and try again'),
{'exception': e.message})
instance._update_endpoint_from_keystone(context, True)
else:
raise
except exceptions.EndpointNotFound as e:
# NOTE(zhiyuan) endpoints are not registered in Keystone
# for the given pod and service, we add default behaviours
# for the handle functions
if i < retries and cfg.CONF.client.auto_refresh_endpoint:
LOG.warning(_LW('%(exception)s, '
'update endpoint and try again'),
{'exception': e.message})
instance._update_endpoint_from_keystone(context, True)
continue
if operation_name == 'list':
return []
else:
return None
return handle_args
return handle_func

View File

@ -185,15 +185,18 @@ class ClientTest(unittest.TestCase):
resources = self.client.list_resources(FAKE_RESOURCE, self.context)
self.assertEqual(resources, [{'name': 'res3'}, {'name': 'res2'}])
def test_list_endpoint_not_found(self):
def test_list_create_endpoint_not_found(self):
cfg.CONF.set_override(name='auto_refresh_endpoint', override=False,
group='client')
# delete the configuration so endpoint cannot be found
api.delete_cached_endpoints(self.context, FAKE_SERVICE_ID)
# auto refresh set to False, directly raise exception
self.assertRaises(exceptions.EndpointNotFound,
self.client.list_resources,
FAKE_RESOURCE, self.context, [])
resources = self.client.list_resources(FAKE_RESOURCE, self.context)
# list_resources returns [] by default
self.assertEqual(resources, [])
resource = self.client.create_resources(FAKE_RESOURCE, self.context,
'res3')
# create_resources returns None by default
self.assertEqual(resource, None)
def test_resource_not_supported(self):
# no such resource