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

fix: correct unwrap of http2.Error #311

Merged
merged 1 commit into from Mar 3, 2022

Conversation

pabigot
Copy link
Contributor

@pabigot pabigot commented Feb 25, 2022

Closes #310

Proposed Changes

Implement Unwrap() correctly.

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable
  • A test has been added if appropriate
  • Tests pass
  • Commit messages are in semantic format
  • Sign CLA (if not already signed)

@codecov-commenter
Copy link

codecov-commenter commented Feb 25, 2022

Codecov Report

Merging #311 (10d3bf4) into master (7688764) will decrease coverage by 0.11%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #311      +/-   ##
==========================================
- Coverage   90.62%   90.51%   -0.12%     
==========================================
  Files          23       23              
  Lines        2465     2468       +3     
==========================================
  Hits         2234     2234              
- Misses        173      176       +3     
  Partials       58       58              
Impacted Files Coverage Δ
api/http/error.go 76.19% <0.00%> (-12.70%) ⬇️

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 7688764...10d3bf4. Read the comment docs.

@pabigot
Copy link
Contributor Author

pabigot commented Feb 25, 2022

With this patch this comment can be extended to use:

if errors.Is(err, syscall.ECONNREFUSED) {
    // server unavailable, back off and retry later
}

because it unwraps to this sequence:

2022/02/25 12:40:34.168950 bucket.sensors: [I] write err 1: *http.Error: Post "http://tirzah.pab:8086/api/v2/write?bucket=sensors&org=green-tirzah&precision=us": dial tcp 192.168.65.21:8086: connect: connection refused
2022/02/25 12:40:34.169095 bucket.sensors: [I] write err 2: *url.Error: Post "http://tirzah.pab:8086/api/v2/write?bucket=sensors&org=green-tirzah&precision=us": dial tcp 192.168.65.21:8086: connect: connection refused
2022/02/25 12:40:34.169125 bucket.sensors: [I] write err 3: *net.OpError: dial tcp 192.168.65.21:8086: connect: connection refused
2022/02/25 12:40:34.169147 bucket.sensors: [I] write err 4: *os.SyscallError: connect: connection refused
2022/02/25 12:40:34.169169 bucket.sensors: [I] write err 5: syscall.Errno: connection refused

rather than falling apart at the first unwrap:

2022/02/25 07:05:44.215389 bucket.sensors: [I] write err 1: *http.Error: Post "http://tirzah.pab:8086/api/v2/write?bucket=sensors&org=green-tirzah&precision=us": dial tcp 192.168.65.21:8086: connect: connection refused
2022/02/25 07:05:44.215812 bucket.sensors: [I] write err 2: *errors.errorString: Post "http://tirzah.pab:8086/api/v2/write?bucket=sensors&org=green-tirzah&precision=us": dial tcp 192.168.65.21:8086: connect: connection refused

Copy link
Contributor

@vlastahajek vlastahajek left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@vlastahajek vlastahajek merged commit 5368398 into influxdata:master Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

http2.Error does not implement errors.Unwrap correctly
3 participants