fix: handle multiple nginx-proxy replicas sharing a label - #1275
fix: handle multiple nginx-proxy replicas sharing a label#1275JamBalaya56562 wants to merge 2 commits into
Conversation
cf6d5b0 to
8cdd8ac
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes nginx-proxy/docker-gen detection and reload behavior when the detection label matches multiple containers (e.g., Swarm replicas), preventing newline-separated container IDs from breaking Docker API calls and startup checks (closes #1006).
Changes:
- Update
check_nginx_proxy_container_runto treat the proxy as “up” if any matched replica is running. - Update
reload_nginxto iterate over all matched docker-gen and nginx-proxy container IDs (SIGHUP or all-in-onedocker execpath). - Add an integration test (
nginx_replicas) and wire it into the test suite and CI matrix.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
app/functions.sh |
Iterates over multiple matched container IDs for health checks, reloads, and bundled docker-gen detection. |
app/entrypoint.sh |
Uses the new helper to detect bundled docker-gen across multiple nginx-proxy replicas. |
test/tests/nginx_replicas/run.sh |
Adds an integration test covering separate docker-gen + multiple nginx replicas and multiple all-in-one replicas. |
test/config.sh |
Registers the new nginx_replicas test in the global test list. |
.github/workflows/test.yml |
Adds nginx_replicas to the GitHub Actions matrix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Addressed the Copilot review (grammar fix: "an nginx-proxy container ID"). |
67258b6 to
6781976
Compare
0ec0f15 to
3c6573c
Compare
|
@JamBalaya56562 please flag AI-generated PR explicitly in the PR description (ie "🤖 Generated with Claude Code" like in this PR) and add the AI agent as co-author of the commits. |
3c6573c to
136faef
Compare
|
@buchdag done, added Claude Code as co-author on the commits. The AI-generated flag is already in the PR description. |
136faef to
0291955
Compare
0291955 to
83e3403
Compare
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
83e3403 to
325f2ff
Compare
What
Handle the case where the nginx-proxy (or docker-gen) detection label matches more than one container. Closes #1006.
Why
labeled_cidreturns one container ID per line, so when several nginx replicas share the same label,get_nginx_proxy_containerreturns multiple newline-separated IDs. Code that treated that as a single ID embedded it directly in the Docker API URL and broke: the health check reported... isn't running, the reload reached no replica, and the startup check failed withcan't get docker-gen container idfor multiple all-in-one replicas.How
check_nginx_proxy_container_run: read the IDs into an array; the proxy is considered up if any matched container is running.reload_nginx: iterate over every docker-gen and nginx-proxy ID (SIGHUP, ordocker execfor the all-in-one path).entrypoint.shstartup check: newnginx_proxy_is_docker_genhelper iterates the IDs to detect a bundled docker-gen, instead of passing the whole string tois_docker_gen_container.With a single matching container everything behaves as before (one iteration), so the
docker_api/docker_api_legacytests are unchanged.Test
New
nginx_replicasintegration test covers both paths: (1) separate docker-gen + two labeled nginx replicas — both receiveSIGHUPand the health check passes; (2) two all-in-one nginx-proxy replicas — the companion starts instead of failing the docker-gen check.Verified locally
Two labeled replicas:
get_nginx_proxy_containerreturns 2 IDs, the health check passes,reload_nginxsendsSIGHUPto both, and the companion starts cleanly with two all-in-one replicas (the old single-arg check failed there).Out of scope
docker_restart(LETSENCRYPT_<cid>_RESTART_CONTAINER) targets proxied app containers, not nginx replicas, so it is unaffected.🤖 Generated with Claude Code