Skip to content
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

make run doesn't work with go 1.22 or 1.21 and go1.20 is also breaking due to incompatible directive in go.mod #754

Closed
acmenezes opened this issue Apr 12, 2024 · 3 comments · Fixed by #751

Comments

@acmenezes
Copy link
Contributor

How to reproduce the problem:
Just run make run in both Linux amd64 and MacOs platforms.
Tested golang versions 1.22.1, 1.21.9 and 1.20.0.

Apparently controller-gen 0.12.0 is not compatible with go1.22 or 1.21 versions and produce the following output when called manually or from the make run target from the main Makefile:

make run
(re)installing /home/alex/go/bin/controller-gen-v0.12.0
/home/alex/go/bin/controller-gen-v0.12.0 rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xa076ef]

goroutine 187 [running]:
go/types.(*Checker).handleBailout(0xc0001f4a00, 0xc00129bd40)
	/usr/local/go/src/go/types/check.go:367 +0x88
panic({0xbc0300?, 0x12a4920?})
	/usr/local/go/src/runtime/panic.go:770 +0x132
go/types.(*StdSizes).Sizeof(0x0, {0xdba038, 0x12ad0c0})
	/usr/local/go/src/go/types/sizes.go:228 +0x30f
go/types.(*Config).sizeof(...)
	/usr/local/go/src/go/types/sizes.go:333
go/types.representableConst.func1({0xdba038?, 0x12ad0c0?})
	/usr/local/go/src/go/types/const.go:76 +0x9e
go/types.representableConst({0xdc0350, 0x1279240}, 0xc0001f4a00, 0x12ad0c0, 0xc00129b4b0)
	/usr/local/go/src/go/types/const.go:92 +0x192
go/types.(*Checker).representation(0xc0001f4a00, 0xc000918dc0, 0x12ad0c0)
	/usr/local/go/src/go/types/const.go:256 +0x65
go/types.(*Checker).implicitTypeAndValue(0xc0001f4a00, 0xc000918dc0, {0xdba060, 0xc00024ce00})
	/usr/local/go/src/go/types/expr.go:375 +0x2d7
go/types.(*Checker).assignment(0xc0001f4a00, 0xc000918dc0, {0xdba060, 0xc00024ce00}, {0xc8cfca, 0x14})
	/usr/local/go/src/go/types/assignments.go:52 +0x2e5
go/types.(*Checker).initConst(0xc0001f4a00, 0xc001276180, 0xc000918dc0)
	/usr/local/go/src/go/types/assignments.go:126 +0x2c5
go/types.(*Checker).constDecl(0xc0001f4a00, 0xc001276180, {0xdbcc20, 0xc001480de0}, {0xdbcc20, 0xc001480e00}, 0x0)
	/usr/local/go/src/go/types/decl.go:490 +0x311
go/types.(*Checker).objDecl(0xc0001f4a00, {0xdc5ae0, 0xc001276180}, 0x0)
	/usr/local/go/src/go/types/decl.go:191 +0xa49
go/types.(*Checker).packageObjects(0xc0001f4a00)
	/usr/local/go/src/go/types/resolver.go:693 +0x4dd
go/types.(*Checker).checkFiles(0xc0001f4a00, {0xc0009c37a0, 0x5, 0x5})
	/usr/local/go/src/go/types/check.go:408 +0x1a5
go/types.(*Checker).Files(...)
	/usr/local/go/src/go/types/check.go:372
sigs.k8s.io/controller-tools/pkg/loader.(*loader).typeCheck(0xc00027b440, 0xc000bcd8e0)
	/home/alex/go/pkg/mod/sigs.k8s.io/controller-tools@v0.12.0/pkg/loader/loader.go:286 +0x36a
sigs.k8s.io/controller-tools/pkg/loader.(*Package).NeedTypesInfo(0xc000bcd8e0)
	/home/alex/go/pkg/mod/sigs.k8s.io/controller-tools@v0.12.0/pkg/loader/loader.go:99 +0x39
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check(0xc000b93560, 0xc000bcd8e0)
	/home/alex/go/pkg/mod/sigs.k8s.io/controller-tools@v0.12.0/pkg/loader/refs.go:268 +0x2b7
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check.func1(0x5d?)
	/home/alex/go/pkg/mod/sigs.k8s.io/controller-tools@v0.12.0/pkg/loader/refs.go:262 +0x53
created by sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check in goroutine 166
	/home/alex/go/pkg/mod/sigs.k8s.io/controller-tools@v0.12.0/pkg/loader/refs.go:260 +0x1c5
make: *** [Makefile:91: manifests] Error 2

On version 1.20.14 make run also breaks due to unknown golang directive in go.mod file toolchain:

<...>
/home/alex/projects/github.com/acmenezes/operator-controller/go.mod:5: unknown directive: toolchain
go: errors parsing go.mod:
/home/alex/projects/github.com/acmenezes/operator-controller/go.mod:5: unknown directive: toolchain
Error: load packages in root "/home/alex/projects/github.com/acmenezes/operator-controller": err: exit status 1: stderr: go: errors parsing go.mod:
/home/alex/projects/github.com/acmenezes/operator-controller/go.mod:5: unknown directive: toolchain

Suggested solution: Update controller-tools to v0.14.0 and go version at least to 1.21

@acmenezes
Copy link
Contributor Author

acmenezes commented Apr 12, 2024

A PR is opened for this one here #751

@tmshort
Copy link
Contributor

tmshort commented Apr 15, 2024

I'm not seeing this issue on Fedora 39/go 1.21.8/1.21.9? Could this be an issue in your environment?

@acmenezes
Copy link
Contributor Author

I have Fedora 39 but also saw the problem on MacOS. With pr #751 merged it's no longer an issue. Thanks!

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

Successfully merging a pull request may close this issue.

2 participants