Fix readiness quota check

Due to coding error I not only switched "used" with "limit" in our
quota check messages but also made it impossible for the check to fail.
This commit fixes it.

Closes-Bug: 1927241
Change-Id: I6e6a396d0e0467ec424bb403064a19cb4f1a586e
This commit is contained in:
Michał Dulko 2021-05-05 17:16:11 +02:00
parent da0ab7211a
commit 673fb5d9b2
1 changed files with 5 additions and 5 deletions

View File

@ -370,13 +370,13 @@ def has_limit(quota):
def is_available(resource, resource_quota):
availability = resource_quota['limit'] - resource_quota['used']
if availability <= 3:
LOG.warning("Neutron quota low for %s. Used %d out of %d limit.",
resource, resource_quota['limit'], resource_quota['used'])
elif availability <= 0:
if availability <= 0:
LOG.error("Neutron quota exceeded for %s. Used %d out of %d limit.",
resource, resource_quota['limit'], resource_quota['used'])
resource, resource_quota['used'], resource_quota['limit'])
return False
elif availability <= 3:
LOG.warning("Neutron quota low for %s. Used %d out of %d limit.",
resource, resource_quota['used'], resource_quota['limit'])
return True