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

🌱 Replace github.com/pkg/errors #1585

Merged
merged 2 commits into from
Jun 13, 2023

Conversation

pierreprinetti
Copy link
Contributor

@pierreprinetti pierreprinetti commented Jun 12, 2023

What this PR does / why we need it:

The package pkg/errors has served its purpose and its proposed changes have been incorporated into Go's standard library in Go v1.13.

This change removes it as a direct dependency, replacing its functionality with the corresponding features of fmt and errors.

Special notes for your reviewer:

The old pkg/errors defined the method Cause() error, whereas the stdlib incorporated its functionality with the method Unwrap() error. As such, if a consumer of CAPO directly called errors.Cause(err) to match the causing error, then their code would silently break because the underlying sentinel error wouldn't be identified.

This problem is susceptible to affect any code that uses CAPO as a library, that uses a version of pkg/errors below v0.9.0.

The last versions of pkg/errors (v0.9.0+) incorporated a compatibility layer with the new Unwrap() syntax.

TODOs:

  • squashed commits
  • if necessary:
    • includes documentation
    • adds unit tests

/hold

EDIT: Added a note pointing out that there is a risk of compatibility issues

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 12, 2023
@netlify
Copy link

netlify bot commented Jun 12, 2023

Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!

Name Link
🔨 Latest commit f2597fe
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-openstack/deploys/64872adbe8883c00071e20ae
😎 Deploy Preview https://deploy-preview-1585--kubernetes-sigs-cluster-api-openstack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 12, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @pierreprinetti. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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 requested review from jichenjc and mdbooth June 12, 2023 10:52
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 12, 2023
@tobiasgiese
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 12, 2023
@pierreprinetti
Copy link
Contributor Author

Incidentally, with this change the CI is now checking the style of the errors... which is why I had to remove the capital letter from an error message :)

@tobiasgiese
Copy link
Member

tobiasgiese commented Jun 12, 2023

I don't know if we want to move away from pkg/errors. There is already a discussion in kubernetes-sigs/cluster-api#6688.
What are the others maintainers thinking? @jichenjc @mdbooth @seanschneeweiss @lentzi90?
I don't have a firm opinion on this, either is fine with me.

Copy link
Contributor

@lentzi90 lentzi90 left a comment

Choose a reason for hiding this comment

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

Looks like a quite small change for us so I'm in favor of taking this in. From what I understand CAPI and kubeadm would have much larger changes so they are waiting for now. But I see plenty of PRs like this in k/k so I think it makes sense for us to follow.

controllers/openstackcluster_controller.go Outdated Show resolved Hide resolved
The package [pkg/errors](/~https://github.com/pkg/errors) has served its
purpose and its proposed changes have been incorporated into Go's
standard library.

This change removes it as a direct dependency, replacing its
functionality with the corresponding features of `fmt` and `errors`.
}
if len(networkList) == 0 {
handleUpdateOSCError(openStackCluster, errors.Errorf("failed to find any network: %v", err))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

wait. err is nil here, isn't it? Why did we wrap it, here and below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have changed this error (and its message) in a separate commit. PTAL!

Avoid wrapping `<nil>` in the error message if there is no error to
wrap.
@tobiasgiese
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 12, 2023
@jichenjc
Copy link
Contributor

/approve

Agree it's small change and we can follow other k/k behavior..
leave the unhold to other folks in case they want to take another look

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jichenjc, pierreprinetti

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

The pull request process is described 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-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 12, 2023
Copy link
Contributor

@lentzi90 lentzi90 left a comment

Choose a reason for hiding this comment

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

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 13, 2023
@k8s-ci-robot k8s-ci-robot merged commit 5ac49e7 into kubernetes-sigs:main Jun 13, 2023
@pierreprinetti pierreprinetti deleted the replace_errors branch June 13, 2023 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants