Skip to content

'add api' panics due to null pointer #1853

Closed
@jpkrohling

Description

@jpkrohling

Bug Report

Running a simple add api command panics due to a null pointer.

What did you do?

$ GO111MODULE=on operator-sdk new app-operator 
INFO[0000] Creating new Go operator 'app-operator'.     
INFO[0000] Created go.mod                               
INFO[0000] Created tools.go                             
INFO[0000] Created cmd/manager/main.go                  
INFO[0000] Created build/Dockerfile                     
INFO[0000] Created build/bin/entrypoint                 
INFO[0000] Created build/bin/user_setup                 
INFO[0000] Created deploy/service_account.yaml          
INFO[0000] Created deploy/role.yaml                     
INFO[0000] Created deploy/role_binding.yaml             
INFO[0000] Created deploy/operator.yaml                 
INFO[0000] Created pkg/apis/apis.go                     
INFO[0000] Created pkg/controller/controller.go         
INFO[0000] Created version/version.go                   
INFO[0000] Created .gitignore                           
INFO[0000] Validating project                           
go: finding github.com/operator-framework/operator-sdk master
INFO[0004] Project validation successful.               
INFO[0004] Project creation complete.                   
$ cd app-operator/
$ GO111MODULE=on operator-sdk add api --api-version=jaegertracing.io/v1 --kind=Jaeger
INFO[0000] Generating api version jaegertracing.io/v1 for kind Jaeger. 
INFO[0000] Created pkg/apis/jaegertracing/group.go      
INFO[0001] Created pkg/apis/jaegertracing/v1/jaeger_types.go 
INFO[0002] Created pkg/apis/addtoscheme_jaegertracing_v1.go 
INFO[0002] Created pkg/apis/jaegertracing/v1/register.go 
INFO[0002] Created pkg/apis/jaegertracing/v1/doc.go     
INFO[0002] Created deploy/crds/jaegertracing_v1_jaeger_cr.yaml 
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xce8d55]

goroutine 1 [running]:
k8s.io/gengo/parser.(*Builder).AddDirRecursive(0xc0020ea230, 0xc001082990, 0x2b, 0x2, 0x2)
	pkg/mod/k8s.io/[email protected]/parser/parse.go:229 +0xb5
sigs.k8s.io/controller-tools/pkg/crd/generator.(*Generator).Do(0xc001707760, 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(0xc0005866e0, 0x2114500, 0x341bfc0, 0x7ffb9db12f00, 0xc0005866e0, 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(0xc001707cf8, 0xc0010828d0, 0x2c, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc000058b40, 0x22, ...)
	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(0xc001707cf8, 0x209a2a0, 0xc0005866e0, 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(0xc001707cf8, 0xc0006d9c68, 0xc001707c98, 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(0xc000556280, 0xc0003d6e20, 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(0xc000556280, 0xc0003d6da0, 0x2, 0x2, 0xc000556280, 0xc0003d6da0)
	pkg/mod/github.com/spf13/[email protected]/command.go:762 +0x465
github.com/spf13/cobra.(*Command).ExecuteC(0xc000389680, 0x209d6c0, 0xc0003dc800, 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

Environment

  • operator-sdk version: operator-sdk version: v0.10.0, commit: ff80b17737a6a0aade663e4827e8af3ab5a21170
  • go version: go version go1.12.5 linux/amd64

Found while working on jaegertracing/jaeger-operator#607

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions