-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 basic container healthcheck #2625
Conversation
Nice! Didn‘t know Compose has now received this feature as well. How does Compose handle the check though? Is it only executed once? Is there some initial timeout? I have set up checks as well (though for Kubernetes) that I will share later today here as well so we can have a look as well (for the future, as a point of reference, not necessarily for this PR). |
The check is run first after $START_PERIOD, then every $INTERVAL. These are the default values:
For more information see the docs 😉 |
Alright, I see. Here are my probes: livenessProbe:
exec:
command:
- /bin/bash
- -c
- supervisorctl status postfix | grep -q 'RUNNING'
initialDelaySeconds: 0
periodSeconds: 300
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
readinessProbe:
exec:
command:
- /bin/bash
- -c
- supervisorctl status postfix | grep -q 'RUNNING'
initialDelaySeconds: 15
periodSeconds: 300
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
startupProbe:
exec:
command: [/bin/bash, /tmp/docker-mailserver/startup_probe.sh]
initialDelaySeconds: 15
periodSeconds: 5
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 5 I admit I like the usage of the I would, however, really like to see the "long" options for |
For the future, I have devised a more elaborate script we could put in the docs for those that want to do more elaborate health checks: #! /bin/bash
set -eEu -o pipefail
shopt -s inherit_errexit
if ! supervisorctl status postfix | grep -q 'RUNNING'
then
printf 'Postfix is not running\n' >/tmp/dms/lr-probe.error-cause.txt
exit 1
fi
STATUS_FILE='/tmp/dms/lr-probe.ss-current-state.txt'
ss --tcp --ipv4 --listening --numeric >"${STATUS_FILE}"
GREP_PATTENS=(
'0\.0\.0\.0:25' # Postfix transfer
'0\.0\.0\.0:143' # Dovecot IMAP
'0\.0\.0\.0:465' # Postfix ESMTP explicit
'0\.0\.0\.0:587' # Postfix ESMTP implicit
'0\.0\.0\.0:993' # Dovecot IMAPS
'127\.0\.0\.1:8891' # OpenDKIM
'127\.0\.0\.1:8893' # OpenDMARC
'127\.0\.0\.1:10023' # Postgrey
'127\.0\.0\.1:10024' # Amavis
)
for PATTERN in "${GREP_PATTENS[@]}"
do
if ! grep -qE "LISTEN.*${PATTERN}" "${STATUS_FILE}"
then
printf "Pattern '%s' was not found\n" "${PATTERN}" \
>/tmp/dms.lr-probe.error-cause.txt
exit 2
fi
done
|
Why not making it future proof and remove I started with something similar, but decided to go without |
This script is for my setup only, we'd need to adjust the script shown above anyway :) |
@polarathene The check-for-changes test is failing. I doubt, this is due to changes of this PR. Also, locally the tests pass. Any idea? |
I'll look over this PR and discussion after I've had some rest, it's late here 😅
Were you referring to this one?
I didn't see any other test failures in the log. This one was the |
Edit: I just resolved the conflicts with your PTRACE commit. Tests are running again now. Let's see what happens 😎 |
Looks like a good addition to docs 👍 |
Description
This PR adds a basic healthcheck for DMS. The container is considered healthy, when postfix is running and listening on port tcp/25.
Type of change
Checklist:
docs/
)