From 61f9c85456a8780ee1e800ea6652cfb3a33567ba Mon Sep 17 00:00:00 2001 From: Roman Dobosz Date: Thu, 30 Apr 2020 09:04:53 +0200 Subject: [PATCH] Throw an exception in case of exceeding quota. Sometimes we create a lot of security group rules, which might exceed the quotas. In this patch we propose to distinguish conflict exceptions for quota exceeding from rule already exists. Change-Id: Icea686ec9d1fcb701f1853c40d6cfd4ca20fd0ac --- kuryr_kubernetes/controller/drivers/utils.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/kuryr_kubernetes/controller/drivers/utils.py b/kuryr_kubernetes/controller/drivers/utils.py index 88f5fd7fe..eaec333cf 100644 --- a/kuryr_kubernetes/controller/drivers/utils.py +++ b/kuryr_kubernetes/controller/drivers/utils.py @@ -186,10 +186,15 @@ def create_security_group_rule(body): sgr = os_net.create_security_group_rule(**params) return sgr.id except os_exc.ConflictException as ex: - LOG.debug("Failed to create already existing security group " - "rule %s", body) - # Get existent sg rule id from exception message - return str(ex).split()[-1][:-1] + if 'quota' in ex.details.lower(): + LOG.error("Failed to create security group rule %s: %s", body, + ex.details) + raise + else: + LOG.debug("Failed to create already existing security group " + "rule %s", body) + # Get existent sg rule id from exception message + return str(ex).split()[-1][:-1] except os_exc.SDKException: LOG.debug("Error creating security group rule") raise