Repository navigation
fix: exclude paused/stopped projects from router's Traefik configuration - #7961
Conversation
|
Download the artifacts for this pull request:
See Testing a PR. |
24761b0 to
58939bc
Compare
58939bc to
ee36733
Compare
There was a problem hiding this comment.
I think this might be OK. It's actually a hard problem that we have only flirted with occasionally, but I think this current implementation tries hard to be rigorous.
It probably has some kind of impact on the quickstart tests though, https://github.com/ddev/ddev/actions/runs/20415550431/job/58669374644
ee36733 to
d75aa55
Compare
I don't understand why this change breaks quickstarts, maybe when files are deleted and replaced, Docker runs a healthcheck for Traefik in that exact second, causing DDEV to break. |
|
Interesting failure in TestDdevXhprofPrependEnabled , https://github.com/ddev/ddev/actions/runs/20435234341/job/58714849174#step:13:15730 |
abdf337 to
f947238
Compare
869756f to
ff3f022
Compare
|
This is on hold until |
e84a9fb to
98d42fb
Compare
a8e2326 to
d137faa
Compare
|
|
||
| ENV TRAEFIK_MONITOR_PORT=10999 | ||
| RUN apk add --no-cache bash curl htop jq vim yq | ||
| RUN apk add --no-cache bash curl file htop jq openssl vim yq |
There was a problem hiding this comment.
This is optional, and I didn't end up using it, but wanted to use file and openssl to chase problems that turned out to be "not ready" problems.
| # Only retry if: no routers loaded yet AND we expect some AND no errors yet | ||
| if [ "$file_router_count" -eq 0 ] && [ "$expected_router_count" -gt 0 ] && [ "$error_count" -eq 0 ]; then | ||
| # How long to wait (seconds) for Traefik to reflect new file-provider config. | ||
| # This covers both initial startup and later config pushes. |
There was a problem hiding this comment.
This section turned out to be critical to solve problems with the quickstart tests, which (on github) continually push new projects while an existing project is running. Without this, we could end up with the project up and healthy, and the config file pushed into the volume, but traefik not yet having the routers running.
I think it's an important criticism that this healthcheck, even when broken out into functions, is to complex for a bash script to handle properly. Right now I think the build implications of doing it in go would be a bit of trouble, but it may be something we should do anyway. We'd just have to compile the go at image build time, it might not be that bad.
| * `certs/default_cert.*` files are the default DDEV-generated certificates, normally created by `mkcert`. | ||
| * `config/default_config.yaml` contains global *dynamic* configuration, including pointers to the default certificates. It is possible to add other Traefik configuration in the `config` directory, which will apply to all projects. For example, a `config/router_middlewares.yaml` file might provide middleware implementations that would apply to all projects. | ||
| * `config/default_config.yaml` contains global *dynamic* configuration, including pointers to the default certificates. | ||
| * `custom-global-config/` is a directory where you can add custom Traefik dynamic configuration files (such as middleware, routers, or services) that will be automatically included for all projects. Files in this directory are copied to the router's config volume on each `ddev start`. For example, a `custom-global-config/global_middlewares.yaml` file might provide middleware implementations that apply to all projects: |
There was a problem hiding this comment.
This is a BC break. I doubt anybody uses it. But it allows us to have a specific place for custom global configuration of middlewares or whatever.
There was a problem hiding this comment.
Shouldn't we have some example for this in the global ~/.ddev directory, pre-creating ~/.ddev/traefik/custom-global-config with some files like README.md and/or some-file.yaml.example inside?
There was a problem hiding this comment.
Or ~/.ddev/traefik/README.md should be updated with this info.
There was a problem hiding this comment.
Added README and example, thanks.
|
|
||
| // GetContainerHealth retrieves the health status of a given container. | ||
| // returns status, most-recent-log | ||
| // The container is only considered "healthy" if it's also "running", contrary to Docker's normal usage |
There was a problem hiding this comment.
Although this didn't seem to be the primary issue (it was a suspect) we definitely don't want to declare a container "healthy" if its state is not "running".
…al test approach [skip ci]
And use that to copy files from custom-global-files to traefik config Because we only want yaml files copied, not readme, etc.
Co-authored-by: Stanislav Zhuk <[email protected]>
…'t support mods there any more
912be14 to
0a41266
Compare
|
I pushed an adjustment to report extra traefik files or custom project traefik configuration more accurately, |
The Issue
When Docker restarts or the system reboots, DDEV projects end up in a "paused" state (containers exist but are stopped). When starting a new project, the router was incorrectly including Traefik routing configuration from these paused projects. This could cause routing conflicts or confusion as the router would have config for projects that weren't actually running.
How This PR Solves The Issue
Two changes were made:
GetActiveProjects()in utils.go now filters out containers that are not in "running" state, ensuring only truly running projects are returned.PushGlobalTraefikConfig()in traefik.go now:destroyExisting=truewhen copying to the volume, which clears any stale config files from paused/stopped projectsThis ensures the router only has routing configuration for projects that are actually running.
TODO
Manual Testing Instructions
ddev startin two different directories)docker exec ddev-router treesudo systemctl restart dockeror restart Docker Desktop)ddev listddev startin one directorydocker exec ddev-router treeAutomated Testing Overview
No new tests added. The existing test infrastructure doesn't easily support testing Docker restart scenarios. The fix was verified through manual testing.
Release/Deployment Notes
It's unlikely that these features are in use, but the behavior of traefik config is a little tighter as of this PR (actually the changes were in earlier PRs and just caught here:
<projectname>.yamlare supported.🤖 Generated with Claude Code