gliderlabs / registrator

Service registry bridge for Docker with pluggable adapters
http://gliderlabs.com/registrator
MIT License
4.66k stars 912 forks source link

SERVICE_CHECK_SCRIPT doesn't work for consul > 1.1.0 #637

Open MAS150MD200 opened 6 years ago

MAS150MD200 commented 6 years ago

Description of the problem: Registrator unable to register consul health check type: script for consul versions > 1.1.0

How reproducible: Try to register the following health check SERVICE_CHECK_SCRIPT=curl --silent --fail example1.com for consul > 1.1.0 The same configuration works for consul 0.9.3.

Actual Results: Health check isn't registered.

Expected Results: Health check should be registered in Consul.

gr4per commented 6 years ago

+1 suffering from the same issue

boarder981 commented 6 years ago

Same exact issue for me. Upgraded from Consul 1.0.0 to 1.1.0 and it totally broke my script checks.

bitsofinfo commented 6 years ago

Same issue here. Given the last registrator released was 2016, i highly doubt this will be fixed.

peteguyatt commented 6 years ago

We encountered this issue too when upgrading - our CHECK_SCRIPT was curl a command to hit the actuator health endpoint in a spring boot application. We worked around this issue by using the CHECK_HTTP/S instead. I know this won't resolve the exact issue described above but I thought I would mention there is a potential workaround (depending on your use case) for others bitten by this issue

josegonzalez commented 6 years ago

Try the master tag of registrator.

peteguyatt commented 6 years ago

@josegonzalez I tried switching using the master image when I first encountered this issue without any luck. I'm not at all familiar with go but from looking at consul.go it looks like the issue is in the buildCheck function - from looking at the payload example in the consul docs it looks like TTL is now mandatory, however that is not set if you specify check_script, chk_cmd, check_http or check_https.

Would a simple fix be to add something similar to the block of code that adds the interval/DefaultInterval? I'm happy to do a PR, thoughts?

josegonzalez commented 6 years ago

Sure, that works for us.

jhsolor commented 6 years ago

I'm working on a PR for this, the consul API removed this command. It's also gone from the current Consul Go client.

See https://github.com/hashicorp/consul/commit/b73323aa429f6edcfdff3b951774ca6f296f2bc5 for the relevant commit on Consul v1.1.0.

jhsolor commented 6 years ago

PR https://github.com/gliderlabs/registrator/pull/643 submitted.

egeexyz commented 5 years ago

Bumping this issue - I'm seeing the same issue. I've got a standard ECS setup - Consul, Fabio, Registrator. We upgraded our Consul server and our Agents and now we're seeing this error.

I switched to the master branch but it had no effect - the error persists.

engel75 commented 3 years ago

Same error message with consul 1.9.3

/etc/consul/consul.d/service_somename.json

{
    "service": {
        "name": "somename",
        "id": "someid",
        "port": 12346,
        "address": "",
        "meta": {"metakey": "metavalue", "metaotherkey": "othermetavalue"},
        "check": [{"id": "true-id-check", "name": "true", "args": ["/bin/true"], "interval": "10s", "timeout": "2s"}],
        "weights": {"passing": 10, "warning": 1},
        "tags": ["primary"]
    }
}

trying to register that service

root@xxxxxxxxx:~# consul services register /etc/consul/consul.d/service_somename.json
Error registering service "somename": Unexpected response code: 400 (Invalid check: TTL must be > 0 for TTL checks)
root@xxxxxxxxx:~# consul -v
Consul v1.9.3
Revision f55da9306
FedorPRO commented 3 years ago

Same error message with consul 1.9.5

...
    "checks": [
      {
        "id":       "HAProxy",
        "name":     "HAProxy TCP on port 80",
        "tcp":      "127.0.0.1:80",
        "interval": "10s",
        "timeout":  "1s"
      },
      {
        "id":       "NGINX",
        "name":     "NGINX TCP on port 8081",
        "tcp":      "127.0.0.1:8081",
        "interval": "10s",
        "timeout":  "1s"
      },
      {
        "args":     ["sh", "/opt/checkit.sh"],
        "interval": "15s",
        "timeout": "20s"
      }
    ]
...
# consul services register /etc/consul.d/app-01.json
Error registering service "web-app-01": Unexpected response code: 400 (Invalid check: TTL must be > 0 for TTL checks)
# curl -i -X PUT --data @/etc/consul.d/app-01.json http://127.0.0.1:8500/v1/agent/service/register
HTTP/1.1 400 Bad Request
Vary: Accept-Encoding
X-Consul-Default-Acl-Policy: allow
Date: Thu, 02 Sep 2021 17:17:07 GMT
Content-Length: 52
Content-Type: text/plain; charset=utf-8

Consul v1.9.5 Revision 3c1c22679