Skip to content

fix(describe): show service info when project is stopped, fixes #7159 - #7768

Merged
stasadev merged 3 commits into
ddev:mainfrom
stasadev:20251027_stasadev_describe
Nov 1, 2025
Merged

stasadev merged 3 commits into
ddev:mainfrom
stasadev:20251027_stasadev_describe

Conversation

@stasadev

@stasadev stasadev commented Oct 27, 2025 •

Copy link
Copy Markdown
Member

The Issue

When a DDEV project is stopped or has failed containers, ddev describe shows empty boxes instead of displaying available service information. The command was overly dependent on SiteRunning status, preventing it from showing useful information about configured services when containers aren't running.

Additionally, ddev exec was checking overall project status instead of verifying the specific target container, causing it to fail when the project had some stopped services even if the target service was running.

How This PR Solves The Issue

For ddev describe:

  1. Removed status-dependent rendering (cmd/ddev/cmd/describe.go):

    • Removed the if status == SiteRunning check that prevented service table rendering
    • Service information is now displayed regardless of project status
    • Individual service status is shown in the table (running/stopped/unhealthy)
  2. Enhanced stopped services data collection (pkg/ddevapp/ddevapp.go):

    • Added logic to parse docker-compose configuration for stopped services
    • Extract service information from compose configuration when containers aren't running:
      • Image names (with -built suffix stripped)
      • Exposed ports from both ports section and HTTP_EXPOSE/HTTPS_EXPOSE environment variables - Virtual hosts and URLs from environment variables
    • Ensures stopped services have the same data structure as running services
  3. Moved unconditional fields outside status check (pkg/ddevapp/ddevapp.go):

    • Database info, XHProf mode, and XHGui status now populate regardless of running state
    • Allows accurate display of configuration even when stopped

For ddev exec:

  • Changed from checking overall app.SiteStatus() to specifically checking if the target container exists using app.FindContainerByType()
  • Provides clearer error messages indicating which specific service is unavailable
  • Allows exec to work on running services even when other services are stopped

Manual Testing Instructions

Test 1: Describe stopped project

cd <any-ddev-project>
ddev stop
ddev describe
# Should show service table with status "stopped" and service details
# including exposed ports, virtual hosts, image names

Test 2: Describe project with failed container

ddev start
ddev exec -s db kill 1
ddev describe
# Should show db as unhealthy/stopped with service info still visible

Test 3: Describe running project (regression test)

ddev start
ddev describe
# Should show full service info as before, with URLs and port mappings

Test 4: Exec with partial failure

ddev start
ddev stop -s db
ddev exec ls
# Should work - exec targets web service which is still running
ddev exec -s db ls
# Should fail with clear message: "No running container found for service 'db'"

Test 5: Services with HTTP_EXPOSE/HTTPS_EXPOSE

# On a project with additional services like adminer or mailpit
ddev stop
ddev describe
# Verify stopped services show correct exposed_ports extracted from environment variables
# e.g., adminer should show port 8080

Test 6: Compare ddev describe -j output for started and stopped project

# Run in DDEV HEAD:
ddev describe -j
# Run in this PR
ddev describe -j

Automated Testing Overview

Changes impact the Describe() method extensively, which is covered by existing tests:

  • pkg/ddevapp/ddevapp_test.go - Tests the Describe() method functionality
  • Tests should pass with these changes as the data structure remains compatible

Additional testing should verify:

  • Stopped project describe output includes service information
  • Service status accurately reflects container state
  • Port information correctly extracted from docker-compose environment variables

Release/Deployment Notes

User-facing improvements:

  • ddev describe now works when projects are stopped, showing configured services and their settings
  • More helpful error messages from ddev exec when specific services aren't running
  • Better visibility into project configuration without requiring services to be running

Backwards compatibility:

  • Fully backwards compatible - no breaking changes to command output structure
  • Existing scripts/tools parsing describe output should continue to work
  • Service data structure remains unchanged, just populated for stopped services

Documentation updates:

  • No documentation changes required - this fixes existing documented behavior

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 27, 2025 •

Copy link
Copy Markdown

@stasadev
stasadev force-pushed the 20251027_stasadev_describe branch from 47ad4cd to e8240a8 Compare October 27, 2025 20:04
@rfay rfay added this to the v1.24.9 milestone Oct 31, 2025
@stasadev
stasadev force-pushed the 20251027_stasadev_describe branch from 4c2bebb to 5511c81 Compare October 31, 2025 19:15
@stasadev
stasadev marked this pull request as ready for review October 31, 2025 19:19
@stasadev
stasadev requested a review from a team as a code owner October 31, 2025 19:19
@stasadev
stasadev requested a review from rfay October 31, 2025 19:19
@stasadev

Copy link
Copy Markdown
Member Author

Ready for review.

I can't imagine how we lived without it 😁.

Comment thread cmd/ddev/cmd/describe.go
Comment on lines +52 to +59
// Ensure we have all services to describe for never-started projects.
if !fileutil.FileExists(app.DockerComposeFullRenderedYAMLPath()) {
_ = app.DockerEnv()
err = app.WriteDockerComposeYAML()
if err != nil {
util.Failed("Failed to run `docker-compose config` for '%s': %v", app.Name, err)
}
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I added a condition here because PhpStorm DDEV Integration runs ddev describe -j every X seconds.

Running docker-compose config inside app.WriteDockerComposeYAML() every X seconds is not what we want.

@rfay

rfay commented Oct 31, 2025

Copy link
Copy Markdown
Member

Should we add it to ddev ut test and ddev ut diagnose, or might it show too much private info?

@stasadev

Copy link
Copy Markdown
Member Author

Should we add it to ddev ut test and ddev ut diagnose, or might it show too much private info?

Isn't that the same as ddev ut configyaml, but in a different form?

I'm not sure we need to add this output to ddev ut test and ddev ut diagnose.

@rfay

rfay commented Oct 31, 2025

Copy link
Copy Markdown
Member

Well, normally ddev ut test shows a lot more than just the configyaml. Like the URL and such. That's why it might expose more sensitive info (when shared in issue)

…7159

## The Issue

Fixes ddev#7159

When a DDEV project is stopped or has failed containers, `ddev describe` shows empty boxes instead of displaying available service information. The command was overly dependent on `SiteRunning` status, preventing it from showing useful information about configured services when containers aren't running.

Additionally, `ddev exec` was checking overall project status instead of verifying the specific target container, causing it to fail when the project had some stopped services even if the target service was running.

## How This PR Solves The Issue

**For `ddev describe`:**

1. **Removed status-dependent rendering** (`cmd/ddev/cmd/describe.go`):
   - Removed the `if status == SiteRunning` check that prevented service table rendering
   - Service information is now displayed regardless of project status
   - Individual service status is shown in the table (running/stopped/unhealthy)

2. **Enhanced stopped services data collection** (`pkg/ddevapp/ddevapp.go`):
   - Added logic to parse docker-compose configuration for stopped services
   - Extract service information from compose configuration when containers aren't running:
     - Image names (with `-built` suffix stripped)
     - Exposed ports from both `ports` section and `HTTP_EXPOSE`/`HTTPS_EXPOSE` environment variables
     - Virtual hosts and URLs from environment variables
   - Ensures stopped services have the same data structure as running services

3. **Moved unconditional fields outside status check** (`pkg/ddevapp/ddevapp.go`):
   - Database info, XHProf mode, and XHGui status now populate regardless of running state
   - Allows accurate display of configuration even when stopped

**For `ddev exec`:**

- Changed from checking overall `app.SiteStatus()` to specifically checking if the target container exists using `app.FindContainerByType()`
- Provides clearer error messages indicating which specific service is unavailable
- Allows exec to work on running services even when other services are stopped

## Manual Testing Instructions

### Test 1: Describe stopped project
```bash
cd <any-ddev-project>
ddev stop
ddev describe
# Should show service table with status "stopped" and service details
# including exposed ports, virtual hosts, image names
```

### Test 2: Describe project with failed container
```bash
ddev start
ddev exec -s db kill 1
ddev describe
# Should show db as unhealthy/stopped with service info still visible
```

### Test 3: Describe running project (regression test)
```bash
ddev start
ddev describe
# Should show full service info as before, with URLs and port mappings
```

### Test 4: Exec with partial failure
```bash
ddev start
ddev stop -s db
ddev exec ls
# Should work - exec targets web service which is still running
ddev exec -s db ls
# Should fail with clear message: "No running container found for service 'db'"
```

### Test 5: Services with HTTP_EXPOSE/HTTPS_EXPOSE
```bash
# On a project with additional services like adminer or mailpit
ddev stop
ddev describe
# Verify stopped services show correct exposed_ports extracted from environment variables
# e.g., adminer should show port 8080
```

## Automated Testing Overview

Changes impact the `Describe()` method extensively, which is covered by existing tests:
- `pkg/ddevapp/ddevapp_test.go` - Tests the `Describe()` method functionality
- Tests should pass with these changes as the data structure remains compatible

Additional testing should verify:
- Stopped project describe output includes service information
- Service status accurately reflects container state
- Port information correctly extracted from docker-compose environment variables

## Release/Deployment Notes

**User-facing improvements:**
- `ddev describe` now works when projects are stopped, showing configured services and their settings
- More helpful error messages from `ddev exec` when specific services aren't running
- Better visibility into project configuration without requiring services to be running

**Backwards compatibility:**
- Fully backwards compatible - no breaking changes to command output structure
- Existing scripts/tools parsing describe output should continue to work
- Service data structure remains unchanged, just populated for stopped services

**Documentation updates:**
- No documentation changes required - this fixes existing documented behavior

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

Co-Authored-By: Claude <[email protected]>
don't skip optional services in `ddev describe`

Describe show work even for fresh never-started project

Add x-ddev
@stasadev
stasadev force-pushed the 20251027_stasadev_describe branch from 5511c81 to 40b9018 Compare November 1, 2025 11:39
@stasadev

stasadev commented Nov 1, 2025

Copy link
Copy Markdown
Member Author

I'm not sure what else I might need to change, so I'm going to pull it.

There's a bit of duplication of logic, but I don't want to experiment with that before release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ddev describe should show info for all available services (including optional profiles) when the project is stopped

2 participants