Delete loadbalancers and floatingips for service and ingress

This patch makes the regex more broad to cover both services and ingresses that
create load balancers in octavia. In cloud-provider-openstack repo, the load
balancer description is defined in:

- f056677572/pkg/cloudprovider/providers/openstack/openstack_loadbalancer.go (L459)
- f056677572/pkg/ingress/controller/openstack/octavia.go (L316)

The floating ip description is defined in:

- f056677572/pkg/cloudprovider/providers/openstack/openstack_loadbalancer.go (L1063)
- f056677572/pkg/ingress/controller/openstack/neutron.go (L72)

Change-Id: I7ce38e38de0d66fac340e287ce520de4c4bf679d
Story: 2004839
(cherry picked from commit d2f36a2ed1)
This commit is contained in:
Lingxian Kong 2019-01-23 11:44:36 +13:00 committed by Feilong Wang
parent 50bddcb17d
commit c056ac4ce5
2 changed files with 10 additions and 9 deletions

View File

@ -25,15 +25,14 @@ def delete_floatingip(context, fix_port_id, cluster):
"""Deletes the floating IP associated with the fix_port_id.
Only delete the floating IP if it's created and associated with the
LoadBalancer type service in Kubernetes cluster.
the load balancers that corresponding to the services and ingresses in
Kubernetes cluster.
This method only works with the Kubernetes cluster with
cloud-provider-openstack controller manager deployed, patched with
this PR:
https://github.com/kubernetes/cloud-provider-openstack/pull/433
cloud-provider-openstack controller manager deployed.
"""
pattern = (r'Floating IP for Kubernetes external service \w+ from cluster '
r'%s$' % cluster.uuid)
pattern = (r'Floating IP for Kubernetes .+ from cluster %s$' %
cluster.uuid)
try:
n_client = clients.OpenStackClients(context).neutron()

View File

@ -52,15 +52,17 @@ def wait_for_lb_deleted(octavia_client, deleted_lbs):
def delete_loadbalancers(context, cluster):
"""Delete loadbalancers for k8s service.
"""Delete loadbalancers for kubernetes resources.
This method only works for the k8s cluster with
cloud-provider-openstack manager or controller-manager patched with
this PR:
https://github.com/kubernetes/cloud-provider-openstack/pull/223
The load balancers created for kubernetes services and ingresses are
deleted.
"""
pattern = (r'Kubernetes external service \w+ from cluster %s$' %
cluster.uuid)
pattern = (r'Kubernetes .+ from cluster %s$' % cluster.uuid)
valid_status = ["ACTIVE", "ERROR", "PENDING_DELETE", "DELETED"]
try: