@@ -64,6 +64,7 @@ const (
64
64
defaultLoadBalancerSourceRangesIPv4 = "0.0.0.0/0"
65
65
defaultLoadBalancerSourceRangesIPv6 = "::/0"
66
66
activeStatus = "ACTIVE"
67
+ errorStatus = "ERROR"
67
68
annotationXForwardedFor = "X-Forwarded-For"
68
69
69
70
ServiceAnnotationLoadBalancerInternal = "service.beta.kubernetes.io/openstack-internal-load-balancer"
@@ -1176,8 +1177,8 @@ func (lbaas *LbaasV2) ensureOctaviaHealthMonitor(lbID string, name string, pool
1176
1177
return err
1177
1178
}
1178
1179
//Recreate health monitor with correct protocol if externalTrafficPolicy was changed
1179
- if (svcConf . healthCheckNodePort > 0 && monitor . Type != "HTTP" ) ||
1180
- ( svcConf . healthCheckNodePort == 0 && monitor .Type == "HTTP" ) {
1180
+ createOpts := lbaas . buildMonitorCreateOpts (svcConf , port )
1181
+ if createOpts . Type != monitor .Type {
1181
1182
klog .InfoS ("Recreating health monitor for the pool" , "pool" , pool .ID , "oldMonitor" , monitorID )
1182
1183
if err := openstackutil .DeleteHealthMonitor (lbaas .lb , monitorID , lbID ); err != nil {
1183
1184
return err
@@ -1220,6 +1221,18 @@ func (lbaas *LbaasV2) ensureOctaviaHealthMonitor(lbID string, name string, pool
1220
1221
return nil
1221
1222
}
1222
1223
1224
+ func (lbaas * LbaasV2 ) canUseHTTPMonitor (port corev1.ServicePort ) bool {
1225
+ if lbaas .opts .LBProvider == "ovn" {
1226
+ // ovn-octavia-provider doesn't support HTTP monitors at all. We got to avoid creating it with ovn.
1227
+ return false
1228
+ } else if port .Protocol == corev1 .ProtocolUDP {
1229
+ // Older Octavia versions or OVN provider doesn't support HTTP monitors on UDP pools. We got to check if that's the case.
1230
+ return openstackutil .IsOctaviaFeatureSupported (lbaas .lb , openstackutil .OctaviaFeatureHTTPMonitorsOnUDP , lbaas .opts .LBProvider )
1231
+ }
1232
+
1233
+ return true
1234
+ }
1235
+
1223
1236
// buildMonitorCreateOpts returns a v2monitors.CreateOpts without PoolID for consumption of both, fully popuplated Loadbalancers and Monitors.
1224
1237
func (lbaas * LbaasV2 ) buildMonitorCreateOpts (svcConf * serviceConfig , port corev1.ServicePort ) v2monitors.CreateOpts {
1225
1238
opts := v2monitors.CreateOpts {
@@ -1231,22 +1244,11 @@ func (lbaas *LbaasV2) buildMonitorCreateOpts(svcConf *serviceConfig, port corev1
1231
1244
if port .Protocol == corev1 .ProtocolUDP {
1232
1245
opts .Type = "UDP-CONNECT"
1233
1246
}
1234
- if svcConf .healthCheckNodePort > 0 {
1235
- setHTTPHealthMonitor := true
1236
- if lbaas .opts .LBProvider == "ovn" {
1237
- // ovn-octavia-provider doesn't support HTTP monitors at all. We got to avoid creating it with ovn.
1238
- setHTTPHealthMonitor = false
1239
- } else if opts .Type == "UDP-CONNECT" {
1240
- // Older Octavia versions or OVN provider doesn't support HTTP monitors on UDP pools. We got to check if that's the case.
1241
- setHTTPHealthMonitor = openstackutil .IsOctaviaFeatureSupported (lbaas .lb , openstackutil .OctaviaFeatureHTTPMonitorsOnUDP , lbaas .opts .LBProvider )
1242
- }
1243
-
1244
- if setHTTPHealthMonitor {
1245
- opts .Type = "HTTP"
1246
- opts .URLPath = "/healthz"
1247
- opts .HTTPMethod = "GET"
1248
- opts .ExpectedCodes = "200"
1249
- }
1247
+ if svcConf .healthCheckNodePort > 0 && lbaas .canUseHTTPMonitor (port ) {
1248
+ opts .Type = "HTTP"
1249
+ opts .URLPath = "/healthz"
1250
+ opts .HTTPMethod = "GET"
1251
+ opts .ExpectedCodes = "200"
1250
1252
}
1251
1253
return opts
1252
1254
}
@@ -1372,20 +1374,8 @@ func (lbaas *LbaasV2) buildBatchUpdateMemberOpts(port corev1.ServicePort, nodes
1372
1374
Name : & node .Name ,
1373
1375
SubnetID : & svcConf .lbMemberSubnetID ,
1374
1376
}
1375
- if svcConf .healthCheckNodePort > 0 {
1376
- useHealthCheckNodePort := true
1377
- if lbaas .opts .LBProvider == "ovn" {
1378
- // ovn-octavia-provider doesn't support HTTP monitors at all, if we have it we got to rely on NodePort
1379
- // and UDP-CONNECT health monitor.
1380
- useHealthCheckNodePort = false
1381
- } else if port .Protocol == "UDP" {
1382
- // Older Octavia versions doesn't support HTTP monitors on UDP pools. If we have one like that, we got
1383
- // to rely on checking the NodePort instead.
1384
- useHealthCheckNodePort = openstackutil .IsOctaviaFeatureSupported (lbaas .lb , openstackutil .OctaviaFeatureHTTPMonitorsOnUDP , lbaas .opts .LBProvider )
1385
- }
1386
- if useHealthCheckNodePort {
1387
- member .MonitorPort = & svcConf .healthCheckNodePort
1388
- }
1377
+ if svcConf .healthCheckNodePort > 0 && lbaas .canUseHTTPMonitor (port ) {
1378
+ member .MonitorPort = & svcConf .healthCheckNodePort
1389
1379
}
1390
1380
members = append (members , member )
1391
1381
newMembers .Insert (fmt .Sprintf ("%s-%s-%d-%d" , node .Name , addr , member .ProtocolPort , svcConf .healthCheckNodePort ))
@@ -3462,8 +3452,8 @@ func (lbaas *LbaasV2) ensureLoadBalancerDeleted(ctx context.Context, clusterName
3462
3452
return nil
3463
3453
}
3464
3454
3465
- if loadbalancer .ProvisioningStatus != activeStatus {
3466
- return fmt .Errorf ("load balancer %s is not ACTIVE , current provisioning status: %s" , loadbalancer .ID , loadbalancer .ProvisioningStatus )
3455
+ if loadbalancer .ProvisioningStatus != activeStatus && loadbalancer . ProvisioningStatus != errorStatus {
3456
+ return fmt .Errorf ("load balancer %s is in immutable status , current provisioning status: %s" , loadbalancer .ID , loadbalancer .ProvisioningStatus )
3467
3457
}
3468
3458
3469
3459
if strings .HasPrefix (loadbalancer .Name , servicePrefix ) {
0 commit comments