Skip to content

Commit 1f93335

Browse files
Differentiate liveness and readiness probes for router pods
Add a backend to the router controller "/livez" that always returns true. This differentiates the liveness and readiness probes so that a router can be alive and not ready. Bug 1550007
1 parent ceac27f commit 1f93335

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

pkg/oc/admin/router/router.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ func generateSecretsConfig(cfg *RouterConfig, namespace string, defaultCert []by
436436
return secrets, volumes, mounts, nil
437437
}
438438

439-
func generateProbeConfigForRouter(cfg *RouterConfig, ports []kapi.ContainerPort) *kapi.Probe {
439+
func generateProbeConfigForRouter(path string, cfg *RouterConfig, ports []kapi.ContainerPort) *kapi.Probe {
440440
var probe *kapi.Probe
441441

442442
if cfg.Type == "haproxy-router" {
@@ -447,7 +447,7 @@ func generateProbeConfigForRouter(cfg *RouterConfig, ports []kapi.ContainerPort)
447447
}
448448

449449
probe.Handler.HTTPGet = &kapi.HTTPGetAction{
450-
Path: "/healthz",
450+
Path: path,
451451
Port: intstr.IntOrString{
452452
Type: intstr.Int,
453453
IntVal: int32(healthzPort),
@@ -466,15 +466,15 @@ func generateProbeConfigForRouter(cfg *RouterConfig, ports []kapi.ContainerPort)
466466
}
467467

468468
func generateLivenessProbeConfig(cfg *RouterConfig, ports []kapi.ContainerPort) *kapi.Probe {
469-
probe := generateProbeConfigForRouter(cfg, ports)
469+
probe := generateProbeConfigForRouter("/livez", cfg, ports)
470470
if probe != nil {
471471
probe.InitialDelaySeconds = 10
472472
}
473473
return probe
474474
}
475475

476476
func generateReadinessProbeConfig(cfg *RouterConfig, ports []kapi.ContainerPort) *kapi.Probe {
477-
probe := generateProbeConfigForRouter(cfg, ports)
477+
probe := generateProbeConfigForRouter("/healthz", cfg, ports)
478478
if probe != nil {
479479
probe.InitialDelaySeconds = 10
480480
}

pkg/router/metrics/metrics.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ type Listener struct {
3737
func (l Listener) handler() http.Handler {
3838
mux := http.NewServeMux()
3939
healthz.InstallHandler(mux, l.Checks...)
40+
mux.Handle("/livez", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
41+
fmt.Fprintf(w, "ok")
42+
return
43+
}))
4044

4145
if l.Authenticator != nil {
4246
protected := http.NewServeMux()

0 commit comments

Comments
 (0)