@@ -1278,19 +1278,6 @@ func (lbaas *LbaasV2) checkServiceUpdate(service *corev1.Service, nodes []*corev
12781278 svcConf .preferredIPFamily = service .Spec .IPFamilies [0 ]
12791279 }
12801280
1281- svcConf .lbID = getStringFromServiceAnnotation (service , ServiceAnnotationLoadBalancerID , "" )
1282- svcConf .supportLBTags = openstackutil .IsOctaviaFeatureSupported (lbaas .lb , openstackutil .OctaviaFeatureTags , lbaas .opts .LBProvider )
1283-
1284- // Get service node-selector annotations
1285- svcConf .nodeSelectors = getKeyValueFromServiceAnnotation (service , ServiceAnnotationLoadBalancerNodeSelector , lbaas .opts .NodeSelector )
1286- for key , value := range svcConf .nodeSelectors {
1287- if value == "" {
1288- klog .V (3 ).InfoS ("Target node label %s key is set to LoadBalancer service %s" , key , serviceName )
1289- } else {
1290- klog .V (3 ).InfoS ("Target node label %s=%s is set to LoadBalancer service %s" , key , value , serviceName )
1291- }
1292- }
1293-
12941281 // Find subnet ID for creating members
12951282 memberSubnetID , err := lbaas .getMemberSubnetID (service )
12961283 if err != nil {
@@ -1322,25 +1309,7 @@ func (lbaas *LbaasV2) checkServiceUpdate(service *corev1.Service, nodes []*corev
13221309 }
13231310 }
13241311 }
1325-
1326- // This affects the protocol of listener and pool
1327- keepClientIP := getBoolFromServiceAnnotation (service , ServiceAnnotationLoadBalancerXForwardedFor , false )
1328- svcConf .proxyProtocolVersion = getProxyProtocolFromServiceAnnotation (service )
1329- if svcConf .proxyProtocolVersion != nil && keepClientIP {
1330- return fmt .Errorf ("annotation %s and %s cannot be used together" , ServiceAnnotationLoadBalancerProxyEnabled , ServiceAnnotationLoadBalancerXForwardedFor )
1331- }
1332- svcConf .keepClientIP = keepClientIP
1333-
1334- svcConf .tlsContainerRef = getStringFromServiceAnnotation (service , ServiceAnnotationTlsContainerRef , lbaas .opts .TlsContainerRef )
1335- svcConf .enableMonitor = getBoolFromServiceAnnotation (service , ServiceAnnotationLoadBalancerEnableHealthMonitor , lbaas .opts .CreateMonitor )
1336- if svcConf .enableMonitor && service .Spec .ExternalTrafficPolicy == corev1 .ServiceExternalTrafficPolicyTypeLocal && service .Spec .HealthCheckNodePort > 0 {
1337- svcConf .healthCheckNodePort = int (service .Spec .HealthCheckNodePort )
1338- }
1339- svcConf .healthMonitorDelay = getIntFromServiceAnnotation (service , ServiceAnnotationLoadBalancerHealthMonitorDelay , int (lbaas .opts .MonitorDelay .Duration .Seconds ()))
1340- svcConf .healthMonitorTimeout = getIntFromServiceAnnotation (service , ServiceAnnotationLoadBalancerHealthMonitorTimeout , int (lbaas .opts .MonitorTimeout .Duration .Seconds ()))
1341- svcConf .healthMonitorMaxRetries = getIntFromServiceAnnotation (service , ServiceAnnotationLoadBalancerHealthMonitorMaxRetries , int (lbaas .opts .MonitorMaxRetries ))
1342- svcConf .healthMonitorMaxRetriesDown = getIntFromServiceAnnotation (service , ServiceAnnotationLoadBalancerHealthMonitorMaxRetriesDown , int (lbaas .opts .MonitorMaxRetriesDown ))
1343- return nil
1312+ return lbaas .makeSvcConf (serviceName , service , svcConf )
13441313}
13451314
13461315func (lbaas * LbaasV2 ) checkServiceDelete (service * corev1.Service , svcConf * serviceConfig ) error {
@@ -1372,19 +1341,6 @@ func (lbaas *LbaasV2) checkService(service *corev1.Service, nodes []*corev1.Node
13721341 svcConf .preferredIPFamily = service .Spec .IPFamilies [0 ]
13731342 }
13741343
1375- svcConf .lbID = getStringFromServiceAnnotation (service , ServiceAnnotationLoadBalancerID , "" )
1376- svcConf .supportLBTags = openstackutil .IsOctaviaFeatureSupported (lbaas .lb , openstackutil .OctaviaFeatureTags , lbaas .opts .LBProvider )
1377-
1378- // Get service node-selector annotations
1379- svcConf .nodeSelectors = getKeyValueFromServiceAnnotation (service , ServiceAnnotationLoadBalancerNodeSelector , lbaas .opts .NodeSelector )
1380- for key , value := range svcConf .nodeSelectors {
1381- if value == "" {
1382- klog .V (3 ).InfoS ("Target node label %s key is set to LoadBalancer service %s" , key , serviceName )
1383- } else {
1384- klog .V (3 ).InfoS ("Target node label %s=%s is set to LoadBalancer service %s" , key , value , serviceName )
1385- }
1386- }
1387-
13881344 // If in the config file internal-lb=true, user is not allowed to create external service.
13891345 if lbaas .opts .InternalLB {
13901346 if ! getBoolFromServiceAnnotation (service , ServiceAnnotationLoadBalancerInternal , false ) {
@@ -1429,8 +1385,6 @@ func (lbaas *LbaasV2) checkService(service *corev1.Service, nodes []*corev1.Node
14291385 }
14301386 }
14311387
1432- svcConf .connLimit = getIntFromServiceAnnotation (service , ServiceAnnotationLoadBalancerConnLimit , - 1 )
1433-
14341388 lbNetworkID , err := lbaas .getNetworkID (service , svcConf )
14351389 if err != nil {
14361390 return fmt .Errorf ("failed to get network id to create load balancer for service %s: %v" , serviceName , err )
@@ -1549,6 +1503,23 @@ func (lbaas *LbaasV2) checkService(service *corev1.Service, nodes []*corev1.Node
15491503 } else {
15501504 klog .V (4 ).Infof ("Ensure an internal loadbalancer service." )
15511505 }
1506+ return lbaas .makeSvcConf (serviceName , service , svcConf )
1507+ }
1508+
1509+ func (lbaas * LbaasV2 ) makeSvcConf (serviceName string , service * corev1.Service , svcConf * serviceConfig ) error {
1510+ svcConf .connLimit = getIntFromServiceAnnotation (service , ServiceAnnotationLoadBalancerConnLimit , - 1 )
1511+ svcConf .lbID = getStringFromServiceAnnotation (service , ServiceAnnotationLoadBalancerID , "" )
1512+ svcConf .supportLBTags = openstackutil .IsOctaviaFeatureSupported (lbaas .lb , openstackutil .OctaviaFeatureTags , lbaas .opts .LBProvider )
1513+
1514+ // Get service node-selector annotations
1515+ svcConf .nodeSelectors = getKeyValueFromServiceAnnotation (service , ServiceAnnotationLoadBalancerNodeSelector , lbaas .opts .NodeSelector )
1516+ for key , value := range svcConf .nodeSelectors {
1517+ if value == "" {
1518+ klog .V (3 ).InfoS ("Target node label %s key is set to LoadBalancer service %s" , key , serviceName )
1519+ } else {
1520+ klog .V (3 ).InfoS ("Target node label %s=%s is set to LoadBalancer service %s" , key , value , serviceName )
1521+ }
1522+ }
15521523
15531524 keepClientIP := getBoolFromServiceAnnotation (service , ServiceAnnotationLoadBalancerXForwardedFor , false )
15541525 svcConf .proxyProtocolVersion = getProxyProtocolFromServiceAnnotation (service )
@@ -1593,6 +1564,7 @@ func (lbaas *LbaasV2) checkService(service *corev1.Service, nodes []*corev1.Node
15931564 klog .Warningf (msg , serviceName )
15941565 }
15951566
1567+ svcConf .tlsContainerRef = getStringFromServiceAnnotation (service , ServiceAnnotationTlsContainerRef , lbaas .opts .TlsContainerRef )
15961568 svcConf .enableMonitor = getBoolFromServiceAnnotation (service , ServiceAnnotationLoadBalancerEnableHealthMonitor , lbaas .opts .CreateMonitor )
15971569 if svcConf .enableMonitor && service .Spec .ExternalTrafficPolicy == corev1 .ServiceExternalTrafficPolicyTypeLocal && service .Spec .HealthCheckNodePort > 0 {
15981570 svcConf .healthCheckNodePort = int (service .Spec .HealthCheckNodePort )
0 commit comments