From 886c5a1a00f939592def4499d48e2bbcd0005e9a Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Wed, 27 Oct 2021 13:55:19 -0700 Subject: [PATCH] [API replay] Update of LB allocation pool This change ensures the LB pool for a router is updated according to the LB size when attaching a load balancer to it. Implemented only for API replay cases on NSX Policy. Change-Id: Id9d6514ccfdb240cf8a9542fcfaaaf672af85154 --- vmware_nsx/services/lbaas/lb_const.py | 10 ++++++++++ .../nsx_p/implementation/loadbalancer_mgr.py | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/vmware_nsx/services/lbaas/lb_const.py b/vmware_nsx/services/lbaas/lb_const.py index 3d07469d2e..32f697b205 100644 --- a/vmware_nsx/services/lbaas/lb_const.py +++ b/vmware_nsx/services/lbaas/lb_const.py @@ -109,6 +109,16 @@ LR_PORT_TYPE = 'os-neutron-rport-id' LB_CERT_RESOURCE_TYPE = ['certificate_signed', 'certificate_self_signed'] DEFAULT_LB_SIZE = 'SMALL' LB_FLAVOR_SIZES = ['SMALL', 'MEDIUM', 'LARGE', 'small', 'medium', 'large'] +POLICY_TIER1_POOL_ALLOC_ROUTING = 'ROUTING' +POLICY_TIER1_POOL_ALLOC_SMALL = 'LB_SMALL' +POLICY_TIER1_POOL_ALLOC_MEDIUM = 'LB_MEDIUM' +POLICY_TIER1_POOL_ALLOC_LARGE = 'LB_LARGE' +POOL_ALLOCATION_MAP = { + 'SMALL': POLICY_TIER1_POOL_ALLOC_SMALL, + 'MEDIUM': POLICY_TIER1_POOL_ALLOC_MEDIUM, + 'LARGE': POLICY_TIER1_POOL_ALLOC_LARGE, +} + LB_RULE_MATCH_TYPE = { L7_RULE_COMPARE_TYPE_CONTAINS: 'CONTAINS', L7_RULE_COMPARE_TYPE_ENDS_WITH: 'ENDS_WITH', diff --git a/vmware_nsx/services/lbaas/nsx_p/implementation/loadbalancer_mgr.py b/vmware_nsx/services/lbaas/nsx_p/implementation/loadbalancer_mgr.py index fa54f6f8cd..4d65fc4240 100644 --- a/vmware_nsx/services/lbaas/nsx_p/implementation/loadbalancer_mgr.py +++ b/vmware_nsx/services/lbaas/nsx_p/implementation/loadbalancer_mgr.py @@ -12,8 +12,10 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +import time from neutron_lib import exceptions as n_exc +from oslo_config import cfg from oslo_log import log as logging from oslo_utils import excutils @@ -104,6 +106,23 @@ class EdgeLoadBalancerManagerFromDict(base_mgr.NsxpLoadbalancerBaseManager): else: tier1_srv = self.core_plugin.nsxpolicy.tier1 connectivity_path = tier1_srv.get_path(router_id) + # In API replay mode, reallocate router pool. + # This migth cause some traffic disruption, so only + # execute this during API replay, when the router + # is not serving any traffic + if cfg.CONF.api_replay_mode: + pool_name = lb_const.POOL_ALLOCATION_MAP[lb_size] + LOG.debug("Moving router %s into %s pool", + router_id, pool_name) + tier1_srv.update( + router_id, + pool_allocation=pool_name) + # The sleep below is to provide a little buffer before + # starting realization checks + time.sleep(2) + LOG.debug("Waiting for realization of %s", router_id) + tier1_srv.wait_until_realized(router_id) + LOG.debug("Router %s realized", router_id) if connectivity_path: with p_utils.get_lb_rtr_lock(router_id): service_client.create_or_overwrite(