-
Notifications
You must be signed in to change notification settings - Fork 2.1k
commandconn: return original error while closing #4394
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
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #4394 +/- ##
==========================================
- Coverage 59.37% 59.37% -0.01%
==========================================
Files 288 286 -2
Lines 24746 24746
==========================================
- Hits 14693 14692 -1
Misses 9169 9169
- Partials 884 885 +1 |
| // to return an io.EOF | ||
| return 0, io.EOF | ||
| // we don't want to call onEOF | ||
| return n, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Err may be nil here; do we need to return a io.EOF in that case? (Thinking out loud if we need an io.EOF for calling code)
if err == nil {
return io.EOF
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, if the read didn't return an error then it's fine to not return one here. This was the original behavior, and subsequent reads will fail regardless with a file closed/pipe closed error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In normal operation, it will only be closing if an EOF was already returned triggering the transport layer to call Close regardless. This special handling is only meant to keep us from calling handleEOF twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking! The original comment triggered my curiosity, so wanted to check 😅 👍
thaJeztah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor comment on the test, but otherwise LGTM
|
|
||
| writeErr := <-writeErrC | ||
| assert.ErrorContains(t, writeErr, "EOF") | ||
| assert.ErrorContains(t, writeErr, "file already closed") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be using one of these for this?
https://github.com/golang/go/blob/18e17e2cb12837ea2c8582ecdb0cc780f49a1aac/src/io/fs/fs.go#L141
https://github.com/golang/go/blob/18e17e2cb12837ea2c8582ecdb0cc780f49a1aac/src/os/error.go#L24
| assert.ErrorContains(t, writeErr, "file already closed") | |
| assert.Check(t, is.ErrorIs(writeErr, fs.ErrClosed)) |
|
|
||
| readErr := <-readErrC | ||
| assert.ErrorContains(t, readErr, "EOF") | ||
| assert.ErrorContains(t, readErr, "file already closed") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| assert.ErrorContains(t, readErr, "file already closed") | |
| assert.Check(t, is.ErrorIs(readErr, fs.ErrClosed)) |
Changes the `Read` and `Write` error handling logic to return the original error while closing the connection. We still skip calling `handleEOF` if already closing the connection. Fixes the flaky `TestCloseWhileWriting` and `TestCloseWhileReading` tests. Co-authored-by: Sebastiaan van Stijn <github@gone.nl> Signed-off-by: Laura Brehm <laurabrehm@hey.com>
thaJeztah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I applied my suggestions in the test
LGTM
|
Thanks! I was away from a keyboard, appreciate it ❤️ |
|
Preparing a cherry-pick; will be up in a minute 👍 |
|
Looks like it's still flaky - I just got a test failure in a freshly rebased PR: https://github.com/docker/cli/actions/runs/5454066267/jobs/9923693780?pr=4331 \cc @laurazard |
|
Thanks @vvoland. I'll TAL when I get a change. |
- What I did
Fixes the flaky
TestCloseWhileWritingandTestCloseWhileReadingtests.- How I did it
Changes the
ReadandWriteerror handling logic to return the original error while closing the connection. We still skip callinghandleEOFif already closing the connection.- How to verify it
go test -v ./..., and make sure everything still works.- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)