From 11f9694453eea6f79f541c4d26e159de1fdc7279 Mon Sep 17 00:00:00 2001 From: Carlos Goncalves Date: Mon, 12 Oct 2020 15:24:14 +0000 Subject: [PATCH] Fix pool delete race on load balancer cascade delete In what appears to be a race condition, load balancer cascade delete can fail while deleting numerous pools. The load balancer can still be deleted with one or more follow-up cascade delete API calls but this is suboptimal. Per local testing, the ValueError exception is harmless so we can just ignore it and continue the pool delete flow, with no orphan resources left behind resulting from the exception skip. Task: 41096 Story: 2008249 Change-Id: I9283d9804feb83a1d5a160da48da6146b19da88c (cherry picked from commit 332791ee2b3cf29d01d94a9bb53fda4043303fd8) --- octavia/common/data_models.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/octavia/common/data_models.py b/octavia/common/data_models.py index 1c6424b2f9..7075f56227 100644 --- a/octavia/common/data_models.py +++ b/octavia/common/data_models.py @@ -16,11 +16,14 @@ import re +from oslo_log import log as logging import six from sqlalchemy.orm import collections from octavia.common import constants +LOG = logging.getLogger(__name__) + class BaseDataModel(object): def to_dict(self, calling_classes=None, recurse=False, **kwargs): @@ -326,7 +329,11 @@ class Pool(BaseDataModel): break for pool in self.load_balancer.pools: if pool.id == self.id: - self.load_balancer.pools.remove(pool) + try: + self.load_balancer.pools.remove(pool) + except ValueError: + LOG.debug("Pool %s has already been removed from load " + "balancer pools list.", pool.id) break for l7policy in self.l7policies: if l7policy.redirect_pool_id == self.id: