Replace duplicate code to get klb crd path

As part of the change below, we are adding a utility code to get klb crd
path.

The klb crd shares the same namespace and the name as the service,
endpoints.

This code can be hence re-used for services too.

Depends-On: https://review.opendev.org/c/openstack/kuryr-kubernetes/+/804205
Change-Id: I90c8851e01de16b82617d60c987bad50a1522dd5
This commit is contained in:
Robin Cernin 2021-08-16 09:23:38 +10:00
parent 990ba608d6
commit 1e53f3adac
1 changed files with 1 additions and 5 deletions

View File

@ -114,11 +114,7 @@ class ServiceHandler(k8s_base.ResourceEventHandler):
def on_finalize(self, service, *args, **kwargs):
k8s = clients.get_kubernetes_client()
svc_name = service['metadata']['name']
svc_namespace = service['metadata']['namespace']
klb_crd_path = (f"{k_const.K8S_API_CRD_NAMESPACES}/"
f"{svc_namespace}/kuryrloadbalancers/{svc_name}")
klb_crd_path = utils.get_klb_crd_path(service)
# Bump all the NPs in the namespace to force SG rules
# recalculation.
self._bump_network_policies(service)