Skip to content

Commit

Permalink
svc_monitor unable to handle empty az list from nova
Browse files Browse the repository at this point in the history
This fix adds error handling to svc_monitor code. If nova
returns empty az_list or if the call to nova fails for some
reason, svc_monitor will not crash after this fix.

Change-Id: Ib132401d931c763c36c9eca46bfd855663b070b9
Closes-Bug: #1593432
  • Loading branch information
Varun Lodaya committed Jun 16, 2016
1 parent 2ae3cd3 commit de36bfa
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/config/svc-monitor/svc_monitor/scheduler/vrouter_scheduler.py
Expand Up @@ -59,11 +59,30 @@ def _get_az_vrouter_list(self):
az_list = self._nc.oper('availability_zones', 'list',
self._args.admin_tenant_name,
detailed=True)
if not az_list:
self._logger.log_error("Failed fetching azs from nova")
return None

az_vr_list = []
for az in az_list:
if self._args.netns_availability_zone not in str(az):
try:
# check:
# 1. If az is mentioned in config
# 2. If the az is enabled & active
# 3. If it has any hosts
if az.zoneName not in self._args.netns_availability_zone or \
not az.zoneState['available'] or not az.hosts:
continue

# check if hosts are active & enabled
for host,host_status in az.hosts.iteritems():
if (('nova-compute' in host_status) and \
host_status['nova-compute']['available'] and \
host_status['nova-compute']['active']):
az_vr_list.append(host)
except Exception as e:
self._logger.log_error(str(e))
continue
az_vr_list.extend(az.hosts.keys())

return az_vr_list

Expand Down

0 comments on commit de36bfa

Please sign in to comment.