operator-framework / operator-sdk

SDK for building Kubernetes applications. Provides high level APIs, useful abstractions, and project scaffolding.
https://sdk.operatorframework.io
Apache License 2.0
7.23k stars 1.75k forks source link

Error running operator-sdk generate k8s release v0.13.0 #2318

Closed cpanato closed 4 years ago

cpanato commented 4 years ago

Bug Report

Hello, I've updated our operator to release 0.13.0 and when running the command operator-sdk generate k8s i got an error that not happen if i use the latest master

Using 0.13.0

$ build/operator-sdk version
operator-sdk version: "v0.13.0", commit: "1af9c95bb51420c55a7f7f2b7fabebda24451276", go version: "go1.13.3 darwin/amd64"

$ build/operator-sdk generate k8s
INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [mattermost:[v1alpha1], ]
F1211 12:26:41.873891   57807 deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from github.com/mattermost/mattermost-operator/pkg/apis/mattermost/v1alpha1.ClusterInstallation

Using master

$ operator-sdk version
operator-sdk version: "v0.13.0-1-gcea92d5b", commit: "cea92d5be4cf1ed7ca1ffca3834fb5ee54093808", go version: "go1.13.3 darwin/amd64"

$ operator-sdk generate k8s
INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [mattermost:[v1alpha1], ]
INFO[0011] Code-generation complete.

any ideas? thanks!

camilamacedo86 commented 4 years ago

Hi @cpanato,

It is strange since current the master and 0.13 are quite similar. Wdyt about remove the sdk binary from the $GOPATH/bin and clean your local go env as here and then, install the 0.13 to check it again?

If the issue is faced, could you provide a link for your project? Is it public?

cpanato commented 4 years ago

Hello @camilamacedo86 thanks for your reply

I'm trying from a clean env, and I don't see the error anymore, maybe it was because I converted to go mod and maybe some miss-match versions. will figure out thanks and sorry for the popcorn

camilamacedo86 commented 4 years ago

Really tks for your reply @cpanato. I am closing this one since shows sort out. However, please feel free to re-open if you see that it still required.

cpanato commented 4 years ago

@camilamacedo86 looks like not, I created a new project did the following

➜ operator-sdk new app-operator --repo github.com/cpanato/temp-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
INFO[0033] Project validation successful.
INFO[0033] Project creation complete.

Then added the api

operator-sdk add api --api-version=app.example.com/v1alpha1 --kind=AppService
INFO[0000] Generating api version app.example.com/v1alpha1 for kind AppService.
INFO[0000] Created pkg/apis/app/group.go
INFO[0010] Created pkg/apis/app/v1alpha1/appservice_types.go
INFO[0010] Created pkg/apis/addtoscheme_app_v1alpha1.go
INFO[0010] Created pkg/apis/app/v1alpha1/register.go
INFO[0010] Created pkg/apis/app/v1alpha1/doc.go
INFO[0010] Created deploy/crds/app.example.com_v1alpha1_appservice_cr.yaml
INFO[0012] Created deploy/crds/app.example.com_appservices_crd.yaml
INFO[0012] Running deepcopy code-generation for Custom Resource group versions: [app:[v1alpha1], ]
F1212 10:38:10.594451   50621 deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from github.com/cpanato/temp-operator/app-operator/pkg/apis/app/v1alpha1.AppService

got the error tried to run again the generate

operator-sdk generate k8s
INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [app:[v1alpha1], ]
F1212 10:38:22.122227   50875 deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from github.com/cpanato/temp-operator/app-operator/pkg/apis/app/v1alpha1.AppService

my go env

➜ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/cpanato/Library/Caches/go-build"
GOENV="/Users/cpanato/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/cpanato/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13.4/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/cpanato/go/src/github.com/cpanato/app-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/f9/ndb5x9v95j52fbm14pp2pty80000gn/T/go-build189038489=/tmp/go-build -gno-record-gcc-switches -fno-common"

go version: go version go1.13.4 darwin/amd64 sdk version: operator-sdk version: "v0.13.0", commit: "1af9c95bb51420c55a7f7f2b7fabebda24451276", go version: "go1.13.3 darwin/amd64"

cpanato commented 4 years ago

@camilamacedo86 i've reopening since the error still persists, in a new operator scaffolding

cpanato commented 4 years ago

should i open another issue?

camilamacedo86 commented 4 years ago

Hi @cpanato,

If you pass the repo it needs to be compatible with the path and name of your operator. Could you try to do the same without --repo github.com/cpanato/temp-operator OR follow up exactly the steps of https://github.com/operator-framework/operator-sdk#create-and-deploy-an-app-operator ?

cpanato commented 4 years ago

@camilamacedo86 same error.

however if i explict export export GOROOT='/usr/local/Cellar/go/1.13.4/libexec'

and run the generate k8s it works

➜ export GOROOT='/usr/local/Cellar/go/1.13.4/libexec'
➜ operator-sdk generate k8s
INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [app:[v1alpha1], ]
INFO[0009] Code-generation complete.

if unset

➜ unset GOROOT
➜ operator-sdk generate k8s
INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [app:[v1alpha1], ]
F1212 10:54:55.322127   61999 deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from github.com/cpanato/temp-operator/app-operator/pkg/apis/app/v1alpha1.AppService
camilamacedo86 commented 4 years ago

So, the root cause of your issue is that your GOROOT is not set up properly. I'd recommend you check if you have more than one go version installed locally and remove them. Keep just the version used.

Also, I think that if you are installing go as described in its docs. If I remember correctly, shows that the brew install formula is not working well with the latest go version.

I am closing this one now. Please, feel free to re-open if you think that still required.

cpanato commented 4 years ago

thanks @camilamacedo86