Skip to content

Fails with "deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from" out of the box #2288

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
mangelajo opened this issue Dec 3, 2019 · 13 comments
Assignees
Labels
triage/support Indicates an issue that is a support question.

Comments

@mangelajo
Copy link

mangelajo commented Dec 3, 2019

Bug Report

What did you do?

operator-sdk new submariner-operator
cd submariner-operator/
operator-sdk add api --api-version=submariner.io/v1alpha1 --kind=Submariner

What did you expect to see?
Working add api

What did you see instead? Under which circumstances?

F1203 10:14:34.573020    3109 deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from github.com/submariner-io/submariner-operator/pkg/apis/submariner/v1alpha1.Submariner
goroutine 1 [running]:
k8s.io/klog.stacks(0xc000d13e00, 0xc000a0f0e0, 0xc1, 0x111)
        /home/joe/go/pkg/mod/k8s.io/[email protected]/klog.go:855 +0xb8
k8s.io/klog.(*loggingT).output(0x335c940, 0xc000000003, 0xc000270c40, 0x3146640, 0xb, 0x375, 0x0)
        /home/joe/go/pkg/mod/k8s.io/[email protected]/klog.go:806 +0x351
k8s.io/klog.(*loggingT).printf(0x335c940, 0x3, 0x1ee9b04, 0x2a, 0xc001154d18, 0x3, 0x3)
        /home/joe/go/pkg/mod/k8s.io/[email protected]/klog.go:705 +0x14b
k8s.io/klog.Fatalf(...)
        /home/joe/go/pkg/mod/k8s.io/[email protected]/klog.go:1256
k8s.io/gengo/examples/deepcopy-gen/generators.(*genDeepCopy).doStruct(0xc000cb0800, 0xc0000ebef0, 0xc00074e6e0)
        /home/joe/go/pkg/mod/k8s.io/[email protected]/examples/deepcopy-gen/generators/deepcopy.go:885 +0x7bd
k8s.io/gengo/examples/deepcopy-gen/generators.(*genDeepCopy).generateFor(0xc000cb0800, 0xc0000ebef0, 0xc00074e6e0)
        /home/joe/go/pkg/mod/k8s.io/[email protected]/examples/deepcopy-gen/generators/deepcopy.go:695 +0xc5
k8s.io/gengo/examples/deepcopy-gen/generators.(*genDeepCopy).GenerateType(0xc000cb0800, 0xc0002709a0, 0xc0000ebef0, 0x21b7320, 0xc000e9ffa0, 0x0, 0x1eb9e33)
        /home/joe/go/pkg/mod/k8s.io/[email protected]/examples/deepcopy-gen/generators/deepcopy.go:608 +0xe98
k8s.io/gengo/generator.(*Context).executeBody(0xc0002709a0, 0x21b42a0, 0xc000934750, 0x222f9c0, 0xc000cb0800, 0x60, 0xc0011550c8)

Environment

  • operator-sdk version: 0.12.0
# operator-sdk version
operator-sdk version: "v0.12.0", commit: "2445fcda834ca4b7cf0d6c38fba6317fb219b469", go version: "go1.13.3 linux/amd64"
  • go version:
# go version 
go version go1.13.4 linux/amd64

and same result with:

[root@00ed05ef611d submariner-operator]# go version
go version go1.12.13 linux/amd64
  • Are you writing your operator in ansible, helm, or go?
    go
@mangelajo mangelajo changed the title Fails with "" out of the box Fails with "deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from" out of the box Dec 3, 2019
@mangelajo
Copy link
Author

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

@camilamacedo86
Copy link
Contributor

camilamacedo86 commented Dec 3, 2019

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 #1854 (comment).

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?

@camilamacedo86 camilamacedo86 added the triage/support Indicates an issue that is a support question. label Dec 3, 2019
@camilamacedo86 camilamacedo86 self-assigned this Dec 3, 2019
@mangelajo
Copy link
Author

mangelajo commented Dec 3, 2019 via email

@camilamacedo86
Copy link
Contributor

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+.

@mangelajo
Copy link
Author

mangelajo commented Dec 3, 2019 via email

@mangelajo
Copy link
Author

mangelajo commented Dec 3, 2019 via email

@camilamacedo86
Copy link
Contributor

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?

@camilamacedo86
Copy link
Contributor

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 [email protected]: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.

@mangelajo
Copy link
Author

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.

@mdbooth
Copy link

mdbooth commented May 6, 2020

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"

@iamkirkbater
Copy link

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.

@jdheyburn
Copy link

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: #1854 (comment)

@keskad
Copy link

keskad commented Oct 27, 2022

In my case an upgrade helped - v0.20.2 -> v0.25.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage/support Indicates an issue that is a support question.
Projects
None yet
Development

No branches or pull requests

6 participants