@@ -236,6 +236,9 @@ const (
236
236
// Default stats and healthz port.
237
237
defaultStatsPort = 1936
238
238
defaultHealthzPort = defaultStatsPort
239
+
240
+ // Default initial delay for probes are 10 seconds
241
+ defaultProbeInitialDelay = 10
239
242
)
240
243
241
244
// NewCmdRouter implements the OpenShift CLI router command.
@@ -402,11 +405,36 @@ func generateSecretsConfig(cfg *RouterConfig, namespace string, defaultCert []by
402
405
return secrets , volumes , mounts , nil
403
406
}
404
407
405
- func generateProbeConfigForRouter (cfg * RouterConfig , ports []kapi.ContainerPort ) * kapi.Probe {
408
+ func generateLivenessProbeConfig (cfg * RouterConfig , ports []kapi.ContainerPort ) * kapi.Probe {
406
409
var probe * kapi.Probe
407
410
408
411
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 }
410
438
healthzPort := defaultHealthzPort
411
439
if cfg .StatsPort > 0 {
412
440
healthzPort = cfg .StatsPort
@@ -431,22 +459,6 @@ func generateProbeConfigForRouter(cfg *RouterConfig, ports []kapi.ContainerPort)
431
459
return probe
432
460
}
433
461
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
-
450
462
func generateMetricsExporterContainer (cfg * RouterConfig , env app.Environment ) * kapi.Container {
451
463
containerName := "metrics-exporter"
452
464
if len (cfg .MetricsImage ) > 0 {
0 commit comments