wildfly / wildfly-operator

Kubernetes Operator for WildFly
http://docs.wildfly.org/wildfly-operator/
Apache License 2.0
32 stars 39 forks source link

Unable to use go 1.22 for make #308

Closed mchoma closed 2 months ago

mchoma commented 2 months ago

With go 1.22 I am experiencing this kind of error.

make deploy IMG=quay.io/wildfly/wildfly-operator:latest
mkdir -p /tmp/tmp.HBmVQCg4i9/wildfly-operator/bin
test -s /tmp/tmp.HBmVQCg4i9/wildfly-operator/bin/controller-gen && /tmp/tmp.HBmVQCg4i9/wildfly-operator/bin/controller-gen --version | grep -q v0.10.0 || \
GOBIN=/tmp/tmp.HBmVQCg4i9/wildfly-operator/bin go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.10.0
/tmp/tmp.HBmVQCg4i9/wildfly-operator/bin/controller-gen 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=0xa048cf]

goroutine 74 [running]:
go/types.(*Checker).handleBailout(0xc000474c00, 0xc001bb3d40)
    /usr/lib/golang/src/go/types/check.go:367 +0x88
panic({0xbbb980?, 0x129bce0?})
    /usr/lib/golang/src/runtime/panic.go:770 +0x132
go/types.(*StdSizes).Sizeof(0x0, {0xdb0c58, 0x12a4440})
    /usr/lib/golang/src/go/types/sizes.go:228 +0x30f
go/types.(*Config).sizeof(...)
    /usr/lib/golang/src/go/types/sizes.go:333
go/types.representableConst.func1({0xdb0c58?, 0x12a4440?})
    /usr/lib/golang/src/go/types/const.go:76 +0x9e
go/types.representableConst({0xdb6ef8, 0x12705a0}, 0xc000474c00, 0x12a4440, 0xc001bb34b0)
    /usr/lib/golang/src/go/types/const.go:92 +0x192
go/types.(*Checker).representation(0xc000474c00, 0xc00196b880, 0x12a4440)
    /usr/lib/golang/src/go/types/const.go:256 +0x65
go/types.(*Checker).implicitTypeAndValue(0xc000474c00, 0xc00196b880, {0xdb0c80, 0xc000330620})
    /usr/lib/golang/src/go/types/expr.go:375 +0x2d7
go/types.(*Checker).assignment(0xc000474c00, 0xc00196b880, {0xdb0c80, 0xc000330620}, {0xc883b9, 0x14})
    /usr/lib/golang/src/go/types/assignments.go:52 +0x2e5
go/types.(*Checker).initConst(0xc000474c00, 0xc00210e9c0, 0xc00196b880)
    /usr/lib/golang/src/go/types/assignments.go:126 +0x2c5
go/types.(*Checker).constDecl(0xc000474c00, 0xc00210e9c0, {0xdb3828, 0xc001a52160}, {0xdb3828, 0xc001a52180}, 0x0)
    /usr/lib/golang/src/go/types/decl.go:490 +0x311
go/types.(*Checker).objDecl(0xc000474c00, {0xdbc6e0, 0xc00210e9c0}, 0x0)
    /usr/lib/golang/src/go/types/decl.go:191 +0xa49
go/types.(*Checker).packageObjects(0xc000474c00)
    /usr/lib/golang/src/go/types/resolver.go:693 +0x4dd
go/types.(*Checker).checkFiles(0xc000474c00, {0xc000e521b0, 0x5, 0x5})
    /usr/lib/golang/src/go/types/check.go:408 +0x1a5
go/types.(*Checker).Files(...)
    /usr/lib/golang/src/go/types/check.go:372
sigs.k8s.io/controller-tools/pkg/loader.(*loader).typeCheck(0xc0003770b0, 0xc000394640)
    /home/mchoma/go/pkg/mod/sigs.k8s.io/controller-tools@v0.10.0/pkg/loader/loader.go:286 +0x36a
sigs.k8s.io/controller-tools/pkg/loader.(*Package).NeedTypesInfo(0xc000394640)
    /home/mchoma/go/pkg/mod/sigs.k8s.io/controller-tools@v0.10.0/pkg/loader/loader.go:99 +0x39
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check(0xc000d481b0, 0xc000394640)
    /home/mchoma/go/pkg/mod/sigs.k8s.io/controller-tools@v0.10.0/pkg/loader/refs.go:268 +0x2b7
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check.func1(0x57?)
    /home/mchoma/go/pkg/mod/sigs.k8s.io/controller-tools@v0.10.0/pkg/loader/refs.go:262 +0x53
created by sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check in goroutine 33
    /home/mchoma/go/pkg/mod/sigs.k8s.io/controller-tools@v0.10.0/pkg/loader/refs.go:260 +0x1c5
make: *** [Makefile:105: manifests] Error 2
+ make install IMG=quay.io/wildfly/wildfly-operator:latest
/tmp/tmp.HBmVQCg4i9/wildfly-operator/bin/controller-gen 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=0xa048cf]

goroutine 131 [running]:
go/types.(*Checker).handleBailout(0xc000188800, 0xc001dffd40)
    /usr/lib/golang/src/go/types/check.go:367 +0x88
panic({0xbbb980?, 0x129bce0?})
    /usr/lib/golang/src/runtime/panic.go:770 +0x132
go/types.(*StdSizes).Sizeof(0x0, {0xdb0c58, 0x12a4440})
    /usr/lib/golang/src/go/types/sizes.go:228 +0x30f
go/types.(*Config).sizeof(...)
    /usr/lib/golang/src/go/types/sizes.go:333
go/types.representableConst.func1({0xdb0c58?, 0x12a4440?})
    /usr/lib/golang/src/go/types/const.go:76 +0x9e
go/types.representableConst({0xdb6ef8, 0x12705a0}, 0xc000188800, 0x12a4440, 0xc001dff4b0)
    /usr/lib/golang/src/go/types/const.go:92 +0x192
go/types.(*Checker).representation(0xc000188800, 0xc000d80d40, 0x12a4440)
    /usr/lib/golang/src/go/types/const.go:256 +0x65
go/types.(*Checker).implicitTypeAndValue(0xc000188800, 0xc000d80d40, {0xdb0c80, 0xc0003307e0})
    /usr/lib/golang/src/go/types/expr.go:375 +0x2d7
go/types.(*Checker).assignment(0xc000188800, 0xc000d80d40, {0xdb0c80, 0xc0003307e0}, {0xc883b9, 0x14})
    /usr/lib/golang/src/go/types/assignments.go:52 +0x2e5
go/types.(*Checker).initConst(0xc000188800, 0xc001c011a0, 0xc000d80d40)
    /usr/lib/golang/src/go/types/assignments.go:126 +0x2c5
go/types.(*Checker).constDecl(0xc000188800, 0xc001c011a0, {0xdb3828, 0xc001d885e0}, {0xdb3828, 0xc001d88600}, 0x0)
    /usr/lib/golang/src/go/types/decl.go:490 +0x311
go/types.(*Checker).objDecl(0xc000188800, {0xdbc6e0, 0xc001c011a0}, 0x0)
    /usr/lib/golang/src/go/types/decl.go:191 +0xa49
go/types.(*Checker).packageObjects(0xc000188800)
    /usr/lib/golang/src/go/types/resolver.go:693 +0x4dd
go/types.(*Checker).checkFiles(0xc000188800, {0xc00190c000, 0x5, 0x5})
    /usr/lib/golang/src/go/types/check.go:408 +0x1a5
go/types.(*Checker).Files(...)
    /usr/lib/golang/src/go/types/check.go:372
sigs.k8s.io/controller-tools/pkg/loader.(*loader).typeCheck(0xc0003770b0, 0xc0003e62e0)
    /home/mchoma/go/pkg/mod/sigs.k8s.io/controller-tools@v0.10.0/pkg/loader/loader.go:286 +0x36a
sigs.k8s.io/controller-tools/pkg/loader.(*Package).NeedTypesInfo(0xc0003e62e0)
    /home/mchoma/go/pkg/mod/sigs.k8s.io/controller-tools@v0.10.0/pkg/loader/loader.go:99 +0x39
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check(0xc000d3c1b0, 0xc0003e62e0)
    /home/mchoma/go/pkg/mod/sigs.k8s.io/controller-tools@v0.10.0/pkg/loader/refs.go:268 +0x2b7
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check.func1(0x5a?)
    /home/mchoma/go/pkg/mod/sigs.k8s.io/controller-tools@v0.10.0/pkg/loader/refs.go:262 +0x53
created by sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check in goroutine 107
    /home/mchoma/go/pkg/mod/sigs.k8s.io/controller-tools@v0.10.0/pkg/loader/refs.go:260 +0x1c5
make: *** [Makefile:105: manifests] Error 2

With go 1.21 everything is ok.

yersan commented 2 months ago

@mchoma Although the WildFly Operator code itself does not require any specific Go version, its dependencies can impose it. This specific error you spotted with go.1.22 is a bug in sigs.k8s.io/controller-tools@v0.10.0 fixed in major versions.

We have to stick the minimum client-go version to the target Kubernetes API, so we are not able to upgrade the controller tools to allow the Operator to run in newer Go versions.

This technically forces us to stick to a specific Go version, so the fix to this issue was to review the requirement section in our readme file and stating there that the Go version in use will be go.1.21

mchoma commented 2 months ago

@yersan When go version will be updated?

yersan commented 2 months ago

@mchoma As soon as we can migrate the Operator SDK to a new version that is compatible with higher Go versions, we will update this requirement.