Skip to content

Commit

Permalink
Differentiate liveness and readiness probes for router pods
Browse files Browse the repository at this point in the history
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
  • Loading branch information
JacobTanenbaum committed Mar 19, 2018
1 parent ceac27f commit 1f93335
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/oc/admin/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ func generateSecretsConfig(cfg *RouterConfig, namespace string, defaultCert []by
return secrets, volumes, mounts, nil
}

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

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

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

func generateLivenessProbeConfig(cfg *RouterConfig, ports []kapi.ContainerPort) *kapi.Probe {
probe := generateProbeConfigForRouter(cfg, ports)
probe := generateProbeConfigForRouter("/livez", cfg, ports)
if probe != nil {
probe.InitialDelaySeconds = 10
}
return probe
}

func generateReadinessProbeConfig(cfg *RouterConfig, ports []kapi.ContainerPort) *kapi.Probe {
probe := generateProbeConfigForRouter(cfg, ports)
probe := generateProbeConfigForRouter("/healthz", cfg, ports)
if probe != nil {
probe.InitialDelaySeconds = 10
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/router/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ type Listener struct {
func (l Listener) handler() http.Handler {
mux := http.NewServeMux()
healthz.InstallHandler(mux, l.Checks...)
mux.Handle("/livez", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "ok")
return
}))

if l.Authenticator != nil {
protected := http.NewServeMux()
Expand Down

0 comments on commit 1f93335

Please sign in to comment.