googleforgames / agones

Dedicated Game Server Hosting and Scaling for Multiplayer Games on Kubernetes
https://agones.dev
Apache License 2.0
6.04k stars 800 forks source link

cannot use func(err error) {…} (value of type func(err error)) as "k8s.io/apimachinery/pkg/util/runtime".ErrorHandler value in assignment #4004

Open joeholley opened 2 days ago

joeholley commented 2 days ago

What happened: In a golang project using go modules (the default as of current golang versions), upgrading the go.mod file to use the latest version of k8s.io/apimachinery (v0.31.0) in a project importing agones.dev/agones causes

go/pkg/mod/agones.dev/agones@v1.43.0/pkg/util/runtime/runtime.go:50:29: cannot use func(err error) {…} (value of type func(err error)) as "k8s.io/apimachinery/pkg/util/runtime".ErrorHandler value in assignment

What you expected to happen: Not particularly unexpected, as this isn't the k8s apimachinery version agones supports at its current release (the agones go.mod file specifies k8s.io/apimachinery v0.29.7). This issue is just for tracking and to document steps to fix this for others who encounter the issue until a new release of agones that supports k8s apimachinery >- v0.31.0 is cut. Basically just want folks who encounter this to be able to search for it in the github issues and see this.

How to reproduce it (as minimally and precisely as possible): In a golang project that specifies both k8s.io/apimachinery and agones.dev/agones as direct dependencies, run

go get -u ./...  # this upgrades k8s.io/apimachinery to latest, so don't do it
go mod tidy      # modifies the go.mod file to use the latest version of k8s.io/apimachinery
go build <project>

Anything else we need to know?: If you have this issue when trying to go build your golang project, these steps should help resolve it:

go get k8s.io/apimachinery@v0.29.7  # force local go environment package directory to downgrade to agones-compatible version
go mod tidy

Environment: