Add log when missing path in health check

This commit is contained in:
Maxence Moutoussamy 2022-06-20 15:40:13 +02:00 committed by GitHub
parent 5c15f5fe04
commit 23340c46e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 9 deletions

View file

@ -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: Below are the available options for the health check mechanism:
- `path` is appended to the server URL to set the health check endpoint. - `path` (required), defines the server URL path for the health check endpoint .
- `scheme`, if defined, will replace the server URL `scheme` for the health check endpoint - `scheme` (optional), replaces the server URL `scheme` for the health check endpoint.
- `hostname`, if defined, will apply `Host` header `hostname` to the health check request. - `hostname` (optional), sets the value of `hostname` in the `Host` header of the health check request.
- `port`, if defined, will replace the server URL `port` for the health check endpoint. - `port` (optional), replaces the server URL `port` for the health check endpoint.
- `interval` defines the frequency of the health check calls. - `interval` (default: 30s), 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). - `timeout` (default: 5s), defines the maximum duration Traefik will wait for a health check request before considering the server unhealthy.
- `headers` defines custom headers to be sent to the health check endpoint. - `headers` (optional), 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). - `followRedirects` (default: true), defines whether redirects should be followed during the health check calls.
!!! info "Interval & Timeout Format" !!! info "Interval & Timeout Format"

View file

@ -311,12 +311,17 @@ func (m *Manager) LaunchHealthCheck() {
} }
func buildHealthCheckOptions(ctx context.Context, lb healthcheck.Balancer, backend string, hc *dynamic.ServerHealthCheck) *healthcheck.Options { 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 return nil
} }
logger := log.FromContext(ctx) logger := log.FromContext(ctx)
if hc.Path == "" {
logger.Errorf("Ignoring heath check configuration for '%s': no path provided", backend)
return nil
}
interval := defaultHealthCheckInterval interval := defaultHealthCheckInterval
if hc.Interval != "" { if hc.Interval != "" {
intervalOverride, err := time.ParseDuration(hc.Interval) intervalOverride, err := time.ParseDuration(hc.Interval)