$ 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], ]
F0203 10:54:29.486117 5946 deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from app-operator/pkg/apis/app/v1alpha1.AppService
By @camilamacedo86 : Add info to centralized:
operator-sdk version锛歷0.15.1
go version锛歡o1.13 linux/amd64
I'm writing operator in go
Operate System锛欳entos7.2
Hi @sky-big,
Could you please provide the full information?
Environment
Insert the output ofoperator-sdk versionhereInsert the output ofgo versionhereInsert the output ofkubectl versionhereHi @camilamacedo86 ,
Environment
operator-sdk version锛歷0.15.1
go version锛歡o1.13 linux/amd64
I'm writing operator in go
This isn't even talking to kubernetes yet
Operate System锛欳entos7.2
Hi @sky-big,
Could you please let us know if you are following the quick start? Have you already change the specs of any type in the project before run this command? If yes, could you share snaps of the code?
@sky-big This is typically an issue with the fields added to your structs in _types.go files. Are there any interfaces in the hierarchy of your struct types? If so, those are the likely culprits. They will likely need to be removed or replaced with concrete implementations.
This is all I have to do, I failed in step 2, I haven't modified the *_types.go file yet @joelanford
[root@function-manager-vm-nat src]# operator-sdk new 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[0003] Project validation successful.
INFO[0003] Project creation complete.
[root@function-manager-vm-nat src]# cd app-operator/
[root@function-manager-vm-nat 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], ]
F0204 10:43:00.265834 17196 deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from app-operator/pkg/apis/app/v1alpha1.AppService
[root@function-manager-vm-nat app-operator]# operator-sdk version
operator-sdk version: "v0.15.1", commit: "e35ec7b722ba095e6438f63fafb9e7326870b486", go version: "go1.13.6 linux/amd64"
[root@function-manager-vm-nat app-operator]# go version
go version go1.13 linux/amd64
I failed the second step by following quick start @camilamacedo86
Hi @sky-big,
As @joelanford explained this error usually occurs because of wrong definitions in the _types files where you define the specs. Also, it is essential to highlight that these steps are fully tested and ensured automatically via the CI; besides, also, I am unable to reproduce your scenario manually. In this way, it shows that you have some issue with the scaffolded project and/or local env setup.
So, in order to help you with. Let's do it step by step and re-check/re-config all OK following my recommendation and suggestions.
Tips:
go env. The GOPROXY should be GOPROXY="https://proxy.golang.org,direct" as the GOROOT should point to the go installation. E.g GOROOT="/usr/local/go" )operator-sdk version to check if it is installed and its version )Recommendations:
Also, if you are Getting Started with SDK and Go projects, I'd recommend you follow up the Getting Started instead of the Quick Started since it will provide a better context and example. And then, check the blog post Getting started with Golang Operators by using Operator SDK to have a further understatement over the example done in the Getting Started guide.
Please, let us know if it makes sense and if you could solve the issue with the information provided.
@camilamacedo86 For what it's worth, I'm hitting the _exact_ same situation as @sky-big, despite following the documentation (both Quick Start and Getting Started). I'm on Ubuntu 19.10, but otherwise it's exactly as @sky-big describes.
I'm not able to reproduce this either. We've seen issues with the code generators because they can sometimes rely on some Go environment variables being set, which are not usually necessary to set in normal Go installations (see https://github.com/operator-framework/operator-sdk/issues/2426)
Can you run the following command and retry:
unset GOROOT
export GOROOT=$(go env GOROOT)
That actually worked! Thanks!
@joelanford Very good method
@joelanford I think I've got some additional information on this one that might be useful: this issue only appears on _some_ of the linux (at least) binaries on the releases page, but not all. It seems like it might depend on the environment of the developer who built the binary.
For example, if I don't have GOROOT set in my shell (even though it shows up in go env GOROOT) like you demonstrated above, I experience the issue with the following versions (not a complete list):
Notably, v0.15.0 _doesn't_ give me this behaviour, it just works. Maybe @jmccormick2001 has some magic?
Also, if I build the broken versions locally myself, they don't have the issue that the binaries on the GitHub releases page have.
I did the 1.15.0 build on a Fedora 31 host. I'll re-open this one so that we can confirm this one.
I can replicate this issue on Ubuntu 18.04 very easily. The only solution I found is setting the GOROOT as described here.
Hi @jmccormick2001,
It is caused because of an error in your local env. You need to set the go env GOROOT.
Run export GOROOT=$(go env GOROOT)
See:
The GOROOT environment variable point to the directory where the go which should be used is installed. In this way, I understand that usually, you don鈥檛 need to set $GOROOT variable. However, you may face issues in some scenarios. For example; if you have more than one go version installed locally, or if you installed it in different locally from where was recommend or if you use homebrew to install. Just to illustrate the homebrew scenario see, for example, https://coderwall.com/p/c00m1g/set-goroot-variable-with-homebre
Duplication of many:
HI as described above all shows sorted out here, so I am closing this one. However, please feel free to re-open if you see that something still required to be done regards this issue.
I am also hitting this, only setting GOROOT as described by @joelanford works.
However operator-sdk v0.13.0 works without a problem(which was the version I used before testing the v0.16.0 version).
I am also pretty sure I never set GOROOT in my environment when using the v0.13.0. So what has changed?
@loxley the most bizarre thing is that for me it was v0.15.0 that worked fine, and for you it was v0.13.0. :shrug:
I wonder if it's some similarity to the environment in which it was built -- e.g. I use Fedora 31, the same as jmccormick2001 built v0.15.0 on. Maybe your local environment is similar to that of whoever built v0.13.0?
In any case, explicitly setting GOROOT seems to be the only consistent fix.
Most helpful comment
I'm not able to reproduce this either. We've seen issues with the code generators because they can sometimes rely on some Go environment variables being set, which are not usually necessary to set in normal Go installations (see https://github.com/operator-framework/operator-sdk/issues/2426)
Can you run the following command and retry: