Skip to content

Commit 0418c18

Browse files
authored
Do not create HTTP monitors for UDP on old Octavia (kubernetes#2000)
Octavia API before 2.16 doesn't support HTTP monitors on UDP pools. It will however allow creation of such if all-in-one LB creation call is used. This is a problem for UDP `ETP=Local` Services, where `healthCheckNodePort` is allocated and CCM will try to create HTTP monitor there. This monitor will be completely not functional. OVN Octavia provider doesn't support HTTP health monitors either. This commit fixes that by making sure we're checking Octavia API version and if it's lower than 2.16 we fall back to creating UDP-CONNECT health monitors on a regular port instead. Moreover same is done when provider is set to "ovn".
1 parent 7aaf505 commit 0418c18

File tree

2 files changed

+37
-5
lines changed

2 files changed

+37
-5
lines changed

pkg/openstack/loadbalancer.go

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,10 +1232,21 @@ func (lbaas *LbaasV2) buildMonitorCreateOpts(svcConf *serviceConfig, port corev1
12321232
opts.Type = "UDP-CONNECT"
12331233
}
12341234
if svcConf.healthCheckNodePort > 0 {
1235-
opts.Type = "HTTP"
1236-
opts.URLPath = "/healthz"
1237-
opts.HTTPMethod = "GET"
1238-
opts.ExpectedCodes = "200"
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+
}
12391250
}
12401251
return opts
12411252
}
@@ -1361,7 +1372,19 @@ func (lbaas *LbaasV2) buildBatchUpdateMemberOpts(port corev1.ServicePort, nodes
13611372
SubnetID: &svcConf.lbMemberSubnetID,
13621373
}
13631374
if svcConf.healthCheckNodePort > 0 {
1364-
member.MonitorPort = &svcConf.healthCheckNodePort
1375+
useHealthCheckNodePort := true
1376+
if lbaas.opts.LBProvider == "ovn" {
1377+
// ovn-octavia-provider doesn't support HTTP monitors at all, if we have it we got to rely on NodePort
1378+
// and UDP-CONNECT health monitor.
1379+
useHealthCheckNodePort = false
1380+
} else if port.Protocol == "UDP" {
1381+
// Older Octavia versions doesn't support HTTP monitors on UDP pools. If we have one like that, we got
1382+
// to rely on checking the NodePort instead.
1383+
useHealthCheckNodePort = openstackutil.IsOctaviaFeatureSupported(lbaas.lb, openstackutil.OctaviaFeatureHTTPMonitorsOnUDP, lbaas.opts.LBProvider)
1384+
}
1385+
if useHealthCheckNodePort {
1386+
member.MonitorPort = &svcConf.healthCheckNodePort
1387+
}
13651388
}
13661389
members = append(members, member)
13671390
newMembers.Insert(fmt.Sprintf("%s-%s-%d-%d", node.Name, addr, member.ProtocolPort, svcConf.healthCheckNodePort))

pkg/util/openstack/loadbalancer.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const (
4242
OctaviaFeatureFlavors = 2
4343
OctaviaFeatureTimeout = 3
4444
OctaviaFeatureAvailabilityZones = 4
45+
OctaviaFeatureHTTPMonitorsOnUDP = 5
4546

4647
waitLoadbalancerInitDelay = 1 * time.Second
4748
waitLoadbalancerFactor = 1.2
@@ -143,6 +144,14 @@ func IsOctaviaFeatureSupported(client *gophercloud.ServiceClient, feature int, l
143144
if currentVer.GreaterThanOrEqual(verAvailabilityZones) {
144145
return true
145146
}
147+
case OctaviaFeatureHTTPMonitorsOnUDP:
148+
if lbProvider == "ovn" {
149+
return false
150+
}
151+
verHTTPMonitorsOnUDP, _ := version.NewVersion("v2.16")
152+
if currentVer.GreaterThanOrEqual(verHTTPMonitorsOnUDP) {
153+
return true
154+
}
146155
default:
147156
klog.Warningf("Feature %d not recognized", feature)
148157
}

0 commit comments

Comments
 (0)