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

Consider HTTP status for more meaningful errors #518

Merged

Conversation

corneliusweig
Copy link
Contributor

The krew CI has quite a few problems on travis, supposedly due to
API quota violation. For more meaningful errors, we now consider the
HTTP status code of the GitHub API response.

Fixes #516

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 27, 2020
@corneliusweig
Copy link
Contributor Author

Let's hope the travis build is red 😆

@codecov-io
Copy link

codecov-io commented Feb 27, 2020

Codecov Report

Merging #518 into master will decrease coverage by 0.11%.
The diff coverage is 0%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #518      +/-   ##
========================================
- Coverage   59.12%    59%   -0.12%     
========================================
  Files          23     23              
  Lines        1003   1005       +2     
========================================
  Hits          593    593              
- Misses        350    351       +1     
- Partials       60     61       +1
Impacted Files Coverage Δ
cmd/krew/cmd/internal/fetch_tag.go 86.66% <0%> (-13.34%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c3b34c1...346147e. Read the comment docs.

The krew CI has quite a few problems on travis, supposedly due to
API quota violation. For more meaningful errors, we now consider the
HTTP status code of the GitHub API response.
@@ -36,6 +36,9 @@ func FetchLatestTag() (string, error) {
if err != nil {
return "", errors.Wrapf(err, "could not GET the latest release")
}
if response.StatusCode != http.StatusOK {
return "", errors.Errorf("expected HTTP status 200 OK, got %s", response.Status)
Copy link
Member

Choose a reason for hiding this comment

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

can we do %d as well (and use response.StatusCode)?

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 think the status code is part of the string. For example for status 200, its "200 OK".

@ahmetb
Copy link
Member

ahmetb commented Feb 27, 2020

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 27, 2020
@ahmetb
Copy link
Member

ahmetb commented Feb 27, 2020

/hold

@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 Feb 27, 2020
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 27, 2020
@corneliusweig
Copy link
Contributor Author

/hold cancel
I moved the defer statement up.

@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 Feb 27, 2020
@corneliusweig
Copy link
Contributor Author

Ah.. finally. Took only 4 tries to get travis red 🐙
I didn't expect 403 though:

fetch_tag_test.go:26: expected HTTP status 200 OK, got 403 Forbidden

@ahmetb should we disable this test for the time being? Or skip for short tests testing.Short()? After all, this still prevents us from merging with Prow.

@ahmetb
Copy link
Member

ahmetb commented Feb 27, 2020

Good lord, lets just delete that test.

@corneliusweig
Copy link
Contributor Author

Really? If I remember correctly you were strongly in favor of having it 😉

I'll disable it for now.

@ahmetb
Copy link
Member

ahmetb commented Feb 27, 2020

Yeah, let's add a // TODO enable once Travis CI is discontinued which we should probably do soon anyway.

@corneliusweig
Copy link
Contributor Author

Ok, the test is skipped now and I added the todo.

@ahmetb
Copy link
Member

ahmetb commented Feb 28, 2020

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 28, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahmetb, corneliusweig

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 [ahmetb,corneliusweig]

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 merged commit 72774ce into kubernetes-sigs:master Feb 28, 2020
@corneliusweig corneliusweig deleted the w/detailed-api-error branch March 1, 2020 20:38
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. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add details to Test_fetchLatestTag_GitHubAPI
4 participants