Repository navigation
fix(router): Prevent unnecessary router re-creation when bound ports unchanged, fixes #6703 - #7992
Conversation
|
@copilot you forgot Then update the OP to use the format in .github/PULL_REQUEST_TEMPLATE.md. You can keep your extensive comments at the bottom. And use the correct format for the PR title: fix(router): ... |
Fixed gofmt issues in commit 5a2a091. Updated PR description to follow the template format. Note: The PR title needs to be updated to |
|
Download the artifacts for this pull request:
See Testing a PR. |
08d1c23 to
f65c560
Compare
|
I looked at the failures of the quickstart, and I think this one needs to wait until the ddev-router healthcheck PRs go in. It also may be that we have to have a special healthcheck check for the router when we are not even starting it. |
d6ce773 to
111e8d3
Compare
rfay
left a comment
There was a problem hiding this comment.
I think this may work. Code looks OK and it's closer all the time to testing successfully.
10c4d22 to
30f1652
Compare
|
That experimental approach did not work. Now trying just removing the special lima port-wait, which is likely the reason that we haven't seen this in other contexts with docker 29. |
637c85e to
c4ff4dd
Compare
stasadev
left a comment
There was a problem hiding this comment.
It seems to fix this issue (without adding any new global config):
Interesting side effect with ephemeral ports:
docker run --rm -p 80:80 -p 443:443 nginx
$ ddev start
Port 80 is busy, using 33000 instead, see https://ddev.com/s/port-conflict
Port 443 is busy, using 33001 instead, see https://ddev.com/s/port-conflict
$ ddev restart
Port 80 is busy, using 33002 instead, see https://ddev.com/s/port-conflict
Port 443 is busy, using 33003 instead, see https://ddev.com/s/port-conflict
$ ddev restart
Port 80 is busy, using 33000 instead, see https://ddev.com/s/port-conflict
Port 443 is busy, using 33001 instead, see https://ddev.com/s/port-conflictSo ddev-router doesn't reuse 33000/33001 for primary router ports, when it's already in use by ddev-router.
When the router is reused (not recreated because ports haven't changed), we now force the healthcheck to run before returning from StartDdevRouter(). This ensures Traefik has loaded the new project's configuration. The fix runs `rm -f /tmp/healthy && /healthcheck.sh` in the router container: - Removes /tmp/healthy so the healthcheck doesn't sleep 59 seconds - Runs the healthcheck which waits for routers to load via wait_for_routers() - Fails StartDdevRouter if the healthcheck fails This fixes intermittent quickstart failures where projects couldn't be accessed because Traefik hadn't loaded their routes yet. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Co-authored-by: Stanislav Zhuk <[email protected]>
ac1b74b to
9ca91b9
Compare
When ports 80/443 are busy, DDEV allocates ephemeral ports (e.g., 33000/33001). Previously, on restart these ports appeared "busy" because the router itself was using them, causing new ports to be allocated and forcing router recreation. Now AllocateAvailablePortForRouter checks if the router already has a port bound and reuses it instead of skipping to the next available port. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
Thanks for noting the no-reuse-of-33000 problem @stasadev - I think I had seen that before, but it's good to get it fixed here, fixed in |
…8110 ## The Issue - Fixes ddev#8110 When starting a second DDEV project with identical port configuration (e.g., both using ddev-adminer on port 9101), the router optimization from PR ddev#7992 prevented recreation because ports matched. However, network aliases in `.router-compose-full.yaml` (required by PR ddev#7642 for inter-container HTTP/S communication) were not updated. This caused the second project's containers to be unable to access their own services via HTTPS, breaking inter-container communication. ## How This PR Solves The Issue This PR extends the router recreation logic to check both ports AND hostnames (network aliases), not just ports: 1. **Added `GetRouterNetworkAliases()`** in `pkg/dockerutil/containers.go` - Extracts network aliases from the running router container's `ddev_default` network configuration, mirroring the pattern of `GetBoundHostPorts()` 2. **Added `HostnamesMatch()`** in `pkg/ddevapp/router.go` - Compares existing vs needed hostnames using subset matching (allows extra hostnames from stopped projects), exactly mirroring `PortsMatch()` logic 3. **Modified `StartDdevRouter()`** in `pkg/ddevapp/router.go` - Now checks both ports and hostnames before deciding to skip recreation. The router is recreated when EITHER ports OR hostnames have changed, while preserving the optimization when neither has changed The fix maintains the performance optimization from PR ddev#7992 (router isn't recreated unnecessarily) while ensuring network aliases are always updated when new projects start. ## Manual Testing Instructions Test the exact reproduction scenario from issue ddev#8110: ```bash # Clean slate ddev poweroff mkdir -p /tmp/pruebas && cd /tmp/pruebas # Start first project with adminer mkdir prueba1 && cd prueba1 ddev config --auto ddev add-on get ddev/ddev-adminer DDEV_DEBUG=true ddev start # Verify works from container ddev exec curl -I https://prueba1.ddev.site:9101 # Should succeed # Start second project with same configuration cd /tmp/pruebas mkdir prueba2 && cd prueba2 ddev config --auto ddev add-on get ddev/ddev-adminer DDEV_DEBUG=true ddev start # Should see: "Router hostnames have changed, will recreate router" ddev exec curl -I https://prueba2.ddev.site:9101 # Should succeed (this would fail without the fix) # Verify both aliases exist in router docker inspect ddev-router --format '{{json .NetworkSettings.Networks.ddev_default.Aliases}}' | jq # Should show both prueba1.ddev.site and prueba2.ddev.site # Verify optimization still works ddev restart # Should see: "Router ports and hostnames have not changed, skipping recreation" ``` ## Automated Testing Overview **New Unit Tests:** - `TestHostnamesMatch()` in `pkg/ddevapp/router_test.go` - 6 test cases verifying hostname comparison logic mirrors `TestPortsMatch()` behavior (empty slices, identical, different order, missing hostname, extra hostnames) - `TestGetRouterNetworkAliases()` in `pkg/dockerutil/containers_test.go` - Verifies alias extraction from containers, error handling **Integration Tests:** - Existing `TestNetworkAliases()` in `pkg/dockerutil/networks_test.go` will verify the fix works end-to-end (can be enhanced with same-port scenario) All tests pass. golangci-lint passes with 0 issues. ## Release/Deployment Notes - **Backward compatible:** No breaking changes, existing behavior preserved - **Performance:** Minimal impact - one additional Docker API call (`ContainerInspect` for network aliases) when router already exists, same O(n+m) complexity as port comparison - **User impact:** Fixes broken inter-container communication for users with multiple projects using identical port configurations (common with add-ons) - **No config changes required:** Fix works automatically on upgrade Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…8110 ## The Issue - Fixes ddev#8110 When starting a second DDEV project with identical port configuration (e.g., both using ddev-adminer on port 9101), the router optimization from PR ddev#7992 prevented recreation because ports matched. However, network aliases in `.router-compose-full.yaml` (required by PR ddev#7642 for inter-container HTTP/S communication) were not updated. This caused the second project's containers to be unable to access their own services via HTTPS, breaking inter-container communication. ## How This PR Solves The Issue This PR extends the router recreation logic to check both ports AND hostnames (network aliases), not just ports: 1. **Added `GetRouterNetworkAliases()`** in `pkg/dockerutil/containers.go` - Extracts network aliases from the running router container's `ddev_default` network configuration, mirroring the pattern of `GetBoundHostPorts()` 2. **Added `HostnamesMatch()`** in `pkg/ddevapp/router.go` - Compares existing vs needed hostnames using subset matching (allows extra hostnames from stopped projects), exactly mirroring `PortsMatch()` logic 3. **Modified `StartDdevRouter()`** in `pkg/ddevapp/router.go` - Now checks both ports and hostnames before deciding to skip recreation. The router is recreated when EITHER ports OR hostnames have changed, while preserving the optimization when neither has changed The fix maintains the performance optimization from PR ddev#7992 (router isn't recreated unnecessarily) while ensuring network aliases are always updated when new projects start. ## Manual Testing Instructions Test the exact reproduction scenario from issue ddev#8110: ```bash # Clean slate ddev poweroff mkdir -p /tmp/pruebas && cd /tmp/pruebas # Start first project with adminer mkdir prueba1 && cd prueba1 ddev config --auto ddev add-on get ddev/ddev-adminer DDEV_DEBUG=true ddev start # Verify works from container ddev exec curl -I https://prueba1.ddev.site:9101 # Should succeed # Start second project with same configuration cd /tmp/pruebas mkdir prueba2 && cd prueba2 ddev config --auto ddev add-on get ddev/ddev-adminer DDEV_DEBUG=true ddev start # Should see: "Router hostnames have changed, will recreate router" ddev exec curl -I https://prueba2.ddev.site:9101 # Should succeed (this would fail without the fix) # Verify both aliases exist in router docker inspect ddev-router --format '{{json .NetworkSettings.Networks.ddev_default.Aliases}}' | jq # Should show both prueba1.ddev.site and prueba2.ddev.site # Verify optimization still works ddev restart # Should see: "Router ports and hostnames have not changed, skipping recreation" ``` ## Automated Testing Overview **New Unit Tests:** - `TestHostnamesMatch()` in `pkg/ddevapp/router_test.go` - 6 test cases verifying hostname comparison logic mirrors `TestPortsMatch()` behavior (empty slices, identical, different order, missing hostname, extra hostnames) - `TestGetRouterNetworkAliases()` in `pkg/dockerutil/containers_test.go` - Verifies alias extraction from containers, error handling **Integration Tests:** - Existing `TestNetworkAliases()` in `pkg/dockerutil/networks_test.go` will verify the fix works end-to-end (can be enhanced with same-port scenario) All tests pass. golangci-lint passes with 0 issues. ## Release/Deployment Notes - **Backward compatible:** No breaking changes, existing behavior preserved - **Performance:** Minimal impact - one additional Docker API call (`ContainerInspect` for network aliases) when router already exists, same O(n+m) complexity as port comparison - **User impact:** Fixes broken inter-container communication for users with multiple projects using identical port configurations (common with add-ons) - **No config changes required:** Fix works automatically on upgrade Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…8110 ## The Issue - Fixes ddev#8110 When starting a second DDEV project with identical port configuration (e.g., both using ddev-adminer on port 9101), the router optimization from PR ddev#7992 prevented recreation because ports matched. However, network aliases in `.router-compose-full.yaml` (required by PR ddev#7642 for inter-container HTTP/S communication) were not updated. This caused the second project's containers to be unable to access their own services via HTTPS, breaking inter-container communication. ## How This PR Solves The Issue This PR extends the router recreation logic to check both ports AND hostnames (network aliases), not just ports: 1. **Added `GetRouterNetworkAliases()`** in `pkg/dockerutil/containers.go` - Extracts network aliases from the running router container's `ddev_default` network configuration, mirroring the pattern of `GetBoundHostPorts()` 2. **Added `HostnamesMatch()`** in `pkg/ddevapp/router.go` - Compares existing vs needed hostnames using subset matching (allows extra hostnames from stopped projects), exactly mirroring `PortsMatch()` logic 3. **Modified `StartDdevRouter()`** in `pkg/ddevapp/router.go` - Now checks both ports and hostnames before deciding to skip recreation. The router is recreated when EITHER ports OR hostnames have changed, while preserving the optimization when neither has changed The fix maintains the performance optimization from PR ddev#7992 (router isn't recreated unnecessarily) while ensuring network aliases are always updated when new projects start. ## Manual Testing Instructions Test the exact reproduction scenario from issue ddev#8110: ```bash # Clean slate ddev poweroff mkdir -p /tmp/pruebas && cd /tmp/pruebas # Start first project with adminer mkdir prueba1 && cd prueba1 ddev config --auto ddev add-on get ddev/ddev-adminer DDEV_DEBUG=true ddev start # Verify works from container ddev exec curl -I https://prueba1.ddev.site:9101 # Should succeed # Start second project with same configuration cd /tmp/pruebas mkdir prueba2 && cd prueba2 ddev config --auto ddev add-on get ddev/ddev-adminer DDEV_DEBUG=true ddev start # Should see: "Router hostnames have changed, will recreate router" ddev exec curl -I https://prueba2.ddev.site:9101 # Should succeed (this would fail without the fix) # Verify both aliases exist in router docker inspect ddev-router --format '{{json .NetworkSettings.Networks.ddev_default.Aliases}}' | jq # Should show both prueba1.ddev.site and prueba2.ddev.site # Verify optimization still works ddev restart # Should see: "Router ports and hostnames have not changed, skipping recreation" ``` ## Automated Testing Overview **New Unit Tests:** - `TestHostnamesMatch()` in `pkg/ddevapp/router_test.go` - 6 test cases verifying hostname comparison logic mirrors `TestPortsMatch()` behavior (empty slices, identical, different order, missing hostname, extra hostnames) - `TestGetRouterNetworkAliases()` in `pkg/dockerutil/containers_test.go` - Verifies alias extraction from containers, error handling **Integration Tests:** - Existing `TestNetworkAliases()` in `pkg/dockerutil/networks_test.go` will verify the fix works end-to-end (can be enhanced with same-port scenario) All tests pass. golangci-lint passes with 0 issues. ## Release/Deployment Notes - **Backward compatible:** No breaking changes, existing behavior preserved - **Performance:** Minimal impact - one additional Docker API call (`ContainerInspect` for network aliases) when router already exists, same O(n+m) complexity as port comparison - **User impact:** Fixes broken inter-container communication for users with multiple projects using identical port configurations (common with add-ons) - **No config changes required:** Fix works automatically on upgrade Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…8110 ## The Issue - Fixes ddev#8110 When starting a second DDEV project with identical port configuration (e.g., both using ddev-adminer on port 9101), the router optimization from PR ddev#7992 prevented recreation because ports matched. However, network aliases in `.router-compose-full.yaml` (required by PR ddev#7642 for inter-container HTTP/S communication) were not updated. This caused the second project's containers to be unable to access their own services via HTTPS, breaking inter-container communication. ## How This PR Solves The Issue This PR extends the router recreation logic to check both ports AND hostnames (network aliases), not just ports: 1. **Added `GetRouterNetworkAliases()`** in `pkg/dockerutil/containers.go` - Extracts network aliases from the running router container's `ddev_default` network configuration, mirroring the pattern of `GetBoundHostPorts()` 2. **Added `HostnamesMatch()`** in `pkg/ddevapp/router.go` - Compares existing vs needed hostnames using subset matching (allows extra hostnames from stopped projects), exactly mirroring `PortsMatch()` logic 3. **Modified `StartDdevRouter()`** in `pkg/ddevapp/router.go` - Now checks both ports and hostnames before deciding to skip recreation. The router is recreated when EITHER ports OR hostnames have changed, while preserving the optimization when neither has changed The fix maintains the performance optimization from PR ddev#7992 (router isn't recreated unnecessarily) while ensuring network aliases are always updated when new projects start. ## Manual Testing Instructions Test the exact reproduction scenario from issue ddev#8110: ```bash # Clean slate ddev poweroff mkdir -p /tmp/pruebas && cd /tmp/pruebas # Start first project with adminer mkdir prueba1 && cd prueba1 ddev config --auto ddev add-on get ddev/ddev-adminer DDEV_DEBUG=true ddev start # Verify works from container ddev exec curl -I https://prueba1.ddev.site:9101 # Should succeed # Start second project with same configuration cd /tmp/pruebas mkdir prueba2 && cd prueba2 ddev config --auto ddev add-on get ddev/ddev-adminer DDEV_DEBUG=true ddev start # Should see: "Router hostnames have changed, will recreate router" ddev exec curl -I https://prueba2.ddev.site:9101 # Should succeed (this would fail without the fix) # Verify both aliases exist in router docker inspect ddev-router --format '{{json .NetworkSettings.Networks.ddev_default.Aliases}}' | jq # Should show both prueba1.ddev.site and prueba2.ddev.site # Verify optimization still works ddev restart # Should see: "Router ports and hostnames have not changed, skipping recreation" ``` ## Automated Testing Overview **New Unit Tests:** - `TestHostnamesMatch()` in `pkg/ddevapp/router_test.go` - 6 test cases verifying hostname comparison logic mirrors `TestPortsMatch()` behavior (empty slices, identical, different order, missing hostname, extra hostnames) - `TestGetRouterNetworkAliases()` in `pkg/dockerutil/containers_test.go` - Verifies alias extraction from containers, error handling **Integration Tests:** - Existing `TestNetworkAliases()` in `pkg/dockerutil/networks_test.go` will verify the fix works end-to-end (can be enhanced with same-port scenario) All tests pass. golangci-lint passes with 0 issues. ## Release/Deployment Notes - **Backward compatible:** No breaking changes, existing behavior preserved - **Performance:** Minimal impact - one additional Docker API call (`ContainerInspect` for network aliases) when router already exists, same O(n+m) complexity as port comparison - **User impact:** Fixes broken inter-container communication for users with multiple projects using identical port configurations (common with add-ons) - **No config changes required:** Fix works automatically on upgrade Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…hand ## Short Summary (TL;DR) The all-project-types job is the only CI job that runs tests with `GOTEST_SHORT` unset, and it ran a hand-kept list that had fallen behind, so 16 tests that skip or shrink under `GOTEST_SHORT` never ran in full anywhere. The list is now generated from the tests themselves, so it can't fall behind again. ## The Issue Found while working on ddev#7904, which changes `TestDebugRebuildCmd`: CI logs show `--- SKIP: TestDebugRebuildCmd` in every job, because Buildkite and `test-reusable.yml` set `GOTEST_SHORT=16` and apache-fpm sets `5`. The list came from ddev#6693 and broke in three ways: - ddev#7027 renamed `TestComposerCreateCmd` to `TestComposerCreateProjectCmd`, so that entry has matched nothing since. - ddev#8028 added `GOTEST_SHORT` skips to `TestDebugRebuildCmd`, `TestDdevImportDB`, `TestDdevRestoreSnapshot`, `TestProcessHooks`, and `TestWebserverMariaMySQLDBClient`, and later PRs did the same for `TestEphemeralPortsReusedOnRestart` (ddev#7992), `TestRouterPortSubstitutionPersistsAcrossProjects` (ddev#8653), `TestSnapshotUncompressed` (ddev#8704), `TestDebugDeleteVolumeCmd` (ddev#8756), and `TestDdevExportDB` (ddev#8798), none of them updating the list. - `TestComposerVersionConfig`, `TestHttpsRedirection`, `TestMysqlCommand`, `TestDdevStartMultipleHostnames`, and `TestProjectAutocompletionForExecCmd` already did less under `GOTEST_SHORT` when ddev#6693 wrote the list, and weren't on it. ## How This PR Solves The Issue Tests use three `testcommon` helpers instead of reading `GOTEST_SHORT`: `SkipIfGotestShort(t)`, `IsGotestShort(t)`, and `UsesAllTestSites(t)`, a marker for tests that loop over every test site. `.github/workflows/all-project-types-tests.sh` finds the tests that call them and prints the `-run` pattern, and fails if a test other than `TestMain` reads `GOTEST_SHORT` itself. The pattern is anchored, so prefix matches such as every `TestCmdStart*` test or `TestAutocompleteServiceForServiceFlag` no longer ride along; like `TestAppdirAlreadyInUse` and `TestConfigValidate`, which also leave the list, they don't depend on `GOTEST_SHORT` and run in every job. The `GOTEST_SHORT` branches that ddev#8028 made unreachable in `TestComposerCreateProjectCmd` and `TestDdevAllDatabases` are removed. ## Manual Testing Instructions ```bash .github/workflows/all-project-types-tests.sh # Expect ^(TestAutocompletionForDescribeCmd|...|TestWriteDrushConfig)\b with the 42 tests below ``` Adding `if os.Getenv("GOTEST_SHORT") != "" { t.Skip() }` to any test makes the script print that file and line and exit non-zero. ## Automated Testing Overview In the all-project-types job, the "Compute TESTARGS" step of `prepare-testargs` should print a `-run '^(...)\b'` pattern with exactly these 42 tests, and the test log should show each of them running, none skipped because of `GOTEST_SHORT`: ```text TestAutocompletionForDescribeCmd TestAutocompletionForStartCmd TestAutocompletionForStopCmd TestAvailableUpdates TestCmdDescribe TestCmdDescribeAppFunction TestCmdDescribeAppUsingSitename TestCmdList TestCmdStart TestCmdStop TestComposerCreateProjectCmd TestComposerVersionConfig TestConfigDatabaseVersion TestDdevAllDatabases TestDdevExportDB TestDdevFullSiteSetup TestDdevImportDB TestDdevImportFiles TestDdevImportFilesCustomUploadDir TestDdevImportFilesDir TestDdevRestoreSnapshot TestDdevStartMultipleHostnames TestDdevUploadDirNoPackage TestDdevXdebugEnabled TestDdevXhprofPrependEnabled TestDdevXhprofXhguiEnabled TestDebugDeleteVolumeCmd TestDebugRebuildCmd TestEphemeralPortsReusedOnRestart TestGetApps TestGetAppsEmpty TestHardenedStart TestHttpsRedirection TestMysqlCommand TestPHPConfig TestPHPWebserverType TestProcessHooks TestProjectAutocompletionForExecCmd TestRouterPortSubstitutionPersistsAcrossProjects TestSnapshotUncompressed TestWebserverMariaMySQLDBClient TestWriteDrushConfig ``` Some of the 16 tests that never ran in full may fail after being skipped this long; this PR's run is where that should show up. 🤖 Developed with assistance from [Claude Code](https://claude.ai/code) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hand ## Short Summary (TL;DR) The all-project-types job is the only CI job that runs tests with `GOTEST_SHORT` unset, and it ran a hand-kept list that had fallen behind, so 16 tests that skip or shrink under `GOTEST_SHORT` never ran in full anywhere. The list is now generated from the tests themselves, so it can't fall behind again. ## The Issue Found while working on ddev#7904, which changes `TestDebugRebuildCmd`: CI logs show `--- SKIP: TestDebugRebuildCmd` in every job, because Buildkite and `test-reusable.yml` set `GOTEST_SHORT=16` and apache-fpm sets `5`. The list came from ddev#6693 and broke in three ways: - ddev#7027 renamed `TestComposerCreateCmd` to `TestComposerCreateProjectCmd`, so that entry has matched nothing since. - ddev#8028 added `GOTEST_SHORT` skips to `TestDebugRebuildCmd`, `TestDdevImportDB`, `TestDdevRestoreSnapshot`, `TestProcessHooks`, and `TestWebserverMariaMySQLDBClient`, and later PRs did the same for `TestEphemeralPortsReusedOnRestart` (ddev#7992), `TestRouterPortSubstitutionPersistsAcrossProjects` (ddev#8653), `TestSnapshotUncompressed` (ddev#8704), `TestDebugDeleteVolumeCmd` (ddev#8756), and `TestDdevExportDB` (ddev#8798), none of them updating the list. - `TestComposerVersionConfig`, `TestHttpsRedirection`, `TestMysqlCommand`, `TestDdevStartMultipleHostnames`, and `TestProjectAutocompletionForExecCmd` already did less under `GOTEST_SHORT` when ddev#6693 wrote the list, and weren't on it. ## How This PR Solves The Issue Tests use three `testcommon` helpers instead of reading `GOTEST_SHORT`: `SkipIfGotestShort(t)`, `IsGotestShort(t)`, and `UsesAllTestSites(t)`, a marker for tests that loop over every test site. `.github/workflows/all-project-types-tests.sh` finds the tests that call them and prints the `-run` pattern, and fails if a test other than `TestMain` reads `GOTEST_SHORT` itself. The pattern is anchored, so prefix matches such as every `TestCmdStart*` test or `TestAutocompleteServiceForServiceFlag` no longer ride along; like `TestAppdirAlreadyInUse` and `TestConfigValidate`, which also leave the list, they don't depend on `GOTEST_SHORT` and run in every job. The `GOTEST_SHORT` branches that ddev#8028 made unreachable in `TestComposerCreateProjectCmd` and `TestDdevAllDatabases` are removed. ## Manual Testing Instructions ```bash .github/workflows/all-project-types-tests.sh # Expect ^(TestAutocompletionForDescribeCmd|...|TestWriteDrushConfig)\b with the 42 tests below ``` Adding `if os.Getenv("GOTEST_SHORT") != "" { t.Skip() }` to any test makes the script print that file and line and exit non-zero. ## Automated Testing Overview In the all-project-types job, the "Compute TESTARGS" step of `prepare-testargs` should print a `-run '^(...)\b'` pattern with exactly these 42 tests, and the test log should show each of them running, none skipped because of `GOTEST_SHORT`: ```text TestAutocompletionForDescribeCmd TestAutocompletionForStartCmd TestAutocompletionForStopCmd TestAvailableUpdates TestCmdDescribe TestCmdDescribeAppFunction TestCmdDescribeAppUsingSitename TestCmdList TestCmdStart TestCmdStop TestComposerCreateProjectCmd TestComposerVersionConfig TestConfigDatabaseVersion TestDdevAllDatabases TestDdevExportDB TestDdevFullSiteSetup TestDdevImportDB TestDdevImportFiles TestDdevImportFilesCustomUploadDir TestDdevImportFilesDir TestDdevRestoreSnapshot TestDdevStartMultipleHostnames TestDdevUploadDirNoPackage TestDdevXdebugEnabled TestDdevXhprofPrependEnabled TestDdevXhprofXhguiEnabled TestDebugDeleteVolumeCmd TestDebugRebuildCmd TestEphemeralPortsReusedOnRestart TestGetApps TestGetAppsEmpty TestHardenedStart TestHttpsRedirection TestMysqlCommand TestPHPConfig TestPHPWebserverType TestProcessHooks TestProjectAutocompletionForExecCmd TestRouterPortSubstitutionPersistsAcrossProjects TestSnapshotUncompressed TestWebserverMariaMySQLDBClient TestWriteDrushConfig ``` Some of the 16 tests that never ran in full may fail after being skipped this long; this PR's run is where that should show up. 🤖 Developed with assistance from [Claude Code](https://claude.ai/code) Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Issue
The router container was being recreated on every project start, even when exposed ports hadn't changed. This caused unnecessary delays and Docker churn, particularly noticeable when starting a third or fourth project.
How This PR Solves The Issue
Modified
StartDdevRouter()to check if the router is already running with the correct port configuration. The router is now only recreated when:Manual Testing Instructions
ddev stop project3ddev start project3DDEV_DEBUG=true ddev start project3- should see "Router ports have not changed, skipping recreation"To test port changes work correctly:
router_http_port: 8080ddev start project-custom-portddev stop -aand then check router statusddev starta project and router should already be waiting to go and not be recreated unless ports change.Automated Testing Overview
Added
TestPortsMatchfunction inpkg/ddevapp/router_test.gothat validates the port comparison logic with 6 test cases:Existing router tests continue to validate overall router functionality.
Release/Deployment Notes
Technical Details
Files changed:
pkg/ddevapp/router.go(+73/-18 lines)pkg/ddevapp/router_test.go(+54 lines)Before: Starting dcmsolivero (4th project, same ports)
After: Starting dcmsolivero (4th project, same ports)
Original prompt
This section details on the original issue you should resolve
<issue_title>router gets recreated on start of a third+ project without the need to support new ports</issue_title>
<issue_description>### Preliminary checklist
ddev utility testor at leastddev utility diagnoseto include output belowOutput of
ddev utility testorddev utility diagnoseExpand `ddev utility diagnose` diagnostic information
Expected Behavior
i would expect that on project start the router would not have to be created on every project start. i would expect that on some project starts only the projects web and db containers are getting created and not also the router again.
Actual Behavior
i had four running projects:
dcms and dcmsolivero are identical installs of drupal cms 2.x. dcmsoliver is basically the database of dcms exported, then the folder with the exported database cloned, within the cloned folder ddev config ran again to add a new project name. so both projects are identical except the name and no additional service added. when i stop dcmsoliver:
and when i start it again the router is getting recreated.