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

Pointer: Add generic Pointer func #239

Closed

Conversation

alvaroaleman
Copy link
Member

This adds a new, generic pointer func to the pointer package.

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change

/kind bug
/kind cleanup
/kind design
/kind documentation
/kind test
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Release note:


@k8s-ci-robot k8s-ci-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 15, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: alvaroaleman
To complete the pull request process, please assign apelisse after the PR has been reviewed.
You can assign the PR to them by writing /assign @apelisse in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-triage-robot
Copy link

This PR may require API review.

If so, when the changes are ready, complete the pre-review checklist and request an API review.

Status of requested reviews is tracked in the API Review project.

@alvaroaleman alvaroaleman force-pushed the add-generic-pointer branch 2 times, most recently from 11147c1 to 3f934fd Compare March 16, 2022 19:47
Copy link
Contributor

@MadhavJivrajani MadhavJivrajani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll need to update the golangci-lint version and explicitly mention 1.18:

docker run --rm -v `pwd`:/go/src/k8s.io/klog -w /go/src/k8s.io/klog \
            golangci/golangci-lint:v1.45.0 golangci-lint run --go 1.18 --disable-all -v \
            -E govet -E misspell -E gofmt -E ineffassign -E golint

See golangci/golangci-lint#2649 for more details.

@liggitt
Copy link
Member

liggitt commented Mar 21, 2022

does this require all consumers of k8s.io/utils to set go1.18 in their go.mod files, or just compile with go 1.18?

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 21, 2022
This adds a new, generic pointer func to the pointer package.
@alvaroaleman
Copy link
Member Author

alvaroaleman commented Mar 21, 2022

@thockin the tests in ./internal/third_party/forked/golang/net do not pass on go versions > 1.16. Is this known? Can you have a look?

The problem is that the test calls IP.UnmarshalText which uses the stdlibs ParseIP which inhibits the behavior you apparently wanted to supress with the fork...?

I've added a commit that uses a downstream IPUnmarshalText but I think you should have a look and check what exactly is expected here.

@alvaroaleman
Copy link
Member Author

@liggitt I just tested, it works fine when the importing project sets go 1.17 but using a go 1.18 compiler...Out of curiosity, why do we care? So importing projects that do not use this package can still use an older compiler?

@liggitt
Copy link
Member

liggitt commented Mar 21, 2022

Out of curiosity, why do we care? So importing projects that do not use this package can still use an older compiler?

changing go.mod to 1.17+ messes up the require directives in ways that break our dependency analysis tooling (xref golang/go#47648)

@liggitt
Copy link
Member

liggitt commented Mar 21, 2022

So importing projects that do not use this package can still use an older compiler?

also, we don't tag versions of k8s.io/utils and maintain multiple branches, so I probably wouldn't expect us to start using go1.18 features until go1.18 was the oldest supported go version (when go1.19 is released)

@alvaroaleman
Copy link
Member Author

alvaroaleman commented Mar 21, 2022

I am sorry the PR has so many unrelated changes now, all of them are fallout from updating the go version:

  • The github workflow never used the configured go version, because it referred an undefined variable from the matrix (go-version vs go-versions)
  • pkg/inotify doesn't pass go vet on go 1.17+ because it calls t.Fatalf from a goroutine
  • forked/golang/net doesn't pass tests on go 1.17+, precicely because of the change in behavior it is supposed to prevent
  • gofmt needed updating in a couple of places to add the go:build directives added in go .17
  • golangci-lint added support for go 1.18 but they didn't change the compiler version in the released docker image that does that, and there is no released docker image compiled with 1.18. Thx @MadhavJivrajani for the tip. The unreleased change to update the compiler for the image is fix: update base images to go1.18 golangci/golangci-lint#2661

@euroelessar
Copy link

Just passing by, but can you consider the following changes, please?

  1. Use // +build go1.18 build tag in a file with generic implementations to keep compatibility with lower golang versions
  2. In case of golang 1.18, implement existing methods using generic one, e.g. var Int = Pointer[int]
  3. Keep an existing implementation for versions below 1.17 behind !go1.18 build tag, this way an older implementation can be deleted once 1.18 is the lowest supported version
  4. Provide an implementation for Deref and Equal methods as well

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 29, 2022
@k8s-ci-robot
Copy link
Contributor

@alvaroaleman: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 6, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Aug 5, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closed this PR.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants