Add a try except block while calling Nova API
During the tempest test, sometimes Nova API would just return HTTP 503 error which means service is temporarily unavailable. Adding this try except block to prevent it from killing the update thread. Actually get_server() API already has the try block in place so I should have followed suit when I implemented this get_servers() API. Also adjusted the code on the MD side to deal with this case. Change-Id: Ie4c6a66d6a705c39ca58827ebbcfa1900f034da6
This commit is contained in:
parent
66bfc117ae
commit
fcda43c1b9
|
@ -301,12 +301,16 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
|
|||
if (delta_time.total_seconds() <
|
||||
self.apic_nova_vm_name_cache_update_interval * 10):
|
||||
is_full_update = False
|
||||
self._set_vm_name_update(session, vm_name_update, self.host_id,
|
||||
current_time,
|
||||
current_time if is_full_update else None)
|
||||
|
||||
nova_vms = nclient.NovaClient().get_servers(
|
||||
is_full_update, self.apic_nova_vm_name_cache_update_interval * 10)
|
||||
# This means Nova API has thrown an exception
|
||||
if nova_vms is None:
|
||||
return
|
||||
|
||||
self._set_vm_name_update(session, vm_name_update, self.host_id,
|
||||
current_time,
|
||||
current_time if is_full_update else None)
|
||||
vm_list = []
|
||||
for vm in nova_vms:
|
||||
vm_list.append((vm.id, vm.name))
|
||||
|
|
|
@ -52,5 +52,8 @@ class NovaClient(object):
|
|||
search_opts = {'all_tenants': 1,
|
||||
'changes-since': str(seconds_ago),
|
||||
'deleted': 'false'}
|
||||
return self.client.servers.list(detailed=False,
|
||||
search_opts=search_opts)
|
||||
try:
|
||||
return self.client.servers.list(detailed=False,
|
||||
search_opts=search_opts)
|
||||
except Exception as e:
|
||||
LOG.exception(e)
|
||||
|
|
Loading…
Reference in New Issue