Skip to content

Invalid memory adding api following guide #1423

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
lynic opened this issue May 14, 2019 · 1 comment · Fixed by #1432
Closed

Invalid memory adding api following guide #1423

lynic opened this issue May 14, 2019 · 1 comment · Fixed by #1432
Assignees

Comments

@lynic
Copy link

lynic commented May 14, 2019

Bug Report

What did you do?
I following the guide to add memcache-operator API, but got invalid memory error:

elynn@deepin:~/Documents/source/go/src/memcached-operator$ go version
go version go1.12 linux/amd64
elynn@deepin:~/Documents/source/go/src/memcached-operator$ operator-sdk add api --api-version=cache.example.com/v1alpha1 --kind=Memcached
INFO[0000] Generating api version cache.example.com/v1alpha1 for kind Memcached. 
INFO[0000] Created pkg/apis/cache/v1alpha1/memcached_types.go 
INFO[0000] Created pkg/apis/addtoscheme_cache_v1alpha1.go 
INFO[0000] Created pkg/apis/cache/v1alpha1/register.go  
INFO[0000] Created pkg/apis/cache/v1alpha1/doc.go       
INFO[0000] Created deploy/crds/cache_v1alpha1_memcached_cr.yaml 
W0514 18:15:18.679125   15033 parse.go:224] Ignoring directory memcached-operator/pkg/apis: unable to import "memcached-operator/pkg/apis": go/build: importGo memcached-operator/pkg/apis: exit status 1
can't load package: package memcached-operator/pkg/apis: unknown import path "memcached-operator/pkg/apis": cannot find module providing package memcached-operator/pkg/apis

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0xb5a1f5]

goroutine 1 [running]:
github.com/operator-framework/operator-sdk/vendor/k8s.io/gengo/parser.(*Builder).AddDirRecursive(0xc0000ccaa0, 0xc000587300, 0x1b, 0x2, 0x2)
	src/github.com/operator-framework/operator-sdk/vendor/k8s.io/gengo/parser/parse.go:229 +0xb5
github.com/operator-framework/operator-sdk/vendor/sigs.k8s.io/controller-tools/pkg/crd/generator.(*Generator).Do(0xc000901760, 0x0, 0x0)
	src/github.com/operator-framework/operator-sdk/vendor/sigs.k8s.io/controller-tools/pkg/crd/generator/generator.go:126 +0x3ac
github.com/operator-framework/operator-sdk/internal/pkg/scaffold.(*CRD).CustomRender(0xc0001f1ad0, 0x20c2ae0, 0x35cbb48, 0x7f565cbd9918, 0xc0001f1ad0, 0x1)
	src/github.com/operator-framework/operator-sdk/internal/pkg/scaffold/crd.go:122 +0x868
github.com/operator-framework/operator-sdk/internal/pkg/scaffold.(*Scaffold).doRender(0xc000901cf8, 0xc000eebb60, 0x2d, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0007b3a80, 0x12, ...)
	src/github.com/operator-framework/operator-sdk/internal/pkg/scaffold/scaffold.go:228 +0x16c
github.com/operator-framework/operator-sdk/internal/pkg/scaffold.(*Scaffold).doFile(0xc000901cf8, 0x20479e0, 0xc0001f1ad0, 0x0, 0x0)
	src/github.com/operator-framework/operator-sdk/internal/pkg/scaffold/scaffold.go:198 +0x227
github.com/operator-framework/operator-sdk/internal/pkg/scaffold.(*Scaffold).Execute(0xc000901cf8, 0xc0005d9c68, 0xc000901c98, 0x6, 0x6, 0x0, 0x0)
	src/github.com/operator-framework/operator-sdk/internal/pkg/scaffold/scaffold.go:163 +0x103
github.com/operator-framework/operator-sdk/cmd/operator-sdk/add.apiRun(0xc000336780, 0xc0000b4860, 0x0, 0x2, 0x0, 0x0)
	src/github.com/operator-framework/operator-sdk/cmd/operator-sdk/add/api.go:107 +0x4d2
github.com/operator-framework/operator-sdk/vendor/github.com/spf13/cobra.(*Command).execute(0xc000336780, 0xc0000b4820, 0x2, 0x2, 0xc000336780, 0xc0000b4820)
	src/github.com/operator-framework/operator-sdk/vendor/github.com/spf13/cobra/command.go:762 +0x465
github.com/operator-framework/operator-sdk/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc000336000, 0x204bd80, 0xc00035d000, 0x0)
	src/github.com/operator-framework/operator-sdk/vendor/github.com/spf13/cobra/command.go:852 +0x2c0
github.com/operator-framework/operator-sdk/vendor/github.com/spf13/cobra.(*Command).Execute(...)
	src/github.com/operator-framework/operator-sdk/vendor/github.com/spf13/cobra/command.go:800
main.main()
	src/github.com/operator-framework/operator-sdk/cmd/operator-sdk/main.go:82 +0x4f7

What did you expect to see?
I pass without error

What did you see instead? Under which circumstances?
I use the operator-sdk master brach and make install to build and install.

Environment

  • operator-sdk version:
elynn@deepin:~/Documents/source/go/src/memcached-operator$ operator-sdk version
operator-sdk version: v0.7.0+git
  • go version:
    1.12
  • Kubernetes version information:
  • Kubernetes cluster kind:

  • Are you writing your operator in ansible, helm, or go?
    go

Possible Solution

Additional context
Add any other context about the problem here.

@joelanford
Copy link
Member

@lynic Thanks for reporting this issue. I think you may have found a bug in the way we determine the module path in go.mod. You can fix it yourself by editing the first line of your go.mod to be module memcached-operator, or you can recreate the project in a subdirectory within $GOPATH (e.g. $GOPATH/src/github.com/lynic/memcached-operator)

In the meantime, I'll submit a PR that fixes the bug in operator-sdk.

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