From cb3890d7df6bf4eb837512d4ee010077836ca115 Mon Sep 17 00:00:00 2001 From: Matthias Baur Date: Wed, 15 May 2024 14:41:45 +0200 Subject: [PATCH] Allow automatic recreation on LB ERROR state to be disabled This is e.g. helpful when you try to debug the LB in ERROR state. --- pkg/openstack/loadbalancer.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/openstack/loadbalancer.go b/pkg/openstack/loadbalancer.go index 895453b211..aeeba7f12d 100644 --- a/pkg/openstack/loadbalancer.go +++ b/pkg/openstack/loadbalancer.go @@ -88,8 +88,9 @@ const ( ServiceAnnotationTlsContainerRef = "loadbalancer.openstack.org/default-tls-container-ref" // revive:enable:var-naming // See https://nip.io - defaultProxyHostnameSuffix = "nip.io" - ServiceAnnotationLoadBalancerID = "loadbalancer.openstack.org/load-balancer-id" + defaultProxyHostnameSuffix = "nip.io" + ServiceAnnotationLoadBalancerID = "loadbalancer.openstack.org/load-balancer-id" + ServiceAnnotationLoadBalancerRecreateOnError = "loadbalancer.openstack.org/recreate-on-error" // Octavia resources name formats servicePrefix = "kube_service_" @@ -306,8 +307,11 @@ func (lbaas *LbaasV2) createOctaviaLoadBalancer(name, clusterName string, servic svcConf.lbMemberSubnetID = loadbalancer.VipSubnetID } + // Allow users to disable automatic recreation on Octavia ERROR state + recreateOnError := getBoolFromServiceAnnotation(service, ServiceAnnotationLoadBalancerRecreateOnError, true) + if loadbalancer, err = openstackutil.WaitActiveAndGetLoadBalancer(lbaas.lb, loadbalancer.ID); err != nil { - if loadbalancer != nil && loadbalancer.ProvisioningStatus == errorStatus { + if loadbalancer != nil && loadbalancer.ProvisioningStatus == errorStatus && recreateOnError { // If LB landed in ERROR state we should delete it and retry the creation later. if err = lbaas.deleteLoadBalancer(loadbalancer, service, svcConf, true); err != nil { return nil, fmt.Errorf("loadbalancer %s is in ERROR state and there was an error when removing it: %v", loadbalancer.ID, err)