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

Improve reporting for missing kubeconfig and error connecting to the cluster #725

Merged
merged 1 commit into from
Mar 10, 2020

Conversation

navidshaikh
Copy link
Collaborator

Fixes #315

Description

  • Improve error reporting if
    • kubeconfig file is missing or
    • there is no route to host
    • i/o timeout

/lint

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Mar 10, 2020
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@navidshaikh: 1 warning.

In response to this:

Fixes #315

Description

  • Improve error reporting if
    • kubeconfig file is missing or
    • there is no route to host
    • i/o timeout

/lint

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.

pkg/errors/errors.go Outdated Show resolved Hide resolved
@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 10, 2020
 Fixes knative#315
 - Improve error reporting if
    - kubeconfig file is missing or
    - there is no route to host
    - i/o timeout
@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-client-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/errors/factory.go 86.7% 90.0% 3.3

Copy link
Contributor

@rhuss rhuss left a comment

Choose a reason for hiding this comment

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

looks good in general, but I wonder whether there is a more robust way to detect error types ? Parsing error message looks very fragile to me.

We can improve on this if we find a better way.

/lgtm

return NewKNError(msg)
}

func newNoRouteToHost(errString string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add an "Error" suffix to the method name (same below)

return false
}

func isNoRouteToHostError(err error) bool {
return strings.Contains(err.Error(), "no route to host") || strings.Contains(err.Error(), "i/o timeout")
Copy link
Contributor

Choose a reason for hiding this comment

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

basing actions on error descriptions is quite fragile. I wonder whether there is a better, typed approach ?

We can also think about it later.

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 10, 2020
@knative-prow-robot knative-prow-robot merged commit 74e43b8 into knative:master Mar 10, 2020
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: navidshaikh, rhuss

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

@kristianmandrup
Copy link

This is great :) Thank you so much!

coryrc pushed a commit to coryrc/client that referenced this pull request May 14, 2020
let error message be meaningful instead of showing binary string
@navidshaikh navidshaikh deleted the pr/fix-315 branch July 27, 2020 05:59
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. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. 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.

Improve error reporting if kubeconfig is missing or cluster unreachable
6 participants