dokku / docker-container-healthchecker

Runs healthchecks against local docker containers
BSD 3-Clause "New" or "Revised" License
16 stars 4 forks source link

Fix Failure in name='port listening check' #151

Closed ashmckenzie closed 9 months ago

ashmckenzie commented 9 months ago

This PR aims to fix a failure I was seeing when deploying my app with the following JSON:

{
  "description": "Checks My App Health",
  "env": {},
  "healthchecks": {
    "web": [
      {
        "attempts": 3,
        "path": "/health",
        "type": "startup"
      },
      {
        "listening": true,
        "name": "port listening check",
        "port": 5000,
        "type": "startup",
        "warn": true
      }
    ]
  },
  "name": "my-app-checker",
  "repository": "xxx",
  "scripts": {
    "dokku": {
      "postdeploy": "touch /app/postdeploy.test",
      "predeploy": "touch /app/predeploy.test"
    }
  }
}

Before

dokku@dokku:/tmp$ sudo /usr/bin/docker-container-healthchecker check 4f6b67ea1581dff4b441aa43dafb51dcc84993dbcfc9b482e7d7f51dc0328cca
-----> Executing 2 healthchecks
       Running healthcheck name='port listening check' attempts=3 port=5000 retries=2 timeout=5 type='listening' wait=5
       Running healthcheck name='eyJhdHRlbXB0cyI6MywicGF0aCI6Ii9oZWFsdGgiLCJwb3J0Ijo1MDAwLCJ0eXBlIjoic3RhcnR1cCJ9' delay=0 path='/health' retries=2 timeout=5 type='path'
       Healthcheck succeeded name='eyJhdHRlbXB0cyI6MywicGF0aCI6Ii9oZWFsdGgiLCJwb3J0Ijo1MDAwLCJ0eXBlIjoic3RhcnR1cCJ9'
 !     Failure in name='port listening check': container listening on expected port (5000) with unexpected IPv6 interface: expected=:: actual=::

After

Running a compiled docker-container-healthchecker from this branch:

dokku@dokku:/tmp$ sudo /home/ash/tmp/docker-container-healthchecker/build/linux/docker-container-healthchecker-amd64 check 4f6b67ea1581dff4b441aa43dafb51dcc84993dbcfc9b482e7d7f51dc0328cca
-----> Executing 2 healthchecks
       Running healthcheck name='eyJhdHRlbXB0cyI6MywicGF0aCI6Ii9oZWFsdGgiLCJwb3J0Ijo1MDAwLCJ0eXBlIjoic3RhcnR1cCJ9' delay=0 path='/health' retries=2 timeout=5 type='path'
       Running healthcheck name='port listening check' attempts=3 port=5000 retries=2 timeout=5 type='listening' wait=5
       Healthcheck succeeded name='eyJhdHRlbXB0cyI6MywicGF0aCI6Ii9oZWFsdGgiLCJwb3J0Ijo1MDAwLCJ0eXBlIjoic3RhcnR1cCJ9'
       Healthcheck succeeded name='port listening check'

cc @josegonzalez

josegonzalez commented 9 months ago

Other than the Makefile changes, the PR looks great!

josegonzalez commented 9 months ago

Would be cool to add the golang tests to CI, I don't think its there.

ashmckenzie commented 9 months ago

Would be cool to add the golang tests to CI, I don't think its there.

https://github.com/dokku/docker-container-healthchecker/pull/153 is a WIP PR 🙏