Skip to content

[BUG] Following quickstart docs leads to panic #1719

@brasic

Description

@brasic

Expected Behavior

The documentation at https://kompose.io/getting-started/ says to call kompose convert with no -f argument. As a user I assume that means it will guess the location of the file by default. As of right now the docs say:

Run kompose convert in the same directory as your docker-compose.yaml file.

$ kompose convert
INFO Kubernetes file "frontend-service.yaml" created
INFO Kubernetes file "redis-master-service.yaml" created
INFO Kubernetes file "redis-replica-service.yaml" created
INFO Kubernetes file "frontend-deployment.yaml" created
INFO Kubernetes file "redis-master-deployment.yaml" created
INFO Kubernetes file "redis-replica-deployment.yaml" created

I expect to be able to follow the instructions to get the result suggested.

Actual Behavior

A go panic trying to index into an empty slice of input files:

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

goroutine 1 [running]:
github.com/kubernetes/kompose/pkg/loader/compose.getComposeFileDir({0x17be0b8?, 0x203000?, 0x203000?})
        /Users/cdrage/syncthing/dev/go/src/kompose/pkg/loader/compose/utils.go:135 +0xee
github.com/kubernetes/kompose/pkg/loader/compose.(*Compose).LoadFile(0x203000?, {0x17be0b8, 0x0, 0x0}, {0x17be0b8, 0x0, 0x0})
        /Users/cdrage/syncthing/dev/go/src/kompose/pkg/loader/compose/compose.go:154 +0x85
github.com/kubernetes/kompose/pkg/app.Convert({0x0, 0x1, 0x0, 0x0, 0x1, {0x0, 0x0}, {0x0, 0x0}, {0xf645b9, ...}, ...})
        /Users/cdrage/syncthing/dev/go/src/kompose/pkg/app/app.go:220 +0x183
github.com/kubernetes/kompose/cmd.glob..func3(0x177c880?, {0x17be0b8?, 0x0?, 0x0?})
        /Users/cdrage/syncthing/dev/go/src/kompose/cmd/convert.go:140 +0x58
github.com/spf13/cobra.(*Command).execute(0x177c880, {0x17be0b8, 0x0, 0x0})
        /Users/cdrage/syncthing/dev/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:944 +0x847
github.com/spf13/cobra.(*Command).ExecuteC(0x177cb60)
        /Users/cdrage/syncthing/dev/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/cdrage/syncthing/dev/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:992
github.com/kubernetes/kompose/cmd.Execute(...)
        /Users/cdrage/syncthing/dev/go/src/kompose/cmd/root.go:89
main.main()
        /Users/cdrage/syncthing/dev/go/src/kompose/main.go:27 +0x25

Steps To Reproduce

  1. Create and enter empty directory
  2. curl -Os https://raw.githubusercontent.com/kubernetes/kompose/main/examples/docker-compose.yaml
  3. kompose convert

Kompose Version

1.31.0 (a04ecdb9e)

Docker-Compose file

any compose file will do, such as the one suggested by the readme

Anything else?

Given that the code panics instead of printing a nicer error I suspect there may have been some recent change to stop inferring the input files? Should probably fix that bug as well as the docs. I had to dig into the code to find out how to actually use it properly, since the output of kompose convert --help makes only this oblique reference to the apparently required -f param:

  -f, --file stringArray    Specify an alternative compose file

I wonder if this has something to do with case sensitivity. The machine I observed this on is a linux workstation. Maybe this is normally only used on macs?

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions