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

Add support for go 1.22 #3792

Closed
mneverov opened this issue Feb 20, 2024 · 11 comments · Fixed by #3910
Closed

Add support for go 1.22 #3792

mneverov opened this issue Feb 20, 2024 · 11 comments · Fixed by #3910
Assignees
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. triage/accepted Indicates an issue or PR is ready to be actively worked on. triage/blocked

Comments

@mneverov
Copy link
Member

What broke? What's expected?

When using go v1.22 kubebuilder create api results in NPE.
Related to kubernetes-sigs/controller-tools#880.

Reproducing this issue

Steps to reproduce:
0. Install go v1.22

$ kubebuilder init
INFO[0000] Writing kustomize manifests for you to edit...
INFO[0000] Writing scaffold for you to edit...
INFO[0000] Get controller runtime:
$ go get sigs.k8s.io/controller-runtime@v0.16.0
INFO[0000] Update dependencies:
$ go mod tidy
Next: define a resource with:
$ kubebuilder create api
$ kubebuilder create api --version v1 --kind Webhook
INFO[0000] Create Resource [y/n]
y
INFO[0001] Create Controller [y/n]
y
INFO[0001] Writing kustomize manifests for you to edit...
INFO[0001] Writing scaffold for you to edit...
INFO[0001] api/v1/webhook_types.go
INFO[0001] api/v1/groupversion_info.go
INFO[0001] internal/controller/suite_test.go
INFO[0001] internal/controller/webhook_controller.go
INFO[0001] Update dependencies:
$ go mod tidy
INFO[0001] Running make:
$ make generate
mkdir -p /home/mneverov/go/src/github.com/mneverov/testkubebuilder/bin
test -s /home/mneverov/go/src/github.com/mneverov/testkubebuilder/bin/controller-gen && /home/mneverov/go/src/github.com/mneverov/testkubebuilder/bin/controller-gen --version | grep -q v0.13.0 || \
GOBIN=/home/mneverov/go/src/github.com/mneverov/testkubebuilder/bin go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.13.0
/home/mneverov/go/src/github.com/mneverov/testkubebuilder/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
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=0xa0e55e]

goroutine 179 [running]:
go/types.(*Checker).handleBailout(0xc00199c000, 0xc001211d40)
        /usr/local/go/src/go/types/check.go:367 +0x88
panic({0xbc8860?, 0x12b5880?})
        /usr/local/go/src/runtime/panic.go:770 +0x132
go/types.(*StdSizes).Sizeof(0x0, {0xdc4c18, 0x12be040})
        /usr/local/go/src/go/types/sizes.go:228 +0x31e
go/types.(*Config).sizeof(...)
        /usr/local/go/src/go/types/sizes.go:333
go/types.representableConst.func1({0xdc4c18?, 0x12be040?})
        /usr/local/go/src/go/types/const.go:76 +0x9e
go/types.representableConst({0xdcaff0, 0x1288f60}, 0xc00199c000, 0x12be040, 0x0)
        /usr/local/go/src/go/types/const.go:92 +0x192
go/types.(*Checker).arrayLength(0xc00199c000, {0xdc92a0, 0xc001636ec0?})
        /usr/local/go/src/go/types/typexpr.go:510 +0x2d3
go/types.(*Checker).typInternal(0xc00199c000, {0xdc78c0, 0xc001658180}, 0x0)
        /usr/local/go/src/go/types/typexpr.go:299 +0x49d
go/types.(*Checker).definedType(0xc00199c000, {0xdc78c0, 0xc001658180}, 0xc001211328?)
        /usr/local/go/src/go/types/typexpr.go:180 +0x37
go/types.(*Checker).varType(0xc00199c000, {0xdc78c0, 0xc001658180})
        /usr/local/go/src/go/types/typexpr.go:145 +0x25
go/types.(*Checker).structType(0xc00199c000, 0xc0013a24b0, 0xc0013a24b0?)
        /usr/local/go/src/go/types/struct.go:113 +0x19f
go/types.(*Checker).typInternal(0xc00199c000, {0xdc7830, 0xc001626f00}, 0xc000842550)
        /usr/local/go/src/go/types/typexpr.go:316 +0x1345
go/types.(*Checker).definedType(0xc00199c000, {0xdc7830, 0xc001626f00}, 0xc92787?)
        /usr/local/go/src/go/types/typexpr.go:180 +0x37
go/types.(*Checker).typeDecl(0xc00199c000, 0xc000842550, 0xc001634c80, 0x0)
        /usr/local/go/src/go/types/decl.go:615 +0x44d
go/types.(*Checker).objDecl(0xc00199c000, {0xdd04b8, 0xc000842550}, 0x0)
        /usr/local/go/src/go/types/decl.go:197 +0xa7f
go/types.(*Checker).packageObjects(0xc00199c000)
        /usr/local/go/src/go/types/resolver.go:681 +0x425
go/types.(*Checker).checkFiles(0xc00199c000, {0xc0012d58f0, 0x3, 0x3})
        /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(0xc0002b1380, 0xc0006f5c60)
        /home/mneverov/go/pkg/mod/sigs.k8s.io/controller-tools@v0.13.0/pkg/loader/loader.go:286 +0x36a
sigs.k8s.io/controller-tools/pkg/loader.(*Package).NeedTypesInfo(0xc0006f5c60)
        /home/mneverov/go/pkg/mod/sigs.k8s.io/controller-tools@v0.13.0/pkg/loader/loader.go:99 +0x39
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check(0xc0008ff770, 0xc0006f5c60)
        /home/mneverov/go/pkg/mod/sigs.k8s.io/controller-tools@v0.13.0/pkg/loader/refs.go:268 +0x2b7
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check.func1(0x4d?)
        /home/mneverov/go/pkg/mod/sigs.k8s.io/controller-tools@v0.13.0/pkg/loader/refs.go:262 +0x53
created by sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check in goroutine 163
        /home/mneverov/go/pkg/mod/sigs.k8s.io/controller-tools@v0.13.0/pkg/loader/refs.go:260 +0x1c5
make: *** [Makefile:53: generate] Error 2
Error: failed to create API: unable to run post-scaffold tasks of "base.go.kubebuilder.io/v4": exit status 2
Usage:
  kubebuilder create api [flags]

Examples:
  # Create a frigates API with Group: ship, Version: v1beta1 and Kind: Frigate
  kubebuilder create api --group ship --version v1beta1 --kind Frigate

  # Edit the API Scheme

  nano api/v1beta1/frigate_types.go

  # Edit the Controller
  nano internal/controller/frigate/frigate_controller.go

  # Edit the Controller Test
  nano internal/controller/frigate/frigate_controller_test.go

  # Generate the manifests
  make manifests

  # Install CRDs into the Kubernetes cluster using kubectl apply
  make install

  # Regenerate code and run against the Kubernetes cluster configured by ~/.kube/config
  make run


Flags:
      --controller           if set, generate the controller without prompting the user (default true)
      --force                attempt to create resource even if it already exists
      --group string         resource Group
  -h, --help                 help for api
      --kind string          resource Kind
      --make make generate   if true, run make generate after generating files (default true)
      --namespaced           resource is namespaced (default true)
      --plural string        resource irregular plural form
      --resource             if set, generate the resource without prompting the user (default true)
      --version string       resource Version

Global Flags:
      --plugins strings   plugin keys to be used for this subcommand execution

FATA[0002] failed to create API: unable to run post-scaffold tasks of "base.go.kubebuilder.io/v4": exit status 2

KubeBuilder (CLI) Version

Version: main.version{KubeBuilderVersion:"3.12.0", KubernetesVendor:"1.27.1", GitCommit:"b48f95cd5384eadcdfd02a47a02910f72ddc7ea8", BuildDate:"2023-09-06T06:04:11Z", GoOs:"linux", GoArch:"amd64"}

PROJECT version

3

Plugin versions

No response

Other versions

No response

Extra Labels

No response

@mneverov mneverov added the kind/bug Categorizes issue or PR as related to a bug. label Feb 20, 2024
@camilamacedo86
Copy link
Member

camilamacedo86 commented Feb 20, 2024

Hi @mneverov

Thank you for raising it.
We need to push a bump for the new release of the controller-tools.
However, we should just bump go/v4. Could you please see the comments in the review of this PR and help us to address them? So, that we can have your contribution merged asap.

However, to support go 1.22 we need to create another PR to bump controller-runtime using go/v2 and properly bump the go/v4 scaffold to use go 1.22 as well as all places where we are using go 1.21 currently.

The current release does not support go 1.22.
So, it is a RFE not a bug.

@camilamacedo86 camilamacedo86 added kind/feature Categorizes issue or PR as related to a new feature. and removed kind/bug Categorizes issue or PR as related to a bug. labels Feb 20, 2024
@camilamacedo86 camilamacedo86 changed the title Panic When Use go v1.22 Add support for go 1.22 Feb 20, 2024
@camilamacedo86 camilamacedo86 added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. triage/accepted Indicates an issue or PR is ready to be actively worked on. labels Feb 20, 2024
@camilamacedo86
Copy link
Member

camilamacedo86 commented Feb 21, 2024

Hi @mneverov

Sorry, now I checked this one better. Following are all the details.

Now, regarding support, we are going to go 1.22.

It is NOT supported yet by Kubebuilder.
Note that we support the versions scaffolded by default with the tool.
You can change as you please, but we cannot ensure that things are still working since the changes will result in combinations not tested by us. See from the doc: https://book.kubebuilder.io/quick-start#versions-and-supportability

Screenshot 2024-02-21 at 17 43 07

What we need to do to support go 1.22

  • Wait for controller-runtime and controller-tools releases using go 1.22
  • Then, change the go plugin to scaffold go 1.22 and use it
  • Mainly replace all places across the project that have 1.21 with 1.22

Your help is very welcome.

Cheers,

@Shuimo03
Copy link

can assignee to me?

@camilamacedo86
Copy link
Member

Hi @Shuimo03

We can only work on this when controller runtime and controller tools are using 1.22 and provide releases within.
That is still not the case:

You can work on the above projects to see if we can help them move first, and then we will be in the place to update Kubebuidler.

Also, feel free to contribute as you see fit.
Your help is more than welcome ;-)

@Shuimo03
Copy link

ok

@camilamacedo86
Copy link
Member

We need be able to remove go/v2 and go/v3 plugins to move forward within
The old versions will not work well after the bump so this one is blocker for the MAJOR release #3622

@yaron2
Copy link

yaron2 commented May 14, 2024

Hi @Shuimo03

We can only work on this when controller runtime and controller tools are using 1.22 and provide releases within. That is still not the case:

You can work on the above projects to see if we can help them move first, and then we will be in the place to update Kubebuidler.

Also, feel free to contribute as you see fit. Your help is more than welcome ;-)

Since this is now the case that both are using Go 1.22.0, can we please bump a new version for Go 1.22? I'm a Dapr maintainer and our performance tests are broken due to this issue.

@camilamacedo86
Copy link
Member

Hi @Shuimo03,

To move forward and support go 1.22 we need to:

-> Get merged: #3899
-> To do a new release 3x
-> Then, we can remove the deprecated plugins to do a 4x #3622 (PRs are done already)
-> Then we can do the bumps and new release.

If you want to help out, could you please help with the review of: #3899

c/c @varshaprasad96

@camilamacedo86
Copy link
Member

Hi @Shuimo03,

we are unblocked now.
Just give to us a couple of days and we will be releasing 4x with support for go 1.22 and k8s 1.30

@camilamacedo86 camilamacedo86 self-assigned this May 15, 2024
@mikeee
Copy link

mikeee commented May 15, 2024

I think you've been tagging the wrong person, thanks for the prompt updates though 🙂

@Shuimo03
Copy link

@camilamacedo86 @yaron2 hi, Are you looking for me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. triage/accepted Indicates an issue or PR is ready to be actively worked on. triage/blocked
Projects
None yet
5 participants