Closed mangelajo closed 4 years ago
More hints on the issue:
# operator-sdk generate openapi
INFO[0000] Running OpenAPI code-generation for Custom Resource group versions: [submariner:[v1alpha1], ]
E1203 12:01:56.439922 272 openapi.go:304] Error when generating: TypeMeta, TypeMeta invalid type
Error: openapi-gen generator error: Failed executing generator: some packages had errors:
cannot generate spec for type invalid type
Hi @mangelajo,
The go version compatible with SDK 0.12 is the 1.13+. Are you with the project created inside of $GOPATH? Also, what is the path of the project? It shows the same scenario of https://github.com/operator-framework/operator-sdk/issues/1854#issuecomment-525132306.
See that you need to be in the $GOPATH and the dir paths need to match with the project. E.g for https://github.com/operator-framework/operator-sdk/
the dir path needs to be $GOPATH /github.com/operator-framework/operator-sdk/
If the above information do not help you sort it out, could you share your code/project?
Thank you Camila!
I tested with go 1.13+ too, I updated the bug report,
irc: ajo / mangelajo Miguel Angel Ajo Pelayo +34 636 52 25 69 skype: ajoajoajo
On Tue, Dec 3, 2019 at 1:05 PM Camila Macedo notifications@github.com wrote:
Hi @mangelajo https://github.com/mangelajo,
The go version compatible with SDK 0.12 is the 1.13+. Are you with the project created inside of $GOPATH? Also, what is the path of the project? It shows the same scenario of #1854 (comment) https://github.com/operator-framework/operator-sdk/issues/1854#issuecomment-525132306 .
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/operator-framework/operator-sdk/issues/2288?email_source=notifications&email_token=AAI7G4TD7QMGFPTQDAH543DQWZDSFA5CNFSM4JUVQW42YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFZEXKA#issuecomment-561138600, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI7G4VAS23RZNPO7FVBNUTQWZDSFANCNFSM4JUVQW4Q .
HI @mangelajo,
Note that go do not work well with more than one version installed. So, ensure that you have locally just the 1.13+.
[root@68d43dc05cf5 submariner-operator]# echo $GOPATH /go [root@68d43dc05cf5 submariner-operator]# pwd /go/src/github.com/submariner-io/submariner-operator [root@68d43dc05cf5 submariner-operator]# echo $GOROOT
[root@68d43dc05cf5 submariner-operator]# export GOROOT=$GOPATH [root@68d43dc05cf5 submariner-operator]# operator-sdk generate k8s INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [submariner:[v1alpha1], ] INFO[0000] Code-generation complete.
This was the issue, as soon as GOROOT is set it will work.
irc: ajo / mangelajo Miguel Angel Ajo Pelayo +34 636 52 25 69 skype: ajoajoajo
On Tue, Dec 3, 2019 at 1:42 PM Camila Macedo notifications@github.com wrote:
HI @mangelajo https://github.com/mangelajo,
Note that go do not work well with more than one version installed. So, ensure that you have locally just the 1.13+.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/operator-framework/operator-sdk/issues/2288?email_source=notifications&email_token=AAI7G4W2WSIH5FC276IDDO3QWZH5DA5CNFSM4JUVQW42YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFZHVGY#issuecomment-561150619, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI7G4XA7SPZZX3J444XQ33QWZH5DANCNFSM4JUVQW4Q .
Sorry, GOROOT must be /usr/lib/golang in my case.
It has to point to the golang installation, otherwise operator-sdk generate openapi won't work.
irc: ajo / mangelajo Miguel Angel Ajo Pelayo +34 636 52 25 69 skype: ajoajoajo
On Tue, Dec 3, 2019 at 1:56 PM Miguel Angel miguelangel@ajo.es wrote:
[root@68d43dc05cf5 submariner-operator]# echo $GOPATH /go [root@68d43dc05cf5 submariner-operator]# pwd /go/src/github.com/submariner-io/submariner-operator [root@68d43dc05cf5 submariner-operator]# echo $GOROOT
[root@68d43dc05cf5 submariner-operator]# export GOROOT=$GOPATH [root@68d43dc05cf5 submariner-operator]# operator-sdk generate k8s INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [submariner:[v1alpha1], ] INFO[0000] Code-generation complete.
This was the issue, as soon as GOROOT is set it will work.
I think we may detect this condition from operator-sdk and warn the user about it. What do you think ?
irc: ajo / mangelajo Miguel Angel Ajo Pelayo +34 636 52 25 69 skype: ajoajoajo
On Tue, Dec 3, 2019 at 1:42 PM Camila Macedo notifications@github.com wrote:
HI @mangelajo https://github.com/mangelajo,
Note that go do not work well with more than one version installed. So, ensure that you have locally just the 1.13+.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/operator-framework/operator-sdk/issues/2288?email_source=notifications&email_token=AAI7G4W2WSIH5FC276IDDO3QWZH5DA5CNFSM4JUVQW42YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFZHVGY#issuecomment-561150619, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI7G4XA7SPZZX3J444XQ33QWZH5DANCNFSM4JUVQW4Q .
Hi @mangelajo,
I am not sure if I understood. Could you fix the local env with the info informed and see it worked or not?
Hi @mangelajo,
I cloned your project locally to check it. See that I am running inside of the GOPATH and with the same path/dir of your project and all worked fine.
Create dir and clone project
camilamacedo@Camilas-MacBook-Pro ~/go/src/github.com $ mkdir submariner-io
camilamacedo@Camilas-MacBook-Pro ~/go/src/github.com $ cd submariner-io/
camilamacedo@Camilas-MacBook-Pro ~/go/src/github.com/submariner-io $ git clone git@github.com:submariner-io/submariner-operator.git
Cloning into 'submariner-operator'...
remote: Enumerating objects: 42, done.
remote: Counting objects: 100% (42/42), done.
remote: Compressing objects: 100% (35/35), done.
remote: Total 616 (delta 13), reused 18 (delta 7), pack-reused 574
Receiving objects: 100% (616/616), 220.91 KiB | 1.10 MiB/s, done.
Resolving deltas: 100% (302/302), done.
Go inside and running sdk gen commands
camilamacedo@Camilas-MacBook-Pro ~/go/src/github.com/submariner-io $ cd submariner-operator/
camilamacedo@Camilas-MacBook-Pro ~/go/src/github.com/submariner-io/submariner-operator (master) $ operator-sdk generate k8s
INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [submariner:[v1alpha1], ]
INFO[0014] Code-generation complete.
camilamacedo@Camilas-MacBook-Pro ~/go/src/github.com/submariner-io/submariner-operator (master) $ operator-sdk generate openapi
INFO[0000] Running OpenAPI code-generation for Custom Resource group versions: [submariner:[v1alpha1], ]
INFO[0007] Created deploy/crds/submariner.io_submariners_crd.yaml
INFO[0007] Code-generation complete.
camilamacedo@Camilas-MacBook-Pro ~/go/src/github.com/submariner-io/submariner-operator
My go env
(master) $ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/camilamacedo/Library/Caches/go-build"
GOENV="/Users/camilamacedo/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/camilamacedo/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/camilamacedo/go/src/github.com/submariner-io/submariner-operator/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/r_/ym6yn3cd0q3fm5jcgcwvj4z00000gn/T/go-build134513003=/tmp/go-build -gno-record-gcc-switches -fno-common"
camilamacedo@Camilas-MacBook-Pro ~/go/src/github.com/submariner-io/submariner-operator (master) $
Please, let us know if you are ok to close this one or has anything else that you are expecting here.
Let me close this one.
I want to open a new one for better "no GOROOT" handling in some situations where the error message is left to the underlying generators and is very obscure.
I am still hitting this exact issue:
$ pwd
/home/mbooth/go/src/github.com/openstack-k8s-operators
$ operator-sdk new foo --verbose
DEBU[0000] Debug logging is set
INFO[0000] Creating new Go operator 'foo'.
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
DEBU[0000] Running []string{"go", "build", "./..."}
INFO[0002] Project validation successful.
INFO[0002] Project creation complete.
$ cd foo
$ operator-sdk add api --api-version=foo.example.com/v1alpha1 --kind=Foo --verbose
DEBU[0000] Debug logging is set
INFO[0000] Generating api version foo.example.com/v1alpha1 for kind Foo.
INFO[0000] Created pkg/apis/foo/group.go
INFO[0000] Created pkg/apis/foo/v1alpha1/foo_types.go
INFO[0000] Created pkg/apis/addtoscheme_foo_v1alpha1.go
INFO[0000] Created pkg/apis/foo/v1alpha1/register.go
INFO[0000] Created pkg/apis/foo/v1alpha1/doc.go
INFO[0000] Created deploy/crds/foo.example.com_v1alpha1_foo_cr.yaml
DEBU[0000] Setting GOROOT=/usr/lib/golang
INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [foo:[v1alpha1], ]
F0506 12:04:45.607871 10761 deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from github.com/openstack-k8s-operators/foo/pkg/apis/foo/v1alpha1.Foo
My environment:
$ go version
go version go1.13.10 linux/amd64
$ operator-sdk version
operator-sdk version: "v0.17.0", commit: "2fd7019f856cdb6f6618e2c3c80d15c3c79d1b6c", kubernetes version: "unknown", go version: "go1.13.10 linux/amd64"
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/mbooth/.cache/go-build"
GOENV="/home/mbooth/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/mbooth/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/usr/lib/golang"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build274026007=/tmp/go-build -gno-record-gcc-switches"
I know this is an old one, but it's one of the first results that pops up when I'm googling this error.
I was getting this caused by GVM in my environment. For whatever reason it isn't setting the env vars per terminal session.
Running gvm use [whatever version]
re-exports the correct env vars, so running that command (even if it's the same version) seemed to solve the issue for me.
Like my fellow commenter above, posting my fix which was to set $GOROOT to the directory containing my go installation.
E.g. for a go installation at /usr/local/Cellar/go/1.16.4/libexec/bin/go
I ran export GOROOT=/usr/local/Cellar/go/1.16.4/libexec/
Fixed pull from here: https://github.com/operator-framework/operator-sdk/issues/1854#issuecomment-525132306
In my case an upgrade helped - v0.20.2
-> v0.25.3
Bug Report
What did you do?
What did you expect to see? Working add api
What did you see instead? Under which circumstances?
Environment
operator-sdk version: 0.12.0
go version:
and same result with:
Are you writing your operator in ansible, helm, or go? go