From 97ff66556c5255267a7fd900a5bf9f9db289f4de Mon Sep 17 00:00:00 2001 From: Eno Compton Date: Fri, 23 Feb 2018 10:25:09 -0700 Subject: [PATCH] Update install.yaml to use /live for liveness check Also, inline health handler function for consistent style. --- build/install.yaml | 4 ++-- cmd/controller/main.go | 36 +++++++++++++++++------------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/build/install.yaml b/build/install.yaml index f263d258c4..9b80063539 100644 --- a/build/install.yaml +++ b/build/install.yaml @@ -155,7 +155,7 @@ spec: value: "8000" livenessProbe: httpGet: - path: /healthz + path: /live port: 8080 initialDelaySeconds: 3 periodSeconds: 3 @@ -288,4 +288,4 @@ subjects: roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: agones-controller \ No newline at end of file + name: agones-controller diff --git a/cmd/controller/main.go b/cmd/controller/main.go index 76bb9e3e20..b64bf90ad5 100644 --- a/cmd/controller/main.go +++ b/cmd/controller/main.go @@ -141,7 +141,23 @@ func main() { logrus.WithError(err).Fatal("could not run webhook server") } }() - go startHealthCheck(health) + go func() { + logrus.Info("Starting health check...") + srv := &http.Server{ + Addr: ":8080", + Handler: health, + } + defer srv.Close() // nolint: errcheck + + if err := srv.ListenAndServe(); err != nil { + if err == http.ErrServerClosed { + logrus.WithError(err).Info("health check: http server closed") + } else { + err := errors.Wrap(err, "Could not listen on :8080") + runtime.HandleError(logrus.WithError(err), err) + } + } + }() err = c.Run(2, stop) if err != nil { @@ -150,21 +166,3 @@ func main() { logrus.Info("Shut down gameserver controller") } - -func startHealthCheck(h healthcheck.Handler) { - logrus.Info("Starting health check...") - srv := &http.Server{ - Addr: ":8080", - Handler: h, - } - defer srv.Close() // nolint: errcheck - - if err := srv.ListenAndServe(); err != nil { - if err == http.ErrServerClosed { - logrus.WithError(err).Info("health check: http server closed") - } else { - err := errors.Wrap(err, "Could not listen on :8080") - runtime.HandleError(logrus.WithError(err), err) - } - } -}