Skip to content

fix(traefik): Convert Traefik configuration errors to warnings instead of failures - #7967

Merged
rfay merged 12 commits into
mainfrom
copilot/consider-dialing-back-errors
Dec 27, 2025
Merged

rfay merged 12 commits into
mainfrom
copilot/consider-dialing-back-errors

Conversation

Copilot AI commented Dec 21, 2025 •

Copy link
Copy Markdown
Contributor

The Issue

PR #7442 introduced healthcheck validation that detects Traefik configuration errors and missing file-based routers. While this provides valuable visibility, it causes project startup failures when these errors exist, even though projects previously worked fine with these issues present.

Users reported that after updating DDEV, they couldn't start projects that previously started successfully. The strict healthcheck was failing due to:

  • Invalid docker-compose.*.yaml configurations
  • Misconfigured .ddev/traefik/config/*.yaml files
  • Missing entrypoints in custom Traefik configurations

How This PR Solves The Issue

This PR converts Traefik configuration errors from failures to warnings, allowing projects to start successfully while still providing visibility into configuration issues.

Changes made:

  1. Modified containers/ddev-traefik-router/traefik_healthcheck.sh:

    • Returns exit code 0 (healthy) for configuration errors and missing file-based routers
    • Outputs warning messages with "WARNING:" prefix
    • Still fails (non-zero exit) only if the basic Traefik ping endpoint is unreachable
  2. Added containers/ddev-traefik-router/monitor-traefik-stderr.sh:

    • Monitors Traefik stderr output and captures ERR messages
    • Writes errors to /tmp/ddev-traefik-errors.txt for later retrieval
  3. Updated containers/ddev-traefik-router/Dockerfile:

    • Adds the monitoring script to the container
    • Uses the script as entrypoint to wrap Traefik execution
  4. Enhanced pkg/ddevapp/router.go:

    • Added GetRouterConfigErrors() function to read captured error messages
    • Modified RenderRouterStatus() to display configuration errors even when router is healthy
    • Shows detailed error messages in ddev list and ddev describe output
  5. Updated docs/content/users/extend/traefik-router.md:

    • Added section explaining "Warning: There are router configuration problems"
    • Documents common causes and how to troubleshoot
  6. Updated pkg/versionconstants/versionconstants.go:

    • Bumped TraefikRouterTag to reflect new container image

Manual Testing Instructions

  1. Test with broken Traefik config:

    Create a test project:

    mkdir test-traefik && cd test-traefik
    ddev config --project-type=php

    Add invalid Traefik configuration with non-existent entrypoint:

    mkdir -p .ddev/traefik/config
    cat > .ddev/traefik/config/x.yaml << 'EOF'
    http:
      routers:
        x-web-80-http:
          entrypoints:
            - http-81
          rule: HostRegexp(`^d11\.ddev\.site$`)
    EOF

    Start and verify behavior:

    ddev restart

    Expected result: Project starts successfully (does not fail)

    Check status:

    ddev list

    Expected result: Router shows as "OK" with warning message about configuration errors

    ddev describe

    Expected result: Shows router status with configuration error details

    Check logs:

    docker logs ddev-router 2>&1 | grep ERR

    Expected result: Shows Traefik error about non-existent entrypoint http-81

  2. Test normal project without errors:

    Remove the broken config:

    rm .ddev/traefik/config/x.yaml
    ddev restart

    Expected result: Project starts normally, no warnings displayed

  3. Verify documentation:

    Review the updated documentation at docs/content/users/extend/traefik-router.md which now includes a section on "Warning: There are router configuration problems"

Automated Testing Overview

  • Go code compiles successfully
  • Existing router tests continue to pass
  • Container healthcheck still validates basic Traefik ping endpoint
  • New monitoring script captures errors without affecting router startup

No new automated tests were added as this primarily changes runtime behavior of the container healthcheck script and error reporting. The functionality is best validated through manual integration testing with actual Traefik configurations.

Release/Deployment Notes

Container Image Update: This PR includes changes to ddev-traefik-router container. A new image has been built and pushed with tag updated in pkg/versionconstants/versionconstants.go.

Behavior Changes:

  • Projects will now start successfully even with Traefik configuration errors
  • Users will see warnings in ddev list and ddev describe output when configuration issues exist
  • Detailed error messages are available via docker logs ddev-router
  • This is a non-breaking change that improves user experience while maintaining visibility into configuration issues

Documentation: Updated Traefik router documentation to explain the warning messages and how to troubleshoot them.

Original prompt

This section details on the original issue you should resolve

<issue_title>Consider dialing back response to traefik configuration errors</issue_title>
<issue_description>### Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem?

We recently started checking for errors from traefik, and it's a good idea. It gives us visibility into traefik behavior that we wouldn't have otherwise. The key change was in

However, a fair number of people have updated DDEV and found that they couldn't start projects which previously started OK, so the errors we were detecting weren't previously causing them pain.

Examples include these and some others in Discord:

Describe your solution

We definitely want visibility into these problems, but let's consider not failing when encountering them, instead provide the information as a warning.

For extra credit, we can get Traefik to tell us what's actually going on (which is in fact in traefik logs) so we can report that.

Describe alternatives

No response

Additional context

No response</issue_description>

<agent_instructions>Changes to containers/ddev-traefik-router will require a new image to be pushed and referenced in versionconstants.go, so remember to ask for that push if you make that change.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Consider dialing back response to traefik configuration errors Convert Traefik configuration errors to warnings instead of failures Dec 21, 2025
Copilot AI requested a review from rfay December 21, 2025 21:01
@rfay rfay changed the title Convert Traefik configuration errors to warnings instead of failures fix(traefik): Convert Traefik configuration errors to warnings instead of failures Dec 21, 2025
@github-actions github-actions Bot added bugfix dependencies Pull requests that update a dependency file labels Dec 21, 2025
@github-actions

github-actions Bot commented Dec 21, 2025 •

Copy link
Copy Markdown

@rfay
rfay force-pushed the copilot/consider-dialing-back-errors branch 2 times, most recently from 9ed58f9 to b79feda Compare December 24, 2025 17:13
@rfay

rfay commented Dec 24, 2025

Copy link
Copy Markdown
Member

@copilot the OP here should be done in the format of .github/PULL_REQUEST_TEMPLATE.md.

Update the OP to reflect the current status of the PR.

Manual testing should include adding a project .ddev/traefik/config/x.yaml with this:

http:
  routers:
    x-web-80-http:
      entrypoints:
        - http-81
      rule: HostRegexp(`^d11\.ddev\.site$`)

and doing ddev restart, ddev list, ddev describe and seeing the resultant output.

Also reviewing the updated doc

Copilot AI commented Dec 24, 2025

Copy link
Copy Markdown
Contributor Author

@copilot the OP here should be done in the format of .github/PULL_REQUEST_TEMPLATE.md.

Update the OP to reflect the current status of the PR.
...

Updated the PR description to follow the template format in commit e9b43e1. The description now includes:

The manual testing section includes step-by-step instructions to:

  1. Create a project with the broken Traefik config (http-81 entrypoint)
  2. Verify the project starts successfully with warnings
  3. Check that ddev list and ddev describe show configuration errors
  4. Verify error details are available in docker logs ddev-router
  5. Test normal operation after removing the broken config

Copilot AI and others added 8 commits December 24, 2025 11:34
- Modified traefik_healthcheck.sh to return success (exit 0) for configuration errors
- Added WARNING prefix to error messages to make them warnings
- Updated router status display to show warnings even when router is healthy
- Users are directed to 'docker logs ddev-router' for detailed error information

Co-authored-by: rfay <[email protected]>
@rfay
rfay force-pushed the copilot/consider-dialing-back-errors branch from e9b43e1 to 270c067 Compare December 24, 2025 18:34

@rfay rfay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be OK, but it took a lot of effort to get green tests, and it wasn't clear why.

@rfay
rfay marked this pull request as ready for review December 26, 2025 14:55
@rfay
rfay requested review from a team as code owners December 26, 2025 14:55
@rfay
rfay requested a review from stasadev December 26, 2025 14:55

@stasadev stasadev left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome improvement, which doesn't break ddev start !

Looks good to me with a small suggestion:


We need to add a link to troubleshooting docs, for example, when I break the ddev-router on Linux, users may not understand what to do with this warning:

# temporary set to 10 (it's reset automatically after reboot)
$ ddev poweroff
$ sudo sysctl -w fs.inotify.max_user_watches=10

$ ddev start
...
Warning: There are router configuration problems:
2025-12-26T20:09:12+02:00 ERR Cannot start the provider *file.Provider error="error adding file watcher: no space left on device"
Successfully started l12
...

# revert back without reboot
$ ddev poweroff
$ sudo sysctl -w fs.inotify.max_user_watches=524288

P.S. I don't know how I ended up with a broken cert from 2024, but this PR helped me realize that I have a problem with an empty default_cert.crt on my end:

$ ddev start
...
Starting ddev-router if necessary... 
 Container ddev-router  Created 
 Container ddev-router  Started 
Warning: There are router configuration problems:
2025-12-26T19:41:27+02:00 ERR Error while creating certificate store error="failed to load X509 key pair: tls: failed to find any PEM data in certificate input" tlsStoreName=default
2025-12-26T19:41:27+02:00 ERR Error while creating certificate store error="failed to load X509 key pair: tls: failed to find any PEM data in certificate input" tlsStoreName=default
...

$ ls -la ~/.ddev/traefik/certs 
total 12
drwxr-xr-x 2 stas stas 4096 Jun 26  2024 .
drwxr-xr-x 4 stas stas 4096 Jul 10 17:59 ..
-rw-r--r-- 1 stas stas    0 Nov 21  2024 default_cert.crt
-rw------- 1 stas stas 1704 Nov 21  2024 default_key.key

I remember seeing this error a long time ago, and googling it didn't help much. I finally fixed it by rm -r ~/.ddev/traefik.

Comment thread pkg/ddevapp/router.go Resolved
@rfay

rfay commented Dec 27, 2025

Copy link
Copy Markdown
Member

Here's the reason the empty default_cert.crt was ignored @stasadev :

ddev/pkg/ddevapp/traefik.go

Lines 137 to 149 in 5b6c8ff

for _, pemFile := range []string{"default_cert.crt", "default_key.key"} {
origFile := filepath.Join(sourceCertsPath, pemFile)
if fileutil.FileExists(origFile) {
// Check to see if file has #ddev-generated in it, meaning we can recreate it.
sigExists, err = fileutil.FgrepStringInFile(origFile, nodeps.DdevFileSignature)
if err != nil {
return err
}
// If either of the files has #ddev-generated, we will respect both
if !sigExists {
break
}
}

"// If either of the files has #ddev-generated, we will respect both"

I wonder why.

rfay and others added 2 commits December 27, 2025 08:55
Empty default_cert.crt files were being left in place instead of being
regenerated, causing traefik startup errors. Now applies the same pattern
from fileutil/embed.go to replace files that are empty or have #ddev-generated.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@rfay

rfay commented Dec 27, 2025

Copy link
Copy Markdown
Member

I fixed that inline and will now (finally) do a PR that standardizes that check.

@rfay
rfay merged commit 0a844d4 into main Dec 27, 2025
@rfay
rfay deleted the copilot/consider-dialing-back-errors branch December 27, 2025 22:33
rfay added a commit that referenced this pull request Dec 28, 2025
Fixes broken merge from PR #7967 conflict. The script now:
- Calculates expected router count from config files (yq)
- Verifies actual loaded routers match expected count
- Uses per_page=10000 to handle >100 routers
- Reports mismatches as WARNING but still returns healthy (exit 0)

This maintains the philosophy from #7967: detect and report router
issues but do not inconvenience users by refusing to run.

Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 <[email protected]>
rfay added a commit that referenced this pull request Dec 31, 2025
Fixes broken merge from PR #7967 conflict. The script now:
- Calculates expected router count from config files (yq)
- Verifies actual loaded routers match expected count
- Uses per_page=10000 to handle >100 routers
- Reports mismatches as WARNING but still returns healthy (exit 0)

This maintains the philosophy from #7967: detect and report router
issues but do not inconvenience users by refusing to run.

Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider dialing back response to traefik configuration errors

3 participants