From 23340c46e60ebeb05f061c98caa90aaf0ee2c9dd Mon Sep 17 00:00:00 2001 From: Maxence Moutoussamy Date: Mon, 20 Jun 2022 15:40:13 +0200 Subject: [PATCH] Add log when missing path in health check --- docs/content/routing/services/index.md | 16 ++++++++-------- pkg/server/service/service.go | 7 ++++++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/docs/content/routing/services/index.md b/docs/content/routing/services/index.md index 53623e884..98758ad6d 100644 --- a/docs/content/routing/services/index.md +++ b/docs/content/routing/services/index.md @@ -322,14 +322,14 @@ To propagate status changes (e.g. all servers of this service are down) upwards, Below are the available options for the health check mechanism: -- `path` is appended to the server URL to set the health check endpoint. -- `scheme`, if defined, will replace the server URL `scheme` for the health check endpoint -- `hostname`, if defined, will apply `Host` header `hostname` to the health check request. -- `port`, if defined, will replace the server URL `port` for the health check endpoint. -- `interval` defines the frequency of the health check calls. -- `timeout` defines the maximum duration Traefik will wait for a health check request before considering the server failed (unhealthy). -- `headers` defines custom headers to be sent to the health check endpoint. -- `followRedirects` defines whether redirects should be followed during the health check calls (default: true). +- `path` (required), defines the server URL path for the health check endpoint . +- `scheme` (optional), replaces the server URL `scheme` for the health check endpoint. +- `hostname` (optional), sets the value of `hostname` in the `Host` header of the health check request. +- `port` (optional), replaces the server URL `port` for the health check endpoint. +- `interval` (default: 30s), defines the frequency of the health check calls. +- `timeout` (default: 5s), defines the maximum duration Traefik will wait for a health check request before considering the server unhealthy. +- `headers` (optional), defines custom headers to be sent to the health check endpoint. +- `followRedirects` (default: true), defines whether redirects should be followed during the health check calls. !!! info "Interval & Timeout Format" diff --git a/pkg/server/service/service.go b/pkg/server/service/service.go index e2f878594..375e9f64e 100644 --- a/pkg/server/service/service.go +++ b/pkg/server/service/service.go @@ -311,12 +311,17 @@ func (m *Manager) LaunchHealthCheck() { } func buildHealthCheckOptions(ctx context.Context, lb healthcheck.Balancer, backend string, hc *dynamic.ServerHealthCheck) *healthcheck.Options { - if hc == nil || hc.Path == "" { + if hc == nil { return nil } logger := log.FromContext(ctx) + if hc.Path == "" { + logger.Errorf("Ignoring heath check configuration for '%s': no path provided", backend) + return nil + } + interval := defaultHealthCheckInterval if hc.Interval != "" { intervalOverride, err := time.ParseDuration(hc.Interval)