Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(ci): say why a container is missing when the wait times out (#102923)

Georges-Antoine Assi8fd72bfcc053
diff --git a/bin/wait-for-docker b/bin/wait-for-docker
index 8f8dd535b6ce..3e2a1d083a4f 100755
--- a/bin/wait-for-docker
+++ b/bin/wait-for-docker
@@ -151,6 +151,25 @@ print_service_diagnostics() {
echo "=========================================="
}
+# A container reported as missing has three causes that the per-service report
+# cannot tell apart: the stack never started, it started and went away, or it
+# runs under a project name this script is not watching. One listing of every
+# container on the host answers all three. It is per-host rather than per
+# service, so it prints once however many services timed out.
+print_host_diagnostics() {
+ local containers
+ containers="$(docker ps -a --format ' {{.Label "com.docker.compose.project"}}/{{.Label "com.docker.compose.service"}} ({{.Status}})' 2>&1 | sort)"
+ echo ""
+ echo "=========================================="
+ echo "Containers on this host, as project/service. This script watches project '${PROJECT}':"
+ if [ -n "$containers" ]; then
+ echo "$containers"
+ else
+ echo " (none)"
+ fi
+ echo "=========================================="
+}
+
POLL_ERR_FILE="$(mktemp "${TMPDIR:-/tmp}/wait-for-docker-err.XXXXXX")"
trap 'rm -f "$POLL_ERR_FILE"' EXIT
@@ -267,10 +286,17 @@ while [ ${#pending[@]} -gt 0 ]; do
done
if [ ${#timed_out[@]} -gt 0 ]; then
+ missing_any=0
for entry in "${timed_out[@]}"; do
IFS='|' read -r svc status container_id <<< "$entry"
print_service_diagnostics "$svc" "$SECONDS" "$status" "$container_id"
+ if [ -z "$container_id" ]; then
+ missing_any=1
+ fi
done
+ if [ "$missing_any" -eq 1 ]; then
+ print_host_diagnostics
+ fi
exit 1
fi