-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Deepcopy generation fails due to "unsupported type invalid type for invalid type" #1854
Comments
I was having the same issue yesterday.
This script will blow up when running the 'generate k8s' command:
and the error:
|
@jpkrohling Are you still having this issue or did you update the branch? I checked out your branch locally and was able to run $ git remote -v
jpkrohling https://github.com/jpkrohling/jaeger-operator.git (fetch)
jpkrohling https://github.com/jpkrohling/jaeger-operator.git (push)
origin https://github.com/jaegertracing/jaeger-operator.git (fetch)
origin https://github.com/jaegertracing/jaeger-operator.git (push)
$ git branch -vv
* 607-Update-Operator-SDK-to-0.10.0 a73ec90 [jpkrohling/607-Update-Operator-SDK-to-0.10.0] Updated operator-sdk to 0.10.0
master be83935 [origin/master: behind 161] Add Elasticsearch image to CR and flag (#289)
test-openapi 9cdd514 Get rid of finalizer, clean sidecars when no jaeger instance found (#575)
$ operator-sdk version
operator-sdk version: v0.10.0, commit: ff80b17737a6a0aade663e4827e8af3ab5a21170
$ operator-sdk generate k8s
INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [io:[v1alpha1], jaegertracing:[v1], ]
INFO[0024] Code-generation complete. |
It still happens, but I just found out that it works when I'm outside of the |
That's weird. It's working fine for me inside $ echo $GOPATH
/Users/haseeb/work/go-space
$ pwd
/Users/haseeb/work/go-space/src/github.com/jaegertracing/jaeger-operator
$ GO111MODULE=on operator-sdk generate k8s
INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [io:[v1alpha1], jaegertracing:[v1], ]
INFO[0022] Code-generation complete.
$ GO111MODULE=off operator-sdk generate k8s
FATA[0000] dependency manager "modules" requires working directory to be in $GOPATH/src and GO111MODULE=on, or outside of $GOPATH/src and GO111MODULE="on", "auto", or unset. More info: https://github.com/operator-framework/operator-sdk/blob/master/doc/user-guide.md#go-modules This behavior inside $GOPATH makes me think this might be a modules related issue to #1853 and #1759. |
I'm using the binaries available under the $ operator-sdk version
operator-sdk version: v0.10.0, commit: ff80b17737a6a0aade663e4827e8af3ab5a21170
$ git st
On branch 607-Update-Operator-SDK-to-0.10.0
nothing to commit, working tree clean
$ git log -1
commit a73ec9006395578aa301c6827bafaae286b50f13 (HEAD -> 607-Update-Operator-SDK-to-0.10.0, origin/607-Update-Operator-SDK-to-0.10.0)
Author: Juraci Paixão Kröhling <[email protected]>
Date: Wed Aug 21 18:27:04 2019 +0200
Updated operator-sdk to 0.10.0
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
$ echo $GOPATH
/mnt/storage/jpkroehling/Projects
$ pwd
/home/jpkroehling/Projects/src/github.com/jaegertracing/jaeger-operator
$ GO111MODULE=on operator-sdk generate k8s
INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [jaegertracing:[v1], io:[v1alpha1], ]
F0826 09:22:48.291885 28597 deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1.ElasticsearchSpec
goroutine 1 [running]:
k8s.io/klog.stacks(0xc000860100, 0xc0002d27e0, 0xbb, 0x10b)
pkg/mod/k8s.io/[email protected]/klog.go:855 +0xb1
k8s.io/klog.(*loggingT).output(0x33f8420, 0xc000000003, 0xc0004b6540, 0x323b24c, 0xb, 0x375, 0x0)
pkg/mod/k8s.io/[email protected]/klog.go:806 +0x2d9
k8s.io/klog.(*loggingT).printf(0x33f8420, 0x3, 0x1dc88a2, 0x2a, 0xc000730e88, 0x3, 0x3)
pkg/mod/k8s.io/[email protected]/klog.go:705 +0x14e
k8s.io/klog.Fatalf(...)
pkg/mod/k8s.io/[email protected]/klog.go:1256
k8s.io/gengo/examples/deepcopy-gen/generators.(*genDeepCopy).doStruct(0xc0001f5e80, 0xc00026c420, 0xc000838cd0)
pkg/mod/k8s.io/[email protected]/examples/deepcopy-gen/generators/deepcopy.go:885 +0x7bf
k8s.io/gengo/examples/deepcopy-gen/generators.(*genDeepCopy).generateFor(0xc0001f5e80, 0xc00026c420, 0xc000838cd0)
pkg/mod/k8s.io/[email protected]/examples/deepcopy-gen/generators/deepcopy.go:695 +0xc5
k8s.io/gengo/examples/deepcopy-gen/generators.(*genDeepCopy).GenerateType(0xc0001f5e80, 0xc000812c60, 0xc00026c420, 0x209c0c0, 0xc00083d120, 0x0, 0x1d9dde4)
pkg/mod/k8s.io/[email protected]/examples/deepcopy-gen/generators/deepcopy.go:608 +0xe86
k8s.io/gengo/generator.(*Context).executeBody(0xc000812c60, 0x2098d80, 0xc00085e650, 0x2111580, 0xc0001f5e80, 0x60, 0x10)
pkg/mod/k8s.io/[email protected]/generator/execute.go:304 +0x11d
k8s.io/gengo/generator.(*Context).ExecutePackage(0xc000812a20, 0x0, 0x0, 0x20e9e00, 0xc0001f5a80, 0x0, 0x0)
pkg/mod/k8s.io/[email protected]/generator/execute.go:265 +0xbf7
k8s.io/gengo/generator.(*Context).ExecutePackages(0xc000812a20, 0x0, 0x0, 0xc0003d5910, 0x1, 0x1, 0x0, 0xc0000593b0)
pkg/mod/k8s.io/[email protected]/generator/execute.go:51 +0xc5
k8s.io/gengo/args.(*GeneratorArgs).Execute(0xc0001badc0, 0xc000731810, 0x1d6e857, 0x6, 0x1e62798, 0xc0000f77a0, 0x16)
pkg/mod/k8s.io/[email protected]/args/args.go:194 +0x2d7
github.com/operator-framework/operator-sdk/cmd/operator-sdk/internal/genutil.deepcopyGen(0xc0006449c0, 0xe, 0xc000404bc0, 0x2, 0x2, 0x18, 0xc0007319b0)
src/github.com/operator-framework/operator-sdk/cmd/operator-sdk/internal/genutil/k8s.go:94 +0x4d2
github.com/operator-framework/operator-sdk/cmd/operator-sdk/internal/genutil.K8sCodegen.func1(0xc0006449c0, 0xe, 0xc0006449c0, 0xe)
src/github.com/operator-framework/operator-sdk/cmd/operator-sdk/internal/genutil/k8s.go:53 +0x50
github.com/operator-framework/operator-sdk/cmd/operator-sdk/internal/genutil.generateWithHeaderFile(0xc000404c00, 0x0, 0x0)
src/github.com/operator-framework/operator-sdk/cmd/operator-sdk/internal/genutil/genutil.go:104 +0x178
github.com/operator-framework/operator-sdk/cmd/operator-sdk/internal/genutil.K8sCodegen(0xc000384500, 0x0)
src/github.com/operator-framework/operator-sdk/cmd/operator-sdk/internal/genutil/k8s.go:54 +0x4a5
github.com/operator-framework/operator-sdk/cmd/operator-sdk/generate.k8sFunc(0xc000384500, 0x341bfc0, 0x0, 0x0, 0x0, 0x0)
src/github.com/operator-framework/operator-sdk/cmd/operator-sdk/generate/k8s.go:56 +0x156
github.com/spf13/cobra.(*Command).execute(0xc000384500, 0x341bfc0, 0x0, 0x0, 0xc000384500, 0x341bfc0)
pkg/mod/github.com/spf13/[email protected]/command.go:762 +0x465
github.com/spf13/cobra.(*Command).ExecuteC(0xc00039c000, 0x209d6c0, 0xc0002bcd00, 0x0)
pkg/mod/github.com/spf13/[email protected]/command.go:852 +0x2ec
github.com/spf13/cobra.(*Command).Execute(...)
pkg/mod/github.com/spf13/[email protected]/command.go:800
main.main()
src/github.com/operator-framework/operator-sdk/cmd/operator-sdk/main.go:85 +0x50f |
I also tried the latest master (abac23c) and it seems that this is fixed there: $ operator-sdk version
operator-sdk version: v0.10.0-19-gabac23c8, commit: abac23c897b898e6fecfb2c02fe318843ae9347f
$ git st
On branch 607-Update-Operator-SDK-to-0.10.0
nothing to commit, working tree clean
$ git log -1
commit a73ec9006395578aa301c6827bafaae286b50f13 (HEAD -> 607-Update-Operator-SDK-to-0.10.0, origin/607-Update-Operator-SDK-to-0.10.0)
Author: Juraci Paixão Kröhling <[email protected]>
Date: Wed Aug 21 18:27:04 2019 +0200
Updated operator-sdk to 0.10.0
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
$ echo $GOPATH
/mnt/storage/jpkroehling/Projects
$ GO111MODULE=on operator-sdk generate k8s
INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [io:[v1alpha1], jaegertracing:[v1], ]
INFO[0010] Code-generation complete. I'm therefore closing this one. Do you have plans for a new release already? |
So, a fix is coming in the next release? Do we know when that will be? |
@jpkrohling I'm not convinced this is something that's fixed on My hypothesis is that building from source makes the problem go away because you end up using the same GOROOT when you build the SDK and when you run the SDK. When the build env and run env are different seems to be when these (and related) issues pop up. |
You are absolutely correct: I can reproduce the problem with the binary at 0.10.0, but not with the self-built 0.10.0. |
I hit this error when not exporting GOROOT, it worked for me after exporting that. |
Alright, I think I finally have this figured out. When the
So when using the Obviously (b) is undesirable because you have to know what GOROOT was used and then force your environment to match it, so (a) setting GOROOT explicitly seems like the best workaround.
/cc @estroz @hasbro17 @jpkrohling @mandymchu @kdwodc TL;DR: If you run into strange problems with code generation, try setting |
Wonderful, thanks for digging into this! I confirm that setting $ export GOROOT=/usr/lib/golang
$ GO111MODULE=on operator-sdk generate k8s
INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [io:[v1alpha1], jaegertracing:[v1], ]
INFO[0009] Code-generation complete.
$ unset GOROOT
$ GO111MODULE=on operator-sdk generate k8s
INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [io:[v1alpha1], jaegertracing:[v1], ]
F0827 09:05:57.950321 12347 deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1.ElasticsearchSpec
goroutine 1 [running]:
k8s.io/klog.stacks(0xc000814700, 0xc0002987e0, 0xbb, 0x10b)
pkg/mod/k8s.io/[email protected]/klog.go:855 +0xb1
k8s.io/klog.(*loggingT).output(0x33f8420, 0xc000000003, 0xc0002b1260, 0x323b24c, 0xb, 0x375, 0x0)
pkg/mod/k8s.io/[email protected]/klog.go:806 +0x2d9
k8s.io/klog.(*loggingT).printf(0x33f8420, 0x3, 0x1dc88a2, 0x2a, 0xc0006cae88, 0x3, 0x3)
pkg/mod/k8s.io/[email protected]/klog.go:705 +0x14e
k8s.io/klog.Fatalf(...)
pkg/mod/k8s.io/[email protected]/klog.go:1256
k8s.io/gengo/examples/deepcopy-gen/generators.(*genDeepCopy).doStruct(0xc000562200, 0xc000464f20, 0xc0007e3c20)
pkg/mod/k8s.io/[email protected]/examples/deepcopy-gen/generators/deepcopy.go:885 +0x7bf
k8s.io/gengo/examples/deepcopy-gen/generators.(*genDeepCopy).generateFor(0xc000562200, 0xc000464f20, 0xc0007e3c20)
pkg/mod/k8s.io/[email protected]/examples/deepcopy-gen/generators/deepcopy.go:695 +0xc5
k8s.io/gengo/examples/deepcopy-gen/generators.(*genDeepCopy).GenerateType(0xc000562200, 0xc0004f6f00, 0xc000464f20, 0x209c0c0, 0xc0007d1c40, 0x0, 0x1d9dde4)
pkg/mod/k8s.io/[email protected]/examples/deepcopy-gen/generators/deepcopy.go:608 +0xe86
k8s.io/gengo/generator.(*Context).executeBody(0xc0004f6f00, 0x2098d80, 0xc000806720, 0x2111580, 0xc000562200, 0x60, 0x10)
pkg/mod/k8s.io/[email protected]/generator/execute.go:304 +0x11d
k8s.io/gengo/generator.(*Context).ExecutePackage(0xc0004f6cc0, 0x0, 0x0, 0x20e9e00, 0xc0003a7e80, 0x0, 0x0)
pkg/mod/k8s.io/[email protected]/generator/execute.go:265 +0xbf7
k8s.io/gengo/generator.(*Context).ExecutePackages(0xc0004f6cc0, 0x0, 0x0, 0xc00044a170, 0x1, 0x1, 0x0, 0xc0005868d0)
pkg/mod/k8s.io/[email protected]/generator/execute.go:51 +0xc5
k8s.io/gengo/args.(*GeneratorArgs).Execute(0xc00049b360, 0xc0006cb810, 0x1d6e857, 0x6, 0x1e62798, 0xc00039a980, 0x16)
pkg/mod/k8s.io/[email protected]/args/args.go:194 +0x2d7
github.com/operator-framework/operator-sdk/cmd/operator-sdk/internal/genutil.deepcopyGen(0xc00057ac90, 0xe, 0xc000568fc0, 0x2, 0x2, 0x18, 0xc0006cb9b0)
src/github.com/operator-framework/operator-sdk/cmd/operator-sdk/internal/genutil/k8s.go:94 +0x4d2
github.com/operator-framework/operator-sdk/cmd/operator-sdk/internal/genutil.K8sCodegen.func1(0xc00057ac90, 0xe, 0xc00057ac90, 0xe)
src/github.com/operator-framework/operator-sdk/cmd/operator-sdk/internal/genutil/k8s.go:53 +0x50
github.com/operator-framework/operator-sdk/cmd/operator-sdk/internal/genutil.generateWithHeaderFile(0xc000569000, 0x0, 0x0)
src/github.com/operator-framework/operator-sdk/cmd/operator-sdk/internal/genutil/genutil.go:104 +0x178
github.com/operator-framework/operator-sdk/cmd/operator-sdk/internal/genutil.K8sCodegen(0xc00036c000, 0x0)
src/github.com/operator-framework/operator-sdk/cmd/operator-sdk/internal/genutil/k8s.go:54 +0x4a5
github.com/operator-framework/operator-sdk/cmd/operator-sdk/generate.k8sFunc(0xc00036c000, 0x341bfc0, 0x0, 0x0, 0x0, 0x0)
src/github.com/operator-framework/operator-sdk/cmd/operator-sdk/generate/k8s.go:56 +0x156
github.com/spf13/cobra.(*Command).execute(0xc00036c000, 0x341bfc0, 0x0, 0x0, 0xc00036c000, 0x341bfc0)
pkg/mod/github.com/spf13/[email protected]/command.go:762 +0x465
github.com/spf13/cobra.(*Command).ExecuteC(0xc000368a00, 0x209d6c0, 0xc0003ac900, 0x0)
pkg/mod/github.com/spf13/[email protected]/command.go:852 +0x2ec
github.com/spf13/cobra.(*Command).Execute(...)
pkg/mod/github.com/spf13/[email protected]/command.go:800
main.main()
src/github.com/operator-framework/operator-sdk/cmd/operator-sdk/main.go:85 +0x50f |
If you always reproduce this issue, although $ go env GOROOT
/usr/local/Cellar/go/1.12.9/libexec
$ 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/appservice1_types.go
INFO[0000] Created pkg/apis/addtoscheme_app1_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/app1_v1alpha1_appservice1_cr.yaml
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x18e8815]
goroutine 1 [running]:
k8s.io/gengo/parser.(*Builder).AddDirRecursive(0xc000560d70, 0xc0002af830, 0x2c, 0x2, 0x2)
pkg/mod/k8s.io/gengo@v0.0.0-20190327210449-e17681d19d3a/parser/parse.go:229 +0xb5
$ export GOROOT='/usr/local/Cellar/go/1.12.9/libexec'
$ operator-sdk add api --api-version=app1.example.com/v1alpha1 --kind=AppService1
INFO[0000] Generating api version app1.example.com/v1alpha1 for kind AppService1.
INFO[0000] Created pkg/apis/app1/group.go
INFO[0001] Created pkg/apis/app1/v1alpha1/appservice_types.go
INFO[0001] Created pkg/apis/addtoscheme_app_v1alpha1.go
INFO[0001] Created pkg/apis/app1/v1alpha1/register.go
INFO[0001] Created pkg/apis/app1/v1alpha1/doc.go
INFO[0001] Created deploy/crds/app_v1alpha1_appservice_cr.yaml
INFO[0007] Created deploy/crds/app_v1alpha1_appservice_crd.yaml
INFO[0007] Running deepcopy code-generation for Custom Resource group versions: [app1:[v1alpha1], ]
INFO[0013] Code-generation complete.
INFO[0013] Running OpenAPI code-generation for Custom Resource group versions: [app1:[v1alpha1], ]
INFO[0026] Created deploy/crds/app_v1alpha1_appservice_crd.yaml
INFO[0026] Code-generation complete.
INFO[0026] API generation complete. Thanks @joelanford gave the detailed answers. |
Soo I am running 0.11 + Modules and am still seeing this error. |
I have tried with 0.11.0 release of operator-sdk cli from homebrew, download using curl, built from source (needed to downgrade go version to 1.12.12 from 1.13.1 for building from source to work successfully due to #2055 ) .
have put my operator in but still getting same error. |
@himanshug There's a couple of things going on possibly.
I never went back and checked that |
@joelanford thanks for looking into it.
|
Yeah, that's definitely a problem and not supported. As I understand it, the code generator needs to know the concrete types to be able to generate the CRD schemas, and the kubernetes client needs to know what concrete types to use when decoding the API objects (e.g. when doing a GET from the API server). |
@joelanford thanks for the help. I did get everything working after various updates to my type file. that same error message happens from so many different reasons, one needs to figure out what specifically is the cause in their setup. I hope the discussion here would help future operator writers. |
If there is no GOROOT environment variable, 'operator-sdk add api' fails. see operator-framework#1854 (comment)
If there is no GOROOT environment variable, 'operator-sdk add api' fails. see operator-framework#1854 (comment)
If there is no GOROOT environment variable, 'operator-sdk add api' fails. see operator-framework#1854 (comment)
So to summarise
does the trick |
Workaround is now working. |
@abergmeier can you open another issue with your specific environment specs? Thanks. |
This is still an ongoing issue. Someone should post this on the operator-sdk install guide, as I spent atleast 30 minutes trying to figure out what was causing it. Installed go with snap package manager |
HI @Nik-Novak, This error is because of the local env which is not configured properly. I am not sure where and how to fit it in the docs. However, please feel free to raise PR with your idea/suggestion for we are able to check it. Really thank you. |
I question why setting |
HI @abergmeier, 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’t 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 I hope that it can help you with. |
Still seeing this issue on operator-sdk v0.16.0, go 1.13.8, Fedora 30.
Fixed it but like some others it stole a small part of my life that I'll never get back 😄 I've got a few other tips I've been thinking I'll add to some docs. I'll try to figure out a spot to mention this in case others fall into it. |
Without this rewrite, the old script failed with: Generating deepcopy funcs F0211 10:52:30.681397 71752 deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from github.com/kubecost/cluster-turndown/pkg/apis/turndownschedule/v1alpha1.TurndownSchedule Initially I found this issue: operator-framework/operator-sdk#1854 and tried to use the GOROOT fix, but it didn't work. I ended up getting (with set -x): $ GOROOT=/usr/bin bash generate.sh ... + bash ./vendor/k8s.io/code-generator/generate-groups.sh all github.com/kubecost/cluster-turndown/pkg/generated github.com/kubecost/cluster-turndown/pkg/apis turndownschedule:v1alpha1 --output-base . --go-header-file hack/custom-boilerplate.go.txt /home/delta/go/pkg/mod/golang.org/x/[email protected]/internal/imports/imports.go:12:2: package bufio is not in GOROOT (/usr/bin/src/bufio) /home/delta/go/pkg/mod/github.com/spf13/[email protected]/flag.go:102:2: package bytes is not in GOROOT (/usr/bin/src/bytes) ... etc. I opted to rewrite the generate.sh script in the image of the official K8s sample-controller and everything worked fine. I'm not sure if the go mod vendor trick in the old generate.sh, which purportedly got around some trouble caused when the code wasn't yet generated, will be necessary to resurrect in the future if we update the API version. I'll document this in the PR as well, so hopefully someone can find this with some spelunking if the problem arises again. After the rewrite, generation with "bash generate.sh" succeeds. WIP: I can't go build with the now-working generation.
Without this rewrite, the old script failed with: Generating deepcopy funcs F0211 10:52:30.681397 71752 deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from github.com/kubecost/cluster-turndown/pkg/apis/turndownschedule/v1alpha1.TurndownSchedule Initially I found this issue: operator-framework/operator-sdk#1854 and tried to use the GOROOT fix, but it didn't work. I ended up getting (with set -x): $ GOROOT=/usr/bin bash generate.sh ... + bash ./vendor/k8s.io/code-generator/generate-groups.sh all github.com/kubecost/cluster-turndown/pkg/generated github.com/kubecost/cluster-turndown/pkg/apis turndownschedule:v1alpha1 --output-base . --go-header-file hack/custom-boilerplate.go.txt /home/delta/go/pkg/mod/golang.org/x/[email protected]/internal/imports/imports.go:12:2: package bufio is not in GOROOT (/usr/bin/src/bufio) /home/delta/go/pkg/mod/github.com/spf13/[email protected]/flag.go:102:2: package bytes is not in GOROOT (/usr/bin/src/bytes) ... etc. I opted to rewrite the generate.sh script in the image of the official K8s sample-controller, with some additions based on the previous generate.sh described in comments. I'm not sure if the go mod vendor trick in the old generate.sh, which purportedly got around some trouble caused when the code wasn't yet generated, will be necessary to resurrect in the future if we update the API version. I'll document this in the PR as well, so hopefully someone can find this with some spelunking if the problem arises again. After the rewrite, generation with "bash generate.sh" succeeds. Go build is now failing because we need to add contexts to our K8s API calls, which is expected after the library version update. Generate code with correct imports
Without this rewrite, the old script failed with: Generating deepcopy funcs F0211 10:52:30.681397 71752 deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from github.com/kubecost/cluster-turndown/pkg/apis/turndownschedule/v1alpha1.TurndownSchedule Initially I found this issue: operator-framework/operator-sdk#1854 and tried to use the GOROOT fix, but it didn't work. I ended up getting (with set -x): $ GOROOT=/usr/bin bash generate.sh ... + bash ./vendor/k8s.io/code-generator/generate-groups.sh all github.com/kubecost/cluster-turndown/pkg/generated github.com/kubecost/cluster-turndown/pkg/apis turndownschedule:v1alpha1 --output-base . --go-header-file hack/custom-boilerplate.go.txt /home/delta/go/pkg/mod/golang.org/x/[email protected]/internal/imports/imports.go:12:2: package bufio is not in GOROOT (/usr/bin/src/bufio) /home/delta/go/pkg/mod/github.com/spf13/[email protected]/flag.go:102:2: package bytes is not in GOROOT (/usr/bin/src/bytes) ... etc. I opted to rewrite the generate.sh script in the image of the official K8s sample-controller, with some additions based on the previous generate.sh described in comments. I'm not sure if the go mod vendor trick in the old generate.sh, which purportedly got around some trouble caused when the code wasn't yet generated, will be necessary to resurrect in the future if we update the API version. I'll document this in the PR as well, so hopefully someone can find this with some spelunking if the problem arises again. After the rewrite, generation with "bash generate.sh" succeeds. Go build is now failing because we need to add contexts to our K8s API calls, which is expected after the library version update. Generate code with correct imports
Bug Report
When migrating an Operator that works with the SDK 0.8.2 to 0.10.0, the
generate k8s
command fails with a message likeHit an unsupported type invalid type for invalid type, from github.com/jaegertracing/jaeger-operator/pkg/apis/io/v1alpha1.Jaeger
. It's unclear which property has an invalid type, so, I commented out all custom types, ending up with a type like this:Even for this type, the
generate k8s
fails with the same message. The code for this can be seen on this branch: https://github.com/jpkrohling/jaeger-operator/tree/607-Update-Operator-SDK-to-0.10.0What did you do?
Clone the branch mentioned above and run:
Environment
operator-sdk version: v0.10.0, commit: ff80b17737a6a0aade663e4827e8af3ab5a21170
go version go1.12.5 linux/amd64
Additional context
Found while working on jaegertracing/jaeger-operator#607
The text was updated successfully, but these errors were encountered: