kudobuilder / kudo

Kubernetes Universal Declarative Operator (KUDO)
https://kudo.dev
Apache License 2.0
1.18k stars 103 forks source link

kudo init --verify throws an error when KUDO is not installed #1753

Closed akirillov closed 3 years ago

akirillov commented 3 years ago

What happened: When running kubectl kudo init --verify without KUDO installed results in a runtime error:

$KUDO_HOME has been configured at /Users/user/.kudo
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x18d3ccc]

goroutine 1 [running]:
k8s.io/apimachinery/pkg/apis/meta/v1/unstructured.(*Unstructured).GetAPIVersion(...)
    /Users/kensipe/projects/go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/apis/meta/v1/unstructured/unstructured.go:218
k8s.io/apimachinery/pkg/apis/meta/v1/unstructured.(*Unstructured).GroupVersionKind(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/kensipe/projects/go/pkg/mod/k8s.io/apimachinery@v0.19.2/pkg/apis/meta/v1/unstructured/unstructured.go:426 +0x6c
github.com/kudobuilder/kudo/pkg/kudoctl/kudoinit/prereq.validateUnstructuredInstallation(0x2973be0, 0xc000206230, 0x0, 0xc00061aba0, 0x0, 0xc00011c080)
    /Users/kensipe/projects/go/src/github.com/kudobuilder/kudo/pkg/kudoctl/kudoinit/prereq/webhook.go:394 +0x45
github.com/kudobuilder/kudo/pkg/kudoctl/kudoinit/prereq.(*KudoWebHook).verifyWithCertManager(0xc000a21540, 0xc00088e370, 0xc00061aba0, 0xc0001391e0, 0xc000139340)
    /Users/kensipe/projects/go/src/github.com/kudobuilder/kudo/pkg/kudoctl/kudoinit/prereq/webhook.go:114 +0xed
github.com/kudobuilder/kudo/pkg/kudoctl/kudoinit/prereq.(*KudoWebHook).VerifyInstallation(0xc000a21540, 0xc00088e370, 0xc00061aba0, 0x0, 0x0)
    /Users/kensipe/projects/go/src/github.com/kudobuilder/kudo/pkg/kudoctl/kudoinit/prereq/webhook.go:103 +0x85
github.com/kudobuilder/kudo/pkg/kudoctl/kudoinit/setup.(*Installer).VerifyInstallation(0xc000534630, 0xc00088e370, 0xc00061aba0, 0x2973be0, 0x29c9aa0)
    /Users/kensipe/projects/go/src/github.com/kudobuilder/kudo/pkg/kudoctl/kudoinit/setup/setup.go:63 +0x9c
github.com/kudobuilder/kudo/pkg/kudoctl/kudoinit/setup.VerifyExistingInstallation(0x29a1a60, 0xc000534630, 0xc00088e370, 0x29744c0, 0xc0000aa008, 0x0, 0x0, 0x0)
    /Users/kensipe/projects/go/src/github.com/kudobuilder/kudo/pkg/kudoctl/kudoinit/setup/setup.go:176 +0x95
github.com/kudobuilder/kudo/pkg/kudoctl/cmd.(*initCmd).verifyExistingInstallation(0xc00046a9c0, 0x29a1a60, 0xc000534630, 0x0, 0x0)
    /Users/kensipe/projects/go/src/github.com/kudobuilder/kudo/pkg/kudoctl/cmd/init.go:290 +0x69
github.com/kudobuilder/kudo/pkg/kudoctl/cmd.(*initCmd).run(0xc00046a9c0, 0x2758b52, 0x9)
    /Users/kensipe/projects/go/src/github.com/kudobuilder/kudo/pkg/kudoctl/cmd/init.go:206 +0x3b2
github.com/kudobuilder/kudo/pkg/kudoctl/cmd.newInitCmd.func1(0xc00013cdc0, 0xc00021a990, 0x0, 0x1, 0x0, 0x0)
    /Users/kensipe/projects/go/src/github.com/kudobuilder/kudo/pkg/kudoctl/cmd/init.go:104 +0x12b
github.com/spf13/cobra.(*Command).execute(0xc00013cdc0, 0xc00021a970, 0x1, 0x1, 0xc00013cdc0, 0xc00021a970)
    /Users/kensipe/projects/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:842 +0x47c
github.com/spf13/cobra.(*Command).ExecuteC(0xc00013c840, 0x0, 0x249f3e0, 0xc000096058)
    /Users/kensipe/projects/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
    /Users/kensipe/projects/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887
main.main()
    /Users/kensipe/projects/go/src/github.com/kudobuilder/kudo/cmd/kubectl-kudo/main.go:24 +0x2a

What you expected to happen: A human-readable message about the KUDO Controller not being installed displayed instead.

How to reproduce it (as minimally and precisely as possible): Run kubectl kudo init --verify on a cluster without KUDO installed.

Environment: