Skip to content

ddev poweroff can panic #8024

@rfay

Description

@rfay

Expected Behavior

ddev poweroff has no business panicking.

Actual Behavior

On tb-wsl-mirrored-15 we're having repeatable problems where an undeletable container persists

docker-ce 29.1.4

In this situation, with just this container, ddev poweroff results in this panic (probably v1.24.10 code)

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/ddev/ddev/pkg/ddevapp.PowerOff()
        /home/runner/work/ddev/ddev/pkg/ddevapp/poweroff.go:37 +0x6e5
github.com/ddev/ddev/cmd/ddev/cmd.init.func48(0xc000488a00?, {0x1be3680?, 0x0?, 0x0?})
        /home/runner/work/ddev/ddev/cmd/ddev/cmd/poweroff.go:17 +0xf
github.com/spf13/cobra.(*Command).execute(0x1baed00, {0x1be3680, 0x0, 0x0})
        /home/runner/work/ddev/ddev/vendor/github.com/spf13/cobra/command.go:1019 +0xae7
github.com/spf13/cobra.(*Command).ExecuteC(0x1bb0120)
        /home/runner/work/ddev/ddev/vendor/github.com/spf13/cobra/command.go:1148 +0x465
github.com/spf13/cobra.(*Command).Execute(...)
        /home/runner/work/ddev/ddev/vendor/github.com/spf13/cobra/command.go:1071
github.com/ddev/ddev/cmd/ddev/cmd.Execute()
        /home/runner/work/ddev/ddev/cmd/ddev/cmd/root.go:117 +0x1a
main.main()
        /home/runner/work/ddev/ddev/cmd/ddev/main.go:28 +0xaa

poweroff.go:17 happens to be

_, _, err = dockerutil.RunSimpleContainer(versionconstants.UtilitiesImage, "poweroff-"+util.RandString(6), []string{"sh", "-c", "rm -rf /mnt/ddev-global-cache/custom_certs/* /mnt/ddev-global-cache/traefik/*"}, []string{}, []string{}, []string{"ddev-global-cache" + ":/mnt/ddev-global-cache"}, "", true, false, map[string]string{"com.ddev.site-name": ""}, nil, &dockerutil.NoHealthCheck)

_, _, err = dockerutil.RunSimpleContainer(versionconstants.UtilitiesImage, "poweroff-"+util.RandString(6), []string{"sh", "-c", "rm -rf /mnt/ddev-global-cache/custom_certs/* /mnt/ddev-global-cache/traefik/*"}, []string{}, []string{}, []string{"ddev-global-cache" + ":/mnt/ddev-global-cache"}, "", true, false, map[string]string{"com.ddev.site-name": ""}, nil, &dockerutil.NoHealthCheck)

I guess the actual panic is poweroff.go:37:

			if err != nil {
				util.Warning("Failed to remove container %v: %v", c.ID, err)

The irony of that is that that code was just added to try to gather info and have a non-fatal response to the Lima problem.

The undeletable container looks like this:

1$ docker ps -a
CONTAINER ID   IMAGE                                                 COMMAND                   CREATED          STATUS                    PORTS     NAMES
500f3d84728b   ddev/ddev-webserver:20260107_codebymikey_ssh_config   "bash -c 'ls -1 \"/mn…"   4 hours ago      Exited (0) 4 hours ago

Steps To Reproduce

No response

Anything else?

Possibly/probably related:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions