kubernetes / kube-openapi

Kubernetes OpenAPI spec generation & serving
Apache License 2.0
319 stars 208 forks source link

Build fails due to `undefined: atomic.Pointer` #379

Closed zchenyu closed 1 year ago

zchenyu commented 1 year ago
Error: ../../../go/pkg/mod/k8s.io/kube-openapi@v0.0.0-20230308215209-15aac26d736a/pkg/cached/cache.go:242:16: undefined: atomic.Pointer

This seems to have been introduced in https://github.com/kubernetes/kube-openapi/pull/371

I believe the fix is to bump the Go version in go.mod to 1.19 https://github.com/kubernetes/kube-openapi/blob/15aac26d736acfa8584df8030fef87eef2ca1921/go.mod#L3

apelisse commented 1 year ago

The question is, how did it pass the CI when I made the PR?

zchenyu commented 1 year ago

Seems CI explicitly uses 1.19 https://github.com/kubernetes/kube-openapi/blob/master/.github/workflows/ci.yml#L15 To use the go.mod version, you can do: https://github.com/actions/setup-go#getting-go-version-from-the-gomod-file

emmahsax commented 1 year ago

I'm getting a similar issue in GitHub Actions after trying to upgrade my project to 1.21:

# k8s.io/kube-openapi/pkg/cached
/github/home/go/pkg/mod/k8s.io/kube-openapi@v0.0.0-20230501164219-8b0f38b5fd1f/pkg/cached/cache.go:242:16: undefined: atomic.Pointer
note: module requires Go 1.19

However, it builds locally when I run go build ./..., and I was previously on 1.20, not 1.19. So how on earth was this package being loaded properly if it's truly requiring 1.19.

apelisse commented 1 year ago

So how on earth was this package being loaded properly if it's truly requiring 1.19.

I'm not entirely sure what you mean, it should work with 1.19+, it doesn't specifically requires 1.19 (i.e. 1.20 should work).

Seems CI explicitly uses 1.19 https://github.com/kubernetes/kube-openapi/blob/master/.github/workflows/ci.yml#L15 To use the go.mod version, you can do: https://github.com/actions/setup-go#getting-go-version-from-the-gomod-file

we should definitely use the go.mod version, sounds like it's time to tear apart the matrix.

emmahsax commented 1 year ago

@apelisse I did figure out the docker image I was using actually had a lower version of Go installed... I had downgraded that docker image, and therefore, it also downgraded the Go version.

apelisse commented 1 year ago

@apelisse I did figure out the docker image I was using actually had a lower version of Go installed... I had downgraded that docker image, and therefore, it also downgraded the Go version.

Thanks for clarifying!

apelisse commented 1 year ago

I've created #418 for ci to use the go.mod version.