Skip to content

Conversation

@vgeshel
Copy link

@vgeshel vgeshel commented Feb 9, 2016

Adds support for Docker checks as described in Consul docs. This runs the check command inside the container.

I've tested this with Consul 0.6 (note that consul interprets the check command's exit code 0 as success, 1 as warning, 2 as critical):

host$ docker run -it --rm -e SERVICE_NAME=test1 -e SERVICE_CHECK_DOCKER_SCRIPT="test -f /tmp/x || exit 2" -e SERVICE_CHECK_DOCKER_SHELL=/bin/sh -p 10011:1234 alpine sh

host$ consul-cli health-service test1
...
      {
        "Node": "ip-10-234-180-74.ec2.internal",
        "CheckID": "service:ip-10-234-180-74.ec2.internal:grave_noyce:1234",
        "Name": "Service 'test1' check",
        "Status": "critical",
        "Notes": "",
        "Output": "",
        "ServiceID": "ip-10-234-180-74.ec2.internal:grave_noyce:1234",
        "ServiceName": "test1"
      }
...

container# touch /tmp/x

host$ consul-cli health-service test1
...
  {
        "Node": "ip-10-234-180-74.ec2.internal",
        "CheckID": "service:ip-10-234-180-74.ec2.internal:grave_noyce:1234",
        "Name": "Service 'test1' check",
        "Status": "passing",
        "Notes": "",
        "Output": "",
        "ServiceID": "ip-10-234-180-74.ec2.internal:grave_noyce:1234",
        "ServiceName": "test1"
      }
...

host$ dig test1.service.consul SRV
...
;; ANSWER SECTION:
test1.service.consul.   0   IN  SRV 1 1 10011 ip-10-234-180-74.ec2.internal.node.us-east-1.consul.
...
container# rm /tmp/x

host$ dig test1.service.consul SRV
# nothing

host$ consul-cli health-service test1
...
      {
        "Node": "ip-10-234-180-74.ec2.internal",
        "CheckID": "service:ip-10-234-180-74.ec2.internal:grave_noyce:1234",
        "Name": "Service 'test1' check",
        "Status": "critical",
        "Notes": "",
        "Output": "",
        "ServiceID": "ip-10-234-180-74.ec2.internal:grave_noyce:1234",
        "ServiceName": "test1"
      }
...

@vgeshel
Copy link
Author

vgeshel commented Feb 11, 2016

Just realized that #332 does the same thing. Closing as redundant.

@vgeshel vgeshel closed this Feb 11, 2016
This was referenced Jun 25, 2018
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant