-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add healthcheck support for http and smtp #8
add healthcheck support for http and smtp #8
Conversation
5328834
to
d275223
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good addition! Thanks 👍
Can you please check the comments?
d275223
to
ba6893a
Compare
As discussed in #8 (comment)
d89cd1c
to
73d04f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks much better! A couple of comments though.
tests/test_healtcheck.py
Outdated
def _healthcheck(*args, **kwargs): | ||
args = ("-f", "tests/healthcheck.yaml") + args | ||
return docker_compose(*args, **kwargs) | ||
|
||
|
||
def _get_container_id(service_name): | ||
return _healthcheck("ps", "-q", service_name).strip() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if you knew this, but plumbum supports these kind of constructs out of the box (it would be equivalent (except the strip()
part)):
def _healthcheck(*args, **kwargs): | |
args = ("-f", "tests/healthcheck.yaml") + args | |
return docker_compose(*args, **kwargs) | |
def _get_container_id(service_name): | |
return _healthcheck("ps", "-q", service_name).strip() | |
_healthcheck = docker_compose["-f", "tests/healthcheck.yaml"] | |
_get_container_id = _healthcheck["ps", "-q", service_name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_get_container_id = _healthcheck["ps", "-q", service_name]
does not work, because this syntax doesn't support args:
NameError: name 'service_name' is not defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, sorry, my butter fingers. It should be _get_container_id = _healthcheck["ps", "-q"]
instead, and then later called as _get_container_id(service_name).strip()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i changed it to
_healthcheck["ps", "-q"]
2f3bc2f
to
06bfdc2
Compare
06bfdc2
to
f4e232c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Just (another) couple of comments 😄
a54d0e4
to
52f13a3
Compare
I'm checking this now (after a while without seeing here). Is it everything up to date to check? |
52f13a3
to
b04dc30
Compare
I rebased the previous 3 commits, and cherry-picked the improvements we made to our internal version in the last 3 years:
|
bcdaacd
to
f1e7027
Compare
this enables the user to configure a healthcheck for containers that can be used to automatically restart proxies resolving to no longer active ips due to PRE_RESOLVE
this should help if ports are/become firewalled for healthcheck to be able to mark container as unhealthy
e72d53f
to
bc075b6
Compare
when we detect a load balancing dns (responding with different ips on almost every request) we deactivate the resolver healthcheck to not restart those containers all the time
bc075b6
to
4627f26
Compare
@pedrobaeza i think i finally made it work. Not at all sure about the poetry stuff (it was pretty broken on Ubuntu 23.10 and python 3.11) in the end i disabled typed-ast in poetry lock ran |
this enables the user to configure a healthcheck for containers that can
be used to automatically restart proxies resolving to no longer active
ips due to PRE_RESOLVE
Issue description
on our longer running instances we discovered that after a while we couldn't reach proxied services anymore from odoo. we tracked it down to the docker-whitelist configs using
PRE_RESOLVE: 1
for cloud services that are not always using the same ip for deployment (e.g. accounts.google.com) the ip changed after a few weeks while the running proxy still resolved to the old ip which was no longer serving the service.New behaviour
with this change you can configure the required healthcheck for the proxied service type (http/smtp) that now enables docker to check the health of the proxy container. combined with https://github.com/willfarrell/docker-autoheal this enables us to automatically restart those containers no longer resolving to the correct ip.
We tested this for 4 months (and improving it in the meanwhile) on our prod system so it seems a worthy addition for us.
To me it looks like this also could be the foundation for fixing #5 (if the reporter confirms they are also using a target service with changing IP addresses) if we add an SQL healthcheck as well.
info @wt-io-it