From fbe6067bdcae78085388ab4f42d2a809a4af909e Mon Sep 17 00:00:00 2001 From: Adrian Turjak Date: Wed, 2 May 2018 13:07:33 +1200 Subject: [PATCH] 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 --- adjutant/common/quota.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/adjutant/common/quota.py b/adjutant/common/quota.py index 67032af..149a72a 100644 --- a/adjutant/common/quota.py +++ b/adjutant/common/quota.py @@ -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: