Skip to content

Commit 246e057

Browse files
authored
[release-1.30] [occm] fix ovn security groups (#2714)
* fix ovn security groups * add tlscontainerref
1 parent 790b5dc commit 246e057

File tree

1 file changed

+19
-48
lines changed

1 file changed

+19
-48
lines changed

pkg/openstack/loadbalancer.go

Lines changed: 19 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,19 +1236,6 @@ func (lbaas *LbaasV2) checkServiceUpdate(service *corev1.Service, nodes []*corev
12361236
svcConf.preferredIPFamily = service.Spec.IPFamilies[0]
12371237
}
12381238

1239-
svcConf.lbID = getStringFromServiceAnnotation(service, ServiceAnnotationLoadBalancerID, "")
1240-
svcConf.supportLBTags = openstackutil.IsOctaviaFeatureSupported(lbaas.lb, openstackutil.OctaviaFeatureTags, lbaas.opts.LBProvider)
1241-
1242-
// Get service node-selector annotations
1243-
svcConf.nodeSelectors = getKeyValueFromServiceAnnotation(service, ServiceAnnotationLoadBalancerNodeSelector, lbaas.opts.NodeSelector)
1244-
for key, value := range svcConf.nodeSelectors {
1245-
if value == "" {
1246-
klog.V(3).InfoS("Target node label %s key is set to LoadBalancer service %s", key, serviceName)
1247-
} else {
1248-
klog.V(3).InfoS("Target node label %s=%s is set to LoadBalancer service %s", key, value, serviceName)
1249-
}
1250-
}
1251-
12521239
// Find subnet ID for creating members
12531240
memberSubnetID, err := lbaas.getMemberSubnetID(service)
12541241
if err != nil {
@@ -1280,26 +1267,7 @@ func (lbaas *LbaasV2) checkServiceUpdate(service *corev1.Service, nodes []*corev
12801267
}
12811268
}
12821269
}
1283-
1284-
// This affects the protocol of listener and pool
1285-
keepClientIP := getBoolFromServiceAnnotation(service, ServiceAnnotationLoadBalancerXForwardedFor, false)
1286-
useProxyProtocol := getBoolFromServiceAnnotation(service, ServiceAnnotationLoadBalancerProxyEnabled, false)
1287-
if useProxyProtocol && keepClientIP {
1288-
return fmt.Errorf("annotation %s and %s cannot be used together", ServiceAnnotationLoadBalancerProxyEnabled, ServiceAnnotationLoadBalancerXForwardedFor)
1289-
}
1290-
svcConf.keepClientIP = keepClientIP
1291-
svcConf.enableProxyProtocol = useProxyProtocol
1292-
1293-
svcConf.tlsContainerRef = getStringFromServiceAnnotation(service, ServiceAnnotationTlsContainerRef, lbaas.opts.TlsContainerRef)
1294-
svcConf.enableMonitor = getBoolFromServiceAnnotation(service, ServiceAnnotationLoadBalancerEnableHealthMonitor, lbaas.opts.CreateMonitor)
1295-
if svcConf.enableMonitor && service.Spec.ExternalTrafficPolicy == corev1.ServiceExternalTrafficPolicyTypeLocal && service.Spec.HealthCheckNodePort > 0 {
1296-
svcConf.healthCheckNodePort = int(service.Spec.HealthCheckNodePort)
1297-
}
1298-
svcConf.healthMonitorDelay = getIntFromServiceAnnotation(service, ServiceAnnotationLoadBalancerHealthMonitorDelay, int(lbaas.opts.MonitorDelay.Duration.Seconds()))
1299-
svcConf.healthMonitorTimeout = getIntFromServiceAnnotation(service, ServiceAnnotationLoadBalancerHealthMonitorTimeout, int(lbaas.opts.MonitorTimeout.Duration.Seconds()))
1300-
svcConf.healthMonitorMaxRetries = getIntFromServiceAnnotation(service, ServiceAnnotationLoadBalancerHealthMonitorMaxRetries, int(lbaas.opts.MonitorMaxRetries))
1301-
svcConf.healthMonitorMaxRetriesDown = getIntFromServiceAnnotation(service, ServiceAnnotationLoadBalancerHealthMonitorMaxRetriesDown, int(lbaas.opts.MonitorMaxRetriesDown))
1302-
return nil
1270+
return lbaas.makeSvcConf(serviceName, service, svcConf)
13031271
}
13041272

13051273
func (lbaas *LbaasV2) checkServiceDelete(service *corev1.Service, svcConf *serviceConfig) error {
@@ -1331,19 +1299,6 @@ func (lbaas *LbaasV2) checkService(service *corev1.Service, nodes []*corev1.Node
13311299
svcConf.preferredIPFamily = service.Spec.IPFamilies[0]
13321300
}
13331301

1334-
svcConf.lbID = getStringFromServiceAnnotation(service, ServiceAnnotationLoadBalancerID, "")
1335-
svcConf.supportLBTags = openstackutil.IsOctaviaFeatureSupported(lbaas.lb, openstackutil.OctaviaFeatureTags, lbaas.opts.LBProvider)
1336-
1337-
// Get service node-selector annotations
1338-
svcConf.nodeSelectors = getKeyValueFromServiceAnnotation(service, ServiceAnnotationLoadBalancerNodeSelector, lbaas.opts.NodeSelector)
1339-
for key, value := range svcConf.nodeSelectors {
1340-
if value == "" {
1341-
klog.V(3).InfoS("Target node label %s key is set to LoadBalancer service %s", key, serviceName)
1342-
} else {
1343-
klog.V(3).InfoS("Target node label %s=%s is set to LoadBalancer service %s", key, value, serviceName)
1344-
}
1345-
}
1346-
13471302
// If in the config file internal-lb=true, user is not allowed to create external service.
13481303
if lbaas.opts.InternalLB {
13491304
if !getBoolFromServiceAnnotation(service, ServiceAnnotationLoadBalancerInternal, false) {
@@ -1388,8 +1343,6 @@ func (lbaas *LbaasV2) checkService(service *corev1.Service, nodes []*corev1.Node
13881343
}
13891344
}
13901345

1391-
svcConf.connLimit = getIntFromServiceAnnotation(service, ServiceAnnotationLoadBalancerConnLimit, -1)
1392-
13931346
lbNetworkID, err := lbaas.getNetworkID(service, svcConf)
13941347
if err != nil {
13951348
return fmt.Errorf("failed to get network id to create load balancer for service %s: %v", serviceName, err)
@@ -1508,6 +1461,23 @@ func (lbaas *LbaasV2) checkService(service *corev1.Service, nodes []*corev1.Node
15081461
} else {
15091462
klog.V(4).Infof("Ensure an internal loadbalancer service.")
15101463
}
1464+
return lbaas.makeSvcConf(serviceName, service, svcConf)
1465+
}
1466+
1467+
func (lbaas *LbaasV2) makeSvcConf(serviceName string, service *corev1.Service, svcConf *serviceConfig) error {
1468+
svcConf.connLimit = getIntFromServiceAnnotation(service, ServiceAnnotationLoadBalancerConnLimit, -1)
1469+
svcConf.lbID = getStringFromServiceAnnotation(service, ServiceAnnotationLoadBalancerID, "")
1470+
svcConf.supportLBTags = openstackutil.IsOctaviaFeatureSupported(lbaas.lb, openstackutil.OctaviaFeatureTags, lbaas.opts.LBProvider)
1471+
1472+
// Get service node-selector annotations
1473+
svcConf.nodeSelectors = getKeyValueFromServiceAnnotation(service, ServiceAnnotationLoadBalancerNodeSelector, lbaas.opts.NodeSelector)
1474+
for key, value := range svcConf.nodeSelectors {
1475+
if value == "" {
1476+
klog.V(3).InfoS("Target node label %s key is set to LoadBalancer service %s", key, serviceName)
1477+
} else {
1478+
klog.V(3).InfoS("Target node label %s=%s is set to LoadBalancer service %s", key, value, serviceName)
1479+
}
1480+
}
15111481

15121482
keepClientIP := getBoolFromServiceAnnotation(service, ServiceAnnotationLoadBalancerXForwardedFor, false)
15131483
useProxyProtocol := getBoolFromServiceAnnotation(service, ServiceAnnotationLoadBalancerProxyEnabled, false)
@@ -1553,6 +1523,7 @@ func (lbaas *LbaasV2) checkService(service *corev1.Service, nodes []*corev1.Node
15531523
klog.Warningf(msg, serviceName)
15541524
}
15551525

1526+
svcConf.tlsContainerRef = getStringFromServiceAnnotation(service, ServiceAnnotationTlsContainerRef, lbaas.opts.TlsContainerRef)
15561527
svcConf.enableMonitor = getBoolFromServiceAnnotation(service, ServiceAnnotationLoadBalancerEnableHealthMonitor, lbaas.opts.CreateMonitor)
15571528
if svcConf.enableMonitor && service.Spec.ExternalTrafficPolicy == corev1.ServiceExternalTrafficPolicyTypeLocal && service.Spec.HealthCheckNodePort > 0 {
15581529
svcConf.healthCheckNodePort = int(service.Spec.HealthCheckNodePort)

0 commit comments

Comments
 (0)