getporter / porter

Porter enables you to package your application artifact, client tools, configuration and deployment logic together as an installer that you can distribute, and install with a single command.
https://porter.sh
Apache License 2.0
1.23k stars 206 forks source link

Action without mixin specified causes panic #873

Closed squillace closed 4 years ago

squillace commented 4 years ago

Install the following:

  1. ╭─ralph at surfacebook in ~/work/go/src/github.com/squillace using
    ╰─○ curl https://cdn.porter.sh/latest/install-linux.sh | bash
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
    100  1111  100  1111    0     0   1121      0 --:--:-- --:--:-- --:--:--  1121
    Installing porter to /home/ralph/.porter
    Installed porter v0.22.2-beta.1 (4401e74)
    installed exec mixin
    exec v0.22.2-beta.1 (4401e74) by Porter Authors
    installed kubernetes mixin
    kubernetes v0.22.2-beta.1 (4401e74) by Porter Authors
    installed helm mixin
    helm v0.10.1-beta.1 (83466c2) by Porter Authors
    installed azure mixin
    azure v0.7.1-beta.1 (a05ef92) by DeisLabs
    installed terraform mixin
    terraform v0.5.1-beta.1 (597a442) by Porter Authors
    installed az mixin
    az v0.4.1-beta.1 (c27e188) by Porter Authors
    installed aws mixin
    aws v0.2.1-beta.1 (e7b6884) by Porter Authors
    installed gcloud mixin
    gcloud v0.3.1-beta.1 (a8240d4) by Porter Authors
    Installation complete.
    Add porter to your path by running:
    export PATH=$PATH:~/.porter
  2. Note that the az mixin you have used extensively is there, version v0.4.1-beta.1 (c27e188). So, put - az in the porter.yaml file: image

  3. Build the bundle:

    
    porter build
    Copying porter runtime ===> 
    Copying mixins ===> 
    Copying mixin exec ===> 
    Copying mixin kubernetes ===> 
    Copying mixin helm3 ===> 
    Copying mixin az ===> 

Generating Dockerfile =======> panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x83a057]

goroutine 1 [running]: get.porter.sh/porter/pkg/manifest.(Step).GetMixinName(0x0, 0xc0000ce4f0, 0x5) /home/vsts/work/1/s/gopath/src/get.porter.sh/porter/pkg/manifest/manifest.go:445 +0x37 get.porter.sh/porter/pkg/build.(DockerfileGenerator).getMixinBuildInput.func1(0x1bdcea2, 0x7, 0xc00037f9b0, 0x5, 0x5) /home/vsts/work/1/s/gopath/src/get.porter.sh/porter/pkg/build/dockerfile-generater.go:212 +0xbd get.porter.sh/porter/pkg/build.(DockerfileGenerator).getMixinBuildInput(0xc0004fdd18, 0xc0000ce3f8, 0x4, 0x2d406c0, 0x0, 0x4d5b38) /home/vsts/work/1/s/gopath/src/get.porter.sh/porter/pkg/build/dockerfile-generater.go:219 +0x12f get.porter.sh/porter/pkg/build.(DockerfileGenerator).buildMixinsSection(0xc0004fdd18, 0xc000120000, 0x9, 0x10, 0x0, 0x0) /home/vsts/work/1/s/gopath/src/get.porter.sh/porter/pkg/build/dockerfile-generater.go:178 +0x1c3 get.porter.sh/porter/pkg/build.(DockerfileGenerator).buildDockerfile(0xc0004fdd18, 0x0, 0x0, 0x83b565, 0x22, 0x4f) /home/vsts/work/1/s/gopath/src/get.porter.sh/porter/pkg/build/dockerfile-generater.go:61 +0xd4 get.porter.sh/porter/pkg/build.(DockerfileGenerator).GenerateDockerFile(0xc0004fdd18, 0x0, 0x0) /home/vsts/work/1/s/gopath/src/get.porter.sh/porter/pkg/build/dockerfile-generater.go:37 +0x40 get.porter.sh/porter/pkg/porter.(Porter).Build(0xc00038cc00, 0xc0004fdd00, 0x0, 0x0) /home/vsts/work/1/s/gopath/src/get.porter.sh/porter/pkg/porter/build.go:38 +0x155 main.buildBundleBuildCommand.func1(0xc000435400, 0x2d406c0, 0x0, 0x0, 0x0, 0x0) /home/vsts/work/1/s/gopath/src/get.porter.sh/porter/cmd/porter/bundle.go:53 +0x35 github.com/spf13/cobra.(Command).execute(0xc000435400, 0x2d406c0, 0x0, 0x0, 0xc000435400, 0x2d406c0) /home/vsts/work/1/s/gopath/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:826 +0x460 github.com/spf13/cobra.(Command).ExecuteC(0xc0002d6780, 0x0, 0x18dc300, 0xc0000ac058) /home/vsts/work/1/s/gopath/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914 +0x2fb github.com/spf13/cobra.(Command).Execute(...) /home/vsts/work/1/s/gopath/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864 main.main() /home/vsts/work/1/s/gopath/src/get.porter.sh/porter/cmd/porter/main.go:18 +0x27

squillace commented 4 years ago

Yeah, brand new project, do nothing at all but put - az in the mixins section, and boom:

weird-az-ity

squillace commented 4 years ago

Fastest bug to go away in the world. Seems I had an emtpy - in the install: action. That one line, with a hyphen, seems to have caused the SEGV.

carolynvs commented 4 years ago

Hey Ralph, we'd like to catch and validate stuff like this as part of #532. Was this the offending YAML, where there was an action with no mixin specified?

install:
- az:
  ... good yaml
- 
- exec:
   ... moar good yaml
$ porter install
Building bundle ===>
Copying porter runtime ===>
Copying mixins ===>
Copying mixin exec ===>

Generating Dockerfile =======>
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4436a87]

goroutine 1 [running]:
get.porter.sh/porter/pkg/manifest.(*Step).GetMixinName(0x0, 0x716ce70, 0x0)
    /Users/carolynvs/go/src/get.porter.sh/porter/pkg/manifest/manifest.go:445 +0x37
get.porter.sh/porter/pkg/build.(*DockerfileGenerator).getMixinBuildInput.func1(0x57e2c13, 0x7, 0xc000452210, 0x2, 0x2)
    /Users/carolynvs/go/src/get.porter.sh/porter/pkg/build/dockerfile-generater.go:212 +0xbd
get.porter.sh/porter/pkg/build.(*DockerfileGenerator).getMixinBuildInput(0xc0005c97e0, 0xc000228080, 0x4, 0x6951598, 0x0, 0x40d6908)
    /Users/carolynvs/go/src/get.porter.sh/porter/pkg/build/dockerfile-generater.go:219 +0x12f
get.porter.sh/porter/pkg/build.(*DockerfileGenerator).buildMixinsSection(0xc0005c97e0, 0xc0003a3400, 0x9, 0x10, 0x0, 0x0)
    /Users/carolynvs/go/src/get.porter.sh/porter/pkg/build/dockerfile-generater.go:178 +0x1c3
get.porter.sh/porter/pkg/build.(*DockerfileGenerator).buildDockerfile(0xc0005c97e0, 0x0, 0x0, 0x4437f95, 0x27, 0x4f)
    /Users/carolynvs/go/src/get.porter.sh/porter/pkg/build/dockerfile-generater.go:61 +0xd4
get.porter.sh/porter/pkg/build.(*DockerfileGenerator).GenerateDockerFile(0xc0005c97e0, 0x0, 0x0)
    /Users/carolynvs/go/src/get.porter.sh/porter/pkg/build/dockerfile-generater.go:37 +0x40
get.porter.sh/porter/pkg/porter.(*Porter).Build(0xc0000f0630, 0xc0000da000, 0xc0005c9870, 0x1)
    /Users/carolynvs/go/src/get.porter.sh/porter/pkg/porter/build.go:38 +0x155
get.porter.sh/porter/pkg/porter.(*Porter).ensureLocalBundleIsUpToDate(0xc0000f0630, 0x57e92a6, 0xb, 0xc0002dac20, 0x11, 0x0, 0x0, 0x0, 0x0)
    /Users/carolynvs/go/src/get.porter.sh/porter/pkg/porter/stamp.go:25 +0x1aa
get.porter.sh/porter/pkg/porter.(*Porter).InstallBundle(0xc0000f0630, 0x57e92a6, 0xb, 0xc0002dac20, 0x11, 0x0, 0x0, 0xc0002289e8, 0x5, 0x1, ...)
    /Users/carolynvs/go/src/get.porter.sh/porter/pkg/porter/install.go:30 +0xcc
main.buildBundleInstallCommand.func2(0xc000403180, 0x6951598, 0x0, 0x0, 0x0, 0x0)
    /Users/carolynvs/go/src/get.porter.sh/porter/cmd/porter/bundle.go:85 +0x7e
github.com/spf13/cobra.(*Command).execute(0xc000403180, 0x6951598, 0x0, 0x0, 0xc000403180, 0x6951598)
    /Users/carolynvs/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:826 +0x460
github.com/spf13/cobra.(*Command).ExecuteC(0xc0001cea00, 0x0, 0xaa400, 0xc0000b8058)
    /Users/carolynvs/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914 +0x2fb
github.com/spf13/cobra.(*Command).Execute(...)
    /Users/carolynvs/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864
main.main()
    /Users/carolynvs/go/src/get.porter.sh/porter/cmd/porter/main.go:18 +0x27

I've gotten that to reproduce but wanted to double check that was what you saw too.

carolynvs commented 4 years ago

I've moved this issue into the porter backlog since it's not specific to any mixin.

squillace commented 4 years ago

yeah, that repro is pretty much what I found and removed and everything started working....

dev-drprasad commented 4 years ago

@carolynvs I would like to pickup this issue

carolynvs commented 4 years ago

Sounds good! 👍

Just so that you know, now that you are on the @deislabs/porters team, feel free to continue to comment on the issue and then assign it to yourself. Any issue that is labeled and in the backlog on our project board (as long as it's not hmm 🛑🤔) is fair game.

Members of the @deislabs/porters team have permission to self-assign issues. I am working on updating the contributing guide to explain the team permissions soon, now that we have more contributors. 💃