Fix issues with missing service

When Adjutant has sizes defined for a service
that isn't in all regions, we need to skip that
service when doing size comparisons if the current
usage doesn't contain that service.

Change-Id: Iea6a03d97e03501fff6e0635d079759faafbd18b
This commit is contained in:
Adrian Turjak 2018-05-02 13:07:33 +12:00
parent dab3938ab2
commit fbe6067bdc
1 changed files with 6 additions and 5 deletions

View File

@ -220,13 +220,14 @@ class QuotaManager(object):
for size, setting in settings.PROJECT_QUOTA_SIZES.items():
match_percentages = []
for service_name, values in setting.items():
if service_name not in current_quota:
continue
for name, value in values.items():
if name not in current_quota[service_name]:
continue
if value > 0:
try:
current = current_quota[service_name][name]
match_percentages.append(float(current) / value)
except KeyError:
pass
current = current_quota[service_name][name]
match_percentages.append(float(current) / value)
elif value < 0:
# NOTE(amelia): Sub-zero quota means unlimited
if current_quota[service_name][name] < 0: