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

k8s operator is not being generated by controller-gen #4466

Open
geyslan opened this issue Jan 2, 2025 · 2 comments · May be fixed by #4471
Open

k8s operator is not being generated by controller-gen #4466

geyslan opened this issue Jan 2, 2025 · 2 comments · May be fixed by #4471
Assignees
Labels
Milestone

Comments

@geyslan
Copy link
Member

geyslan commented Jan 2, 2025

Description

There's a panic on Tracee's k8s operator build process.

make k8s-manifests outputs:

controller-gen rbac:roleName=tracee crd webhook paths="./pkg/k8s/..." output:crd:artifacts:config=deploy/helm/tracee/crds output:rbac:artifacts:config=deploy/helm/tracee/templates/
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=0xa0de6f]

goroutine 15 [running]:
go/types.(*Checker).handleBailout(0xc0010c2400, 0xc000cf7d40)
	/usr/local/go/src/go/types/check.go:367 +0x88
panic({0xbc7860?, 0x12b2880?})
	/usr/local/go/src/runtime/panic.go:770 +0x132
go/types.(*StdSizes).Sizeof(0x0, {0xdc3678, 0x12bb060})
	/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({0xdc3678?, 0x12bb060?})
	/usr/local/go/src/go/types/const.go:76 +0x9e
go/types.representableConst({0xdc9a50, 0x1285f60}, 0xc0010c2400, 0x12bb060, 0xc000cf74b0)
	/usr/local/go/src/go/types/const.go:92 +0x192
go/types.(*Checker).representation(0xc0010c2400, 0xc0009363c0, 0x12bb060)
	/usr/local/go/src/go/types/const.go:256 +0x65
go/types.(*Checker).implicitTypeAndValue(0xc0010c2400, 0xc0009363c0, {0xdc36a0, 0xc000036cb0})
	/usr/local/go/src/go/types/expr.go:375 +0x2d7
go/types.(*Checker).assignment(0xc0010c2400, 0xc0009363c0, {0xdc36a0, 0xc000036cb0}, {0xc95293, 0x14})
	/usr/local/go/src/go/types/assignments.go:52 +0x2e5
go/types.(*Checker).initConst(0xc0010c2400, 0xc000c6b680, 0xc0009363c0)
	/usr/local/go/src/go/types/assignments.go:126 +0x2c5
go/types.(*Checker).constDecl(0xc0010c2400, 0xc000c6b680, {0xdc62c0, 0xc00102e160}, {0xdc62c0, 0xc00102e180}, 0x0)
	/usr/local/go/src/go/types/decl.go:490 +0x311
go/types.(*Checker).objDecl(0xc0010c2400, {0xdcf1e0, 0xc000c6b680}, 0x0)
	/usr/local/go/src/go/types/decl.go:191 +0xa49
go/types.(*Checker).packageObjects(0xc0010c2400)
	/usr/local/go/src/go/types/resolver.go:693 +0x4dd
go/types.(*Checker).checkFiles(0xc0010c2400, {0xc000b5b500, 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(0xc00030d4a0, 0xc0001b22a0)
	/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/loader.go:286 +0x36a
sigs.k8s.io/controller-tools/pkg/loader.(*Package).NeedTypesInfo(0xc0001b22a0)
	/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/loader.go:99 +0x39
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check(0xc000907f50, 0xc0001b22a0)
	/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:268 +0x2b7
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check.func1(0x16?)
	/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:262 +0x53
created by sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check in goroutine 73
	/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/loader/refs.go:260 +0x1c5
make: *** [Makefile:1045: k8s-manifests] Error 2

Operator was introduced by: #3632

Output of tracee version:

main-a481d11d2

Additional details

If we bump controller-gen to latest (v0.17.0) it doesn't panic in make k8s-manifests but complains about an invalid type in make k8s-generate:

make k8s-generate 
controller-gen object:headerFile="deploy/boilerplate.go.txt" paths="./pkg/k8s/..."
github.com/aquasecurity/tracee/pkg/k8s/apis/tracee.aquasec.com/v1beta1:-: invalid type: interface{GetDefaultActions() []string; GetDescription() string; GetName() string; GetRules() []github.com/aquasecurity/tracee/pkg/k8s/apis/tracee.aquasec.com/v1beta1.Rule; GetScope() []string}
Error: not all generators ran successfully
run `controller-gen object:headerFile=deploy/boilerplate.go.txt paths=./pkg/k8s/... -w` to see all available markers, or `controller-gen object:headerFile=deploy/boilerplate.go.txt paths=./pkg/k8s/... -h` for usage
make: *** [Makefile:1049: k8s-generate] Error 1

This happens even when we checkout 01229cb which introduced the build process.

@geyslan geyslan added this to the v0.23.0 milestone Jan 2, 2025
@ShohamBit
Copy link
Collaborator

ShohamBit commented Jan 7, 2025

Could you tell me what caused this failure? @geyslan

@geyslan
Copy link
Member Author

geyslan commented Jan 7, 2025

Could you tell me what caused this failure? @geyslan

The version of the tool. It's not supported anymore... Then things went loose.

After bumping it we detected a new issue.

@geyslan geyslan linked a pull request Jan 7, 2025 that will close this issue
@geyslan geyslan self-assigned this Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants