Skip to content

Unexpected exception(panic) when run add api after error faced to create the project #1734

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

Closed
camilamacedo86 opened this issue Jul 24, 2019 · 4 comments

Comments

@camilamacedo86
Copy link
Contributor

Bug Report

Bug

What did you do?

What did you expect to see?
A handled exception (error handled/with the msg) and/or success.

What did you see instead? Under which circumstances?

$ operator-sdk add api --api-version=app-test.example.com/v1alpha1 --kind=AppService
INFO[0000] Generating api version app-test.example.com/v1alpha1 for kind AppService. 
INFO[0000] Created pkg/apis/apptest/group.go            
INFO[0013] Created pkg/apis/apptest/v1alpha1/appservice_types.go 
INFO[0013] Created pkg/apis/addtoscheme_apptest_v1alpha1.go 
INFO[0013] Created pkg/apis/apptest/v1alpha1/register.go 
INFO[0013] Created pkg/apis/apptest/v1alpha1/doc.go     
INFO[0013] Created deploy/crds/apptest_v1alpha1_appservice_cr.yaml 
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x18e62b5]

goroutine 1 [running]:
k8s.io/gengo/parser.(*Builder).AddDirRecursive(0xc00004c7d0, 0xc000051980, 0x21, 0x2, 0x2)
	pkg/mod/k8s.io/[email protected]/parser/parse.go:229 +0xb5
sigs.k8s.io/controller-tools/pkg/crd/generator.(*Generator).Do(0xc0006e7760, 0x0, 0x0)
	pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/generator/generator.go:126 +0x3ac
github.com/operator-framework/operator-sdk/internal/pkg/scaffold.(*CRD).CustomRender(0xc0000f58c0, 0x2d12420, 0x401fc80, 0x4749430, 0xc0000f58c0, 0x1)
	src/github.com/operator-framework/operator-sdk/internal/pkg/scaffold/crd.go:102 +0x27e
github.com/operator-framework/operator-sdk/internal/pkg/scaffold.(*Scaffold).doRender(0xc0006e7cf8, 0xc000051920, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0006462e0, 0x18, ...)
	src/github.com/operator-framework/operator-sdk/internal/pkg/scaffold/scaffold.go:222 +0x16c
github.com/operator-framework/operator-sdk/internal/pkg/scaffold.(*Scaffold).doFile(0xc0006e7cf8, 0x2c97de0, 0xc0000f58c0, 0x0, 0x0)
	src/github.com/operator-framework/operator-sdk/internal/pkg/scaffold/scaffold.go:192 +0x230
github.com/operator-framework/operator-sdk/internal/pkg/scaffold.(*Scaffold).Execute(0xc0006e7cf8, 0xc0006e7c68, 0xc0006e7c98, 0x6, 0x6, 0x0, 0x0)
	src/github.com/operator-framework/operator-sdk/internal/pkg/scaffold/scaffold.go:157 +0x103
github.com/operator-framework/operator-sdk/cmd/operator-sdk/add.apiRun(0xc000173900, 0xc00015f260, 0x0, 0x2, 0x0, 0x0)
	src/github.com/operator-framework/operator-sdk/cmd/operator-sdk/add/api.go:118 +0x542
github.com/spf13/cobra.(*Command).execute(0xc000173900, 0xc00015f220, 0x2, 0x2, 0xc000173900, 0xc00015f220)
	pkg/mod/github.com/spf13/[email protected]/command.go:762 +0x465
github.com/spf13/cobra.(*Command).ExecuteC(0xc000172280, 0x2c9b2e0, 0xc000387900, 0x0)
	pkg/mod/github.com/spf13/[email protected]/command.go:852 +0x2ec
github.com/spf13/cobra.(*Command).Execute(...)
	pkg/mod/github.com/spf13/[email protected]/command.go:800
main.main()
	src/github.com/operator-framework/operator-sdk/cmd/operator-sdk/main.go:85 +0x50f
camilamacedo@Camilas-MacBook-Pro ~/go/src/github.com/test/app-test $ operator-sdk add api --api-version=app-test.example.com/v1alpha1 --kind=AppService
INFO[0000] Generating api version app-test.example.com/v1alpha1 for kind AppService. 
Error: api scaffold failed: (/Users/camilamacedo/go/src/github.com/test/app-test/pkg/apis/apptest/v1alpha1/appservice_types.go already exists)
Usage:

Environment
operator-sdk version: v0.9.0, commit: 560208d
go version: go version go1.12.7 darwin/amd64

@johananl
Copy link
Contributor

Duplicate of #1675.

@camilamacedo86 see #1675 (comment). You need to have GOROOT set. You can probably use export GOROOT=$(go env GOROOT).

@camilamacedo86
Copy link
Contributor Author

camilamacedo86 commented Jul 30, 2019

Hi @johananl,

Could we not handle this error and provide the steps suggested to fix it? IMHO it would bring a better experience for new users. wdyt?

c/c @lilic wdyt?

@johananl
Copy link
Contributor

Could we not handle this error and provide the steps suggested to fix it? IMHO it would bring a better experience for new users. wdyt?

@camilamacedo86 I agree this is not a very good UX, however I'm only a visitor and not a maintainer here so I'll leave the stage for the people who are.

FWIW, here is my take on this, in case it's useful to anyone:

Given the above, I see the following options:

  1. Fix the problem in gengo. This is probably the most "correct" approach since it seems gengo does something weird and it's better to fix the problem at its source.
  2. Bypass the error in the operator-sdk code (not sure if possible, I would need to dig deeper to understand the cause).
  3. Specify export GOROOT=/stuff as a requirement in the operator-sdk docs.

Personally I'm all for option 1, with 2 as a workaround until the fixed is merged upstream. I would use option 3 as last resort only.

@camilamacedo86
Copy link
Contributor Author

Closing as duplicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants