Skip to content

operator-sdk fails to add an api on brand new project #2725

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
surajssd opened this issue Mar 26, 2020 · 4 comments
Closed

operator-sdk fails to add an api on brand new project #2725

surajssd opened this issue Mar 26, 2020 · 4 comments

Comments

@surajssd
Copy link
Contributor

surajssd commented Mar 26, 2020

Bug Report

What did you do?

I was following the Quick Start guide to create a project and when add api it fails with error, Hit an unsupported type invalid type for invalid type, from ./pkg/apis/app/v1alpha1.AppService.

$ operator-sdk new app-operator --repo github.com/example-inc/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                           
INFO[0004] Project validation successful.               
INFO[0004] Project creation complete.

$ cd app-operator
/tmp/app-operator

$ 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[0000] Created pkg/apis/app/v1alpha1/appservice_types.go 
INFO[0000] Created pkg/apis/addtoscheme_app_v1alpha1.go 
INFO[0000] Created pkg/apis/app/v1alpha1/register.go    
INFO[0000] Created pkg/apis/app/v1alpha1/doc.go         
INFO[0000] Created deploy/crds/app.example.com_v1alpha1_appservice_cr.yaml 
INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [app:[v1alpha1], ] 
F0326 14:54:04.512973 3863302 deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from ./pkg/apis/app/v1alpha1.AppService

What did you see instead? Under which circumstances?

This is the error I saw in a brand new project:

$ 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[0000] Created pkg/apis/app/v1alpha1/appservice_types.go 
INFO[0000] Created pkg/apis/addtoscheme_app_v1alpha1.go 
INFO[0000] Created pkg/apis/app/v1alpha1/register.go    
INFO[0000] Created pkg/apis/app/v1alpha1/doc.go         
INFO[0000] Created deploy/crds/app.example.com_v1alpha1_appservice_cr.yaml 
INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [app:[v1alpha1], ] 
F0326 14:54:04.512973 3863302 deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from ./pkg/apis/app/v1alpha1.AppService

Environment

  • operator-sdk version:
operator-sdk version: "v0.16.0-dirty", commit: "55f1446c5f472e7d8e308dcdf36d0d7fc44fc4fd", go version: "go1.13.8 linux/amd64"

55f1446

  • go version:
go version go1.14.1 linux/amd64
  • Kubernetes version information:
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.0", GitCommit:"70132b0f130acc0bed193d9ba59dd186f0e634cf", GitTreeState:"clean", BuildDate:"2019-12-07T21:20:10Z", GoVersion:"go1.13.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.0", GitCommit:"9e991415386e4cf155a24b1da15becaa390438d8", GitTreeState:"clean", BuildDate:"2020-03-25T14:50:46Z", GoVersion:"go1.13.8", Compiler:"gc", Platform:"linux/amd64"}
  • Kubernetes cluster kind:

minikube

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

golang

@pzghost
Copy link
Contributor

pzghost commented Mar 26, 2020

Maybe the operator-sdk cann't get your GOROOT, you should set it obviously.
e.g.

[pzghost@localhost app-operator]$ echo $GOROOT

[pzghost@localhost app-operator]$ 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[0000] Created pkg/apis/app/v1alpha1/appservice_types.go 
INFO[0000] Created pkg/apis/addtoscheme_app_v1alpha1.go 
INFO[0000] Created pkg/apis/app/v1alpha1/register.go    
INFO[0000] Created pkg/apis/app/v1alpha1/doc.go         
INFO[0000] Created deploy/crds/app.example.com_v1alpha1_appservice_cr.yaml 
INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [app:[v1alpha1], ] 
F0326 17:43:26.216455   23113 deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from app-operator/pkg/apis/app/v1alpha1.AppService
[pzghost@localhost app-operator]$ rm -rf pkg/apis/
[pzghost@localhost app-operator]$ export GOROOT=/usr/local/go
[pzghost@localhost app-operator]$ 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[0000] Created pkg/apis/app/v1alpha1/appservice_types.go 
INFO[0000] Created pkg/apis/addtoscheme_app_v1alpha1.go 
INFO[0000] Created pkg/apis/app/v1alpha1/register.go    
INFO[0000] Created pkg/apis/app/v1alpha1/doc.go         
INFO[0000] Created deploy/crds/app.example.com_v1alpha1_appservice_cr.yaml 
INFO[0000] RBAC rules in deploy/role.yaml already up to date for the resource (app.example.com/v1alpha1, AppService) 
INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [app:[v1alpha1], ] 
INFO[0008] Code-generation complete.                    
INFO[0008] Running CRD generator.                       
INFO[0008] CRD generation complete.                     
INFO[0008] API generation complete.                     

@surajssd
Copy link
Contributor Author

That is my GOROOT as well:

$ go env GOROOT
/usr/local/go

If that is default why do I have to set it again?

@joelanford
Copy link
Member

This is a known issue. See #1854 (comment)

If setting GOROOT doesn't resolve this, we can re-open.

@dmvolod
Copy link
Contributor

dmvolod commented Apr 24, 2020

@joelanford I can see, that PR #2754 introduce to set GOROOT on k8s generating and create API. I tried to call
operator-sdk add api ... and it still doesn't work
DEBU[0000] Debug logging is set
INFO[0000] Generating api version cache.example.com/v1alpha1 for kind Memcached.
INFO[0000] Created pkg/apis/cache/group.go
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.example.com_v1alpha1_memcached_cr.yaml
INFO[0000] RBAC rules in deploy/role.yaml already up to date for the resource (cache.example.com/v1alpha1, Memcached)
DEBU[0000] Setting GOROOT=/usr/lib/golang
INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [cache:[v1alpha1], ]
F0427 10:46:38.017216 304094 deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from ./pkg/apis/cache/v1alpha1.Memcached

$ operator-sdk version
operator-sdk version: "v0.17.0", commit: "2fd7019f856cdb6f6618e2c3c80d15c3c79d1b6c", kubernetes version: "unknown", go version: "go1.13.10 linux/amd64"

uname -a
Linux localhost.localdomain 5.5.17-200.fc31.x86_64 #1 SMP Mon Apr 13 15:29:42 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

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

No branches or pull requests

4 participants