Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starting a container via compat API with with StorageOpt crashes the server #12766

Closed
riyad opened this issue Jan 7, 2022 · 0 comments · Fixed by #12767
Closed

Starting a container via compat API with with StorageOpt crashes the server #12766

riyad opened this issue Jan 7, 2022 · 0 comments · Fixed by #12767
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@riyad
Copy link
Contributor

riyad commented Jan 7, 2022

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

Starting a container via compat API with with StorageOpt crashes the server with the following error: runtime error: index out of range [1] with length 1 (see below).

Doing a little digging it seems like decoding the options (by splitting on "=") in libpod/container_internal.go:454 fails because they have already been decoded in pkg/specgenutil/specgen.go:397.
It seems like the relevant code was added in #11991.

Steps to reproduce the issue:

  1. curl -sS --unix-socket /run/user/1000/podman/podman.sock -XPOST 'http://localhost/v1.40/containers/create' -H "Content-Type: application/tar" -d '{"Tty": false, "OpenStdin": false, "StdinOnce": false, "AttachStdin": false, "AttachStdout": true, "AttachStderr": true, "Cmd": ["echo", "test"], "Image": "alpine:3.10", "NetworkDisabled": false, "HostConfig": {"NetworkMode": "default", "StorageOpt": {"size": "120G"}}}'

Describe the results you received:

Server response:

500 Internal Server Error
{"cause":"runtime error: index out of range [1] with length 1","message":"runtime error: index out of range [1] with length 1","response":500}

Server logs:

WARN[0043] Recovering from API service endpoint handler panic: runtime error: index out of range [1] with length 1, goroutine 50 [running]:
github.com/containers/podman/v3/pkg/api/server.panicHandler.func1.1.1()
        /home/riyad/src/podman/pkg/api/server/handler_panic.go:22 +0x85
panic({0x1822740, 0xc0004358d8})
        /snap/go/8839/src/runtime/panic.go:1038 +0x215
github.com/containers/podman/v3/libpod.(*Container).setupStorage(0xc000593a70, {0x1be9488, 0xc000474a50})
        /home/riyad/src/podman/libpod/container_internal.go:458 +0xeb2
github.com/containers/podman/v3/libpod.(*Runtime).setupContainer(0xc0005428c0, {0x1be9488, 0xc000474a50}, 0xc000593a70)
        /home/riyad/src/podman/libpod/runtime_ctr.go:420 +0x11a8
github.com/containers/podman/v3/libpod.(*Runtime).newContainer(0x0, {0x1be9488, 0xc000474a50}, 0x0, {0xc0006ead80, 0xf, 0x0})
        /home/riyad/src/podman/libpod/runtime_ctr.go:231 +0xfc
github.com/containers/podman/v3/libpod.(*Runtime).NewContainer(0xc0005428c0, {0x1be9488, 0xc000474a50}, 0x0, 0x0, 0x0, {0xc0006ead80, 0xf, 0x10})
        /home/riyad/src/podman/libpod/runtime_ctr.go:53 +0x1b2
github.com/containers/podman/v3/pkg/specgen/generate.ExecuteCreate({0x1be9488, 0xc000474a50}, 0x0, 0xc000588a00, 0x0, 0x0, {0xc0006ead80, 0x0, 0x0})
        /home/riyad/src/podman/pkg/specgen/generate/container_create.go:194 +0x3f
github.com/containers/podman/v3/pkg/domain/infra/abi.(*ContainerEngine).ContainerCreate(0xc0008ff168, {0x1be9488, 0xc000474a50}, 0x3)
        /home/riyad/src/podman/pkg/domain/infra/abi/containers.go:612 +0xe5
github.com/containers/podman/v3/pkg/api/handlers/compat.CreateContainer({0x7fbb9c373278, 0xc000474ab0}, 0xc000472900)
        /home/riyad/src/podman/pkg/api/handlers/compat/containers_create.go:100 +0x537
github.com/containers/podman/v3/pkg/api/server.(*APIServer).APIHandler.func1.1({0x7fbb9c373278, 0xc000474ab0}, 0xc000472900)
        /home/riyad/src/podman/pkg/api/server/handler_api.go:36 +0x922
github.com/containers/podman/v3/pkg/api/server.(*APIServer).APIHandler.func1({0x7fbb9c373278, 0xc000474ab0}, 0xc0007942c0)
        /home/riyad/src/podman/pkg/api/server/handler_api.go:38 +0x57
net/http.HandlerFunc.ServeHTTP(0x17ead00, {0x7fbb9c373278, 0xc000474ab0}, 0xe)
        /snap/go/8839/src/net/http/server.go:2047 +0x2f
github.com/containers/podman/v3/pkg/api/server.referenceIDHandler.func1.1({0x7fbb9c373278, 0xc000474ab0}, 0xc000472900)
        /home/riyad/src/podman/pkg/api/server/handler_rid.go:38 +0x35e
net/http.HandlerFunc.ServeHTTP(0x1bf9e98, {0x7fbb9c373278, 0xc000474ab0}, 0x7fbbcb5a75b8)
        /snap/go/8839/src/net/http/server.go:2047 +0x2f
github.com/gorilla/handlers.combinedLoggingHandler.ServeHTTP({{0x1bbc000, 0x28717c0}, {0x1bbc140, 0xc00019e228}}, {0x1bd3ba0, 0xc00002c1c0}, 0xc000472900)
        /home/riyad/src/podman/vendor/github.com/gorilla/handlers/handlers.go:75 +0x369
github.com/containers/podman/v3/pkg/api/server.panicHandler.func1.1({0x1bd3ba0, 0xc00002c1c0}, 0xc000474a50)
        /home/riyad/src/podman/pkg/api/server/handler_panic.go:29 +0x82
net/http.HandlerFunc.ServeHTTP(0xc000472700, {0x1bd3ba0, 0xc00002c1c0}, 0xc0000789f8)
        /snap/go/8839/src/net/http/server.go:2047 +0x2f
github.com/gorilla/mux.(*Router).ServeHTTP(0xc0004da000, {0x1bd3ba0, 0xc00002c1c0}, 0xc000472200)
        /home/riyad/src/podman/vendor/github.com/gorilla/mux/mux.go:210 +0x1cf
net/http.serverHandler.ServeHTTP({0x1bcd908}, {0x1bd3ba0, 0xc00002c1c0}, 0xc000472200)
        /snap/go/8839/src/net/http/server.go:2879 +0x43b
net/http.(*conn).serve(0xc0005a60a0, {0x1be9488, 0xc000474030})
        /snap/go/8839/src/net/http/server.go:1930 +0xb08
created by net/http.(*Server).Serve
        /snap/go/8839/src/net/http/server.go:3034 +0x4e8

---[snip]---

Output of podman version:

Client:       Podman Engine
Version:      4.0.0-dev
API Version:  4.0.0-dev
Go Version:   go1.17.5
Git Commit:   8a2238440635d497dbdacceb6826c850582766ea
Built:        Fri Jan  7 10:34:52 2022
OS/Arch:      linux/amd64
@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Jan 7, 2022
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant