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

Deprecate the use of pkg/errors #2868

Merged

Conversation

raisaat
Copy link
Contributor

@raisaat raisaat commented Dec 13, 2021

Deprecate the use of pkg/errors in MCO to use built-in Golang error-wrapping

Signed-off-by: Raisaat Rashid rarashid@redhat.com

- What I did

Changed all the code instances in machine-config-operator using pkg/errors to use built-in Golang error-wrapping instead.

- How to verify it

Make sure all the e2e and unit tests run properly.

- Description for the changelog

Deprecate the use of pkg/errors in machine-config-operator to use built-in Golang error-wrapping

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 13, 2021

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 13, 2021
@raisaat
Copy link
Contributor Author

raisaat commented Dec 13, 2021

/test e2e-aws-op

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 13, 2021

@raisaat: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test cluster-bootimages
  • /test e2e-agnostic-upgrade
  • /test e2e-aws
  • /test e2e-gcp-op
  • /test images
  • /test unit
  • /test verify

The following commands are available to trigger optional jobs:

  • /test bootstrap-unit
  • /test e2e-aws-disruptive
  • /test e2e-aws-proxy
  • /test e2e-aws-serial
  • /test e2e-aws-single-node
  • /test e2e-aws-upgrade
  • /test e2e-aws-upgrade-single-node
  • /test e2e-aws-workers-rhel7
  • /test e2e-aws-workers-rhel8
  • /test e2e-azure
  • /test e2e-azure-upgrade
  • /test e2e-gcp-op-single-node
  • /test e2e-gcp-single-node
  • /test e2e-gcp-upgrade
  • /test e2e-metal-assisted
  • /test e2e-metal-ipi
  • /test e2e-metal-ipi-ovn-dualstack
  • /test e2e-metal-ipi-ovn-ipv6
  • /test e2e-openstack
  • /test e2e-openstack-parallel
  • /test e2e-ovirt
  • /test e2e-ovirt-upgrade
  • /test e2e-ovn-step-registry
  • /test e2e-vsphere
  • /test e2e-vsphere-upgrade
  • /test e2e-vsphere-upi
  • /test okd-e2e-aws
  • /test okd-e2e-gcp-op
  • /test okd-e2e-upgrade
  • /test okd-e2e-vsphere
  • /test okd-images

Use /test all to run the following jobs that were automatically triggered:

  • pull-ci-openshift-machine-config-operator-master-bootstrap-unit
  • pull-ci-openshift-machine-config-operator-master-e2e-agnostic-upgrade
  • pull-ci-openshift-machine-config-operator-master-e2e-aws
  • pull-ci-openshift-machine-config-operator-master-e2e-aws-disruptive
  • pull-ci-openshift-machine-config-operator-master-e2e-aws-serial
  • pull-ci-openshift-machine-config-operator-master-e2e-aws-single-node
  • pull-ci-openshift-machine-config-operator-master-e2e-aws-upgrade-single-node
  • pull-ci-openshift-machine-config-operator-master-e2e-aws-workers-rhel7
  • pull-ci-openshift-machine-config-operator-master-e2e-aws-workers-rhel8
  • pull-ci-openshift-machine-config-operator-master-e2e-gcp-op
  • pull-ci-openshift-machine-config-operator-master-e2e-gcp-op-single-node
  • pull-ci-openshift-machine-config-operator-master-e2e-metal-ipi
  • pull-ci-openshift-machine-config-operator-master-e2e-ovn-step-registry
  • pull-ci-openshift-machine-config-operator-master-e2e-vsphere-upgrade
  • pull-ci-openshift-machine-config-operator-master-images
  • pull-ci-openshift-machine-config-operator-master-okd-e2e-aws
  • pull-ci-openshift-machine-config-operator-master-okd-images
  • pull-ci-openshift-machine-config-operator-master-unit
  • pull-ci-openshift-machine-config-operator-master-verify

In response to this:

/test e2e-aws-op

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.

@raisaat
Copy link
Contributor Author

raisaat commented Dec 13, 2021

/test e2e-gcp-op

@raisaat
Copy link
Contributor Author

raisaat commented Dec 13, 2021

/test e2e-aws

@raisaat raisaat changed the title [WIP]: Deprecate the use of pkg/errors in machine-config-operator/cmd [WIP]: Deprecate the use of pkg/errors Dec 14, 2021
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 15, 2021
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 15, 2021
@raisaat raisaat marked this pull request as ready for review December 15, 2021 13:09
@raisaat raisaat changed the title [WIP]: Deprecate the use of pkg/errors Deprecate the use of pkg/errors Dec 15, 2021
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 15, 2021
@raisaat
Copy link
Contributor Author

raisaat commented Dec 15, 2021

/test e2e-gcp-op

@raisaat
Copy link
Contributor Author

raisaat commented Dec 15, 2021

/test e2e-aws

@sinnykumari
Copy link
Contributor

You don't need to run test again. When you push any new changes, all tests will automatically rerun

Copy link
Member

@cheesesashimi cheesesashimi left a comment

Choose a reason for hiding this comment

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

Overall, this looks great! I just have a couple of minor comments / suggestions. The biggest one is the fix for the unit tests / linter issues.

Also, I think we may be missing a few cases:

$ rg -g "\!vendor" -g "*.go" --files-with-matches -F "github.com/pkg/errors"
pkg/server/api.go
pkg/daemon/on_disk_validation.go

Once those are addressed, we should be able to completely remove github.com/pkg/errors, though the actual removal should be done in a separate commit in this PR for easier review since it's vendored.

}
return "", errors.Wrap(err, "failed to run command %s (%d tries): %v")
return "", fmt.Errorf("failed to run command %s (%d tries): %v: %w", err)
Copy link
Member

Choose a reason for hiding this comment

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

This is where the unit test failure is occurring. Basically, this fmt.Errorf requires four formatting arguments, but only one was passed in.

This should also fix the lint failure as well.

} else {
return errors.Wrapf(err, "unkown error occured %v", lastErr)
return fmt.Errorf("unkown error occured %v: %w", lastErr, err)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("unkown error occured %v: %w", lastErr, err)
return fmt.Errorf("unknown error occurred %v: %w", lastErr, err)

@yuqi-zhang
Copy link
Contributor

/retest-required

@@ -183,14 +182,14 @@ func (ctrl *Controller) checkMasterNodesOnDelete(obj interface{}) {
}
currentMasters, err := ctrl.getCurrentMasters()
if err != nil {
goerrs.Wrap(err, "Reconciling to make master nodes schedulable/unschedulable failed")
fmt.Errorf("Reconciling to make master nodes schedulable/unschedulable failed: %w", err)
Copy link
Member

Choose a reason for hiding this comment

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

golangci-lint caught this. The reason why this was never caught before is most likely because the linter was not looking for the goerrs.Wrap() function. When this was changed to use fmt.Errorf(), the linter picked up on the pattern and alerted to an unused result since fmt.Errorf() is likely a more well-known signature.

That explanation aside, it's interesting that this error is never bubbled out of this function. This could be because this function is passed into a ResourceEventHandlerFuncs struct whose type does not accept a function with any return arguments. The same pattern can be seen throughout ctrl.checkMasterNodesOnDelete, ctrl.reconcileMaster and ctrl.reconcileMasters (all within this file, pkg/controller/node/node_controller.go).

As for a proposed remedy, I offer two suggestions:

  1. We replace these specific calls to fmt.Errorf() with calls to glog.Errorf() so the errors are logged. This remedy would not introduce any unknown behavior and may help gain insight into how often these particular errors occur.
  2. Instead of just logging the error, we handle it using the utilruntime.HandleError() function which will try again using the rudimentaryErrorBackoff mechanism within that package. This function appears to be used throughout this file. However, this could introduce unknown behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting. I think paths like this one are very rarely considered in the first place, since we don't generally consider node deletion operations. In fact I am not sure whether we have any testing for this case, and whether we'd be able to auto recover, if at all.

I think right now I am leaning towards option 1, since I think it's fine to increase error logging in general in case these situations do happen. For 2, I don't know how we are handling the errors at all, so I am not sure what behaviour the HandleError actually exhibits for our use case (again, they should very rarely fire)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we leave option 2 for now? I have made a commit for option 1. I can go ahead and squash it with the previous commits (after a rebase since there are merge conflicts).

@@ -156,7 +155,7 @@ func checkV3Files(files []ign3types.File) error {
var err error
contents, err = dataurl.DecodeString(*f.Contents.Source)
if err != nil {
return errors.Wrapf(err, "couldn't parse file %q", f.Path)
return fmt.Errorf("couldn't parse file %q: %w", f.Path, err)
Copy link
Member

Choose a reason for hiding this comment

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

Just an FYI: This may cause a merge conflict depending upon whether #2874 is merged before this is.

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 19, 2021
@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 21, 2022
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 5, 2022
@raisaat
Copy link
Contributor Author

raisaat commented Apr 5, 2022

/remove-lifecycle stale

@openshift-ci openshift-ci bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 5, 2022
@cheesesashimi
Copy link
Member

/test e2e-gcp-op

@raisaat
Copy link
Contributor Author

raisaat commented Apr 13, 2022

/retest-required

@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

2 similar comments
@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@kikisdeliveryservice
Copy link
Contributor

hmm so the failures seem related to this PR

see: https://prow.ci.openshift.org/view/gs/origin-ci-test/pr-logs/pull/openshift_machine-config-operator/2868/pull-ci-openshift-machine-config-operator-master-e2e-agnostic-upgrade/1514370580923551744

 # github.com/openshift/machine-config-operator/pkg/daemon
pkg/daemon/daemon.go:703:12: undefined: "errors".Wrapf
pkg/daemon/daemon.go:706:11: undefined: "errors".Wrapf
pkg/daemon/daemon.go:713:10: undefined: "errors".Wrapf
pkg/daemon/daemon.go:721:10: undefined: "errors".Wrapf
pkg/daemon/daemon.go:726:10: undefined: "errors".Wrapf
pkg/daemon/daemon.go:733:10: undefined: "errors".Wrapf
pkg/daemon/daemon.go:738:10: undefined: "errors".Wrapf
pkg/daemon/daemon.go:744:10: undefined: "errors".Wrapf
pkg/daemon/daemon.go:752:10: undefined: "errors".Wrapf
pkg/daemon/daemon.go:758:11: undefined: "errors".Wrapf
pkg/daemon/daemon.go:758:11: too many errors 

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 13, 2022
@kikisdeliveryservice
Copy link
Contributor

@raisaat I think you need to rebase onto master and then search for new "errors." that were just merged today via #3068

@yuqi-zhang
Copy link
Contributor

Ah apologies, I duplicate some old code for that PR, and forgot to update error references.

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Apr 14, 2022
@raisaat
Copy link
Contributor Author

raisaat commented Apr 14, 2022

@kikisdeliveryservice Thanks! Fixed them.

@yuqi-zhang not a problem :)

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 14, 2022
Signed-off-by: Raisaat Rashid <rarashid@redhat.com>
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 14, 2022
@kikisdeliveryservice
Copy link
Contributor

Thanks @raisaat

/lgtm
/hold cancel

@openshift-ci openshift-ci bot added lgtm Indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Apr 14, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 14, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cheesesashimi, kikisdeliveryservice, raisaat

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:
  • OWNERS [kikisdeliveryservice]

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

@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 14, 2022

@raisaat: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/okd-e2e-aws 4cfb1fa9d27f2c5de0002758321df2d551d5c75d link false /test okd-e2e-aws
ci/prow/e2e-aws-single-node 4cfb1fa9d27f2c5de0002758321df2d551d5c75d link false /test e2e-aws-single-node
ci/prow/e2e-aws-workers-rhel8 4cfb1fa9d27f2c5de0002758321df2d551d5c75d link false /test e2e-aws-workers-rhel8
ci/prow/e2e-metal-ipi 4cfb1fa9d27f2c5de0002758321df2d551d5c75d link false /test e2e-metal-ipi
ci/prow/e2e-aws-workers-rhel7 4cfb1fa9d27f2c5de0002758321df2d551d5c75d link false /test e2e-aws-workers-rhel7
ci/prow/e2e-aws-upgrade-single-node 4cfb1fa9d27f2c5de0002758321df2d551d5c75d link false /test e2e-aws-upgrade-single-node
ci/prow/e2e-aws-disruptive 4cfb1fa9d27f2c5de0002758321df2d551d5c75d link false /test e2e-aws-disruptive
ci/prow/e2e-gcp-op-single-node 4cfb1fa9d27f2c5de0002758321df2d551d5c75d link false /test e2e-gcp-op-single-node
ci/prow/4.12-upgrade-from-stable-4.11-images e36a8eb5ef9cd8f6150309f15b37702f6a8f6371 link true /test 4.12-upgrade-from-stable-4.11-images

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@kikisdeliveryservice
Copy link
Contributor

Overriding the agnostic-upgrade job which keeps failing due to unrelated bugs and to prevent other PRs from merging which will require this to be updated again.

/override ci/prow/e2e-agnostic-upgrade

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 14, 2022

@kikisdeliveryservice: Overrode contexts on behalf of kikisdeliveryservice: ci/prow/e2e-agnostic-upgrade

In response to this:

Overriding the agnostic-upgrade job which keeps failing due to unrelated bugs and to prevent other PRs from merging which will require this to be updated again.

/override ci/prow/e2e-agnostic-upgrade

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
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants