marathon-lb health check failing on all spray.io c

2019-04-17 04:25发布

问题:

I'm running DC/OS 1.7 with marathon-lb.

spray.io 1.3.3 is returning 400 to all marathon-lb/HAProxy heath check calls: request has a relative URI and is missing a Host header so marathon-lb never routes any requests to the service.

The health check in the marathon json is:

   "healthChecks": [
     {
       "path": "/health",
       "protocol": "HTTP",
       "portIndex": 0,
       "gracePeriodSeconds": 10,
       "intervalSeconds": 2,
       "timeoutSeconds": 10,
       "maxConsecutiveFailures": 10,
       "ignoreHttp1xx": false
     }   ],

and the logging by spray.io in the docker container is:

[WARN] [08/19/2016 23:53:42.534] [asp-service-akka.actor.default-dispatcher-5] [akka://asp-service/user/IO-HTTP/listener-0/4] Illegal request, responding with status '400 Bad Request': Illegal request: Cannot establish effective request URI of HttpRequest(GET,/health,List(),Empty,HTTP/1.0), request has a relative URI and is missing a Host header

The /health endpoint works fine from curl against the mesos managed ip:port.

I can't find any docs on making HAProxy via marathon-lb more forgiving or suppressing spray.io's 400.

回答1:

from the mesosphere team, sends the hostname in header via the "labels": { section in the marathon json:

    "HAPROXY_0_BACKEND_HTTP_HEALTHCHECK_OPTIONS": "  http-send-name-header Host\n  timeout check {healthCheckTimeoutSeconds}s\n"



回答2:

Please try to add the HAPROXY_BACKEND_HTTP_HEALTHCHECK_OPTIONS label, you can try to replace www with {hostname} in this example: https://github.com/mesosphere/marathon-lb/wiki#custom-http-headers-in-health-check

Additional links:

  1. https://github.com/mesosphere/marathon-lb/blob/master/Longhelp.md#haproxy_backend_http_healthcheck_options
  2. https://cbonte.github.io/haproxy-dconv/1.6/configuration.html#4.2-option%20httpchk