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)