From a7575ae6afc12ef771dabcc2126fdbbe4b25986e Mon Sep 17 00:00:00 2001 From: Kobi Samoray Date: Thu, 22 Apr 2021 10:27:50 +0300 Subject: [PATCH] NSXV: Octavia L7 rule delete Fix a bug with L7 rule deletion Change-Id: Ib40040c5d85ebef7d8566d1d2a46438367887927 --- .../lbaas/nsx_v/implementation/l7policy_mgr.py | 2 +- .../services/lbaas/nsx_v/implementation/l7rule_mgr.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/vmware_nsx/services/lbaas/nsx_v/implementation/l7policy_mgr.py b/vmware_nsx/services/lbaas/nsx_v/implementation/l7policy_mgr.py index 249e787ba7..2cc1650c59 100644 --- a/vmware_nsx/services/lbaas/nsx_v/implementation/l7policy_mgr.py +++ b/vmware_nsx/services/lbaas/nsx_v/implementation/l7policy_mgr.py @@ -42,7 +42,7 @@ def policy_to_application_rule(policy): condition = '' rule_lines = [] for rule in policy['rules']: - if rule['provisioning_status'] == constants.PENDING_DELETE: + if rule.get('provisioning_status') == constants.PENDING_DELETE: # skip this rule as it is being deleted continue diff --git a/vmware_nsx/services/lbaas/nsx_v/implementation/l7rule_mgr.py b/vmware_nsx/services/lbaas/nsx_v/implementation/l7rule_mgr.py index 68e75c4d4f..bede8732dd 100644 --- a/vmware_nsx/services/lbaas/nsx_v/implementation/l7rule_mgr.py +++ b/vmware_nsx/services/lbaas/nsx_v/implementation/l7rule_mgr.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import constants from oslo_log import helpers as log_helpers from oslo_log import log as logging from oslo_utils import excutils @@ -29,8 +30,7 @@ class EdgeL7RuleManagerFromDict(base_mgr.EdgeLoadbalancerBaseManager): def __init__(self, vcns_driver): super(EdgeL7RuleManagerFromDict, self).__init__(vcns_driver) - def _handle_l7policy_rules_change(self, context, rule, completor, - delete=False): + def _handle_l7policy_rules_change(self, context, rule, completor): # Get the nsx application rule id and edge id edge_id, app_rule_id = l7policy_mgr.policy_to_edge_and_rule_id( context, rule['l7policy_id']) @@ -60,8 +60,11 @@ class EdgeL7RuleManagerFromDict(base_mgr.EdgeLoadbalancerBaseManager): self._handle_l7policy_rules_change(context, new_rule, completor) def delete(self, context, rule, completor): - self._handle_l7policy_rules_change(context, rule, completor, - delete=True) + # Mark rule for deletion in policy rule list + for r in rule['policy']['rules']: + if r['l7rule_id'] == rule['l7rule_id']: + r['provisioning_status'] = constants.PENDING_DELETE + self._handle_l7policy_rules_change(context, rule, completor) def delete_cascade(self, context, rule, completor): self.delete(context, rule, completor)