Skip to content

Commit 612dc51

Browse files
committed
Fix of BUG 1405440
Using TCPSocketAction as the liveness probe, which will not be affected by the connection limit set in HAProxy's config file. This is a TRUE fix for BUG 1405440.
1 parent 788e4d1 commit 612dc51

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

pkg/cmd/admin/router/router.go

+30-18
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ const (
236236
// Default stats and healthz port.
237237
defaultStatsPort = 1936
238238
defaultHealthzPort = defaultStatsPort
239+
240+
// Default initial delay for probes are 10 seconds
241+
defaultProbeInitialDelay = 10
239242
)
240243

241244
// NewCmdRouter implements the OpenShift CLI router command.
@@ -402,11 +405,36 @@ func generateSecretsConfig(cfg *RouterConfig, namespace string, defaultCert []by
402405
return secrets, volumes, mounts, nil
403406
}
404407

405-
func generateProbeConfigForRouter(cfg *RouterConfig, ports []kapi.ContainerPort) *kapi.Probe {
408+
func generateLivenessProbeConfig(cfg *RouterConfig, ports []kapi.ContainerPort) *kapi.Probe {
406409
var probe *kapi.Probe
407410

408411
if cfg.Type == "haproxy-router" {
409-
probe = &kapi.Probe{}
412+
probe = &kapi.Probe{InitialDelaySeconds: defaultProbeInitialDelay}
413+
healthzPort := defaultHealthzPort
414+
if cfg.StatsPort > 0 {
415+
healthzPort = cfg.StatsPort
416+
}
417+
418+
// https://bugzilla.redhat.com/show_bug.cgi?id=1405440
419+
// To avoid the failure of HTTP requests due to connection limit in high load scenarios,
420+
// a TCP connection check can be used to check whether the HAProxy process is alive or not.
421+
// This is the most lightweight & cheapest TRUE solution to the BUG.
422+
probe.Handler.TCPSocket = &kapi.TCPSocketAction{
423+
Port: intstr.IntOrString{
424+
Type: intstr.Int,
425+
IntVal: int32(healthzPort),
426+
},
427+
}
428+
}
429+
430+
return probe
431+
}
432+
433+
func generateReadinessProbeConfig(cfg *RouterConfig, ports []kapi.ContainerPort) *kapi.Probe {
434+
var probe *kapi.Probe
435+
436+
if cfg.Type == "haproxy-router" {
437+
probe = &kapi.Probe{InitialDelaySeconds: defaultProbeInitialDelay}
410438
healthzPort := defaultHealthzPort
411439
if cfg.StatsPort > 0 {
412440
healthzPort = cfg.StatsPort
@@ -431,22 +459,6 @@ func generateProbeConfigForRouter(cfg *RouterConfig, ports []kapi.ContainerPort)
431459
return probe
432460
}
433461

434-
func generateLivenessProbeConfig(cfg *RouterConfig, ports []kapi.ContainerPort) *kapi.Probe {
435-
probe := generateProbeConfigForRouter(cfg, ports)
436-
if probe != nil {
437-
probe.InitialDelaySeconds = 10
438-
}
439-
return probe
440-
}
441-
442-
func generateReadinessProbeConfig(cfg *RouterConfig, ports []kapi.ContainerPort) *kapi.Probe {
443-
probe := generateProbeConfigForRouter(cfg, ports)
444-
if probe != nil {
445-
probe.InitialDelaySeconds = 10
446-
}
447-
return probe
448-
}
449-
450462
func generateMetricsExporterContainer(cfg *RouterConfig, env app.Environment) *kapi.Container {
451463
containerName := "metrics-exporter"
452464
if len(cfg.MetricsImage) > 0 {

0 commit comments

Comments
 (0)