Skip to content

[release/1.5 backport] pushWriter: correctly propagate errors#7998

Merged
AkihiroSuda merged 1 commit intocontainerd:release/1.5from
thaJeztah:1.5_backport_fix_push_error_propagate
Jan 25, 2023
Merged

[release/1.5 backport] pushWriter: correctly propagate errors#7998
AkihiroSuda merged 1 commit intocontainerd:release/1.5from
thaJeztah:1.5_backport_fix_push_error_propagate

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

In the refactor from 926b9c7, the error handling was substantially reworked, and changed the types of errors returned.

Notably, in the case of a network error, instead of propogating the error through to return from pushWriter.Write (as previously), it would be propagated through to pushWriter.Commit - however, this is too late, since we've already closed the io.Pipe by the time we would have reached this function. Therefore, we get the generic error message "io: read/write on closed pipe" for every network error.

This patch corrects this behavior to ensure that the correct error object is always returned as early as possible, by checking the error result after writing and detecting a closed pipe.

Additionally, we do some additional hardening - specifically we prevent falling through when resetting the content or detecting errors, and update the tests to explicitly check for the ErrReset message.

(cherry picked from commit 9f6058d)

In the refactor from 926b9c7, the error
handling was substantially reworked, and changed the types of errors
returned.

Notably, in the case of a network error, instead of propogating the
error through to return from pushWriter.Write (as previously), it would
be propagated through to pushWriter.Commit - however, this is too late,
since we've already closed the io.Pipe by the time we would have reached
this function. Therefore, we get the generic error message  "io:
read/write on closed pipe" for *every network error*.

This patch corrects this behavior to ensure that the correct error
object is always returned as early as possible, by checking the error
result after writing and detecting a closed pipe.

Additionally, we do some additional hardening - specifically we prevent
falling through when resetting the content or detecting errors, and
update the tests to explicitly check for the ErrReset message.

Signed-off-by: Justin Chadwell <[email protected]>
(cherry picked from commit 9f6058d)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Comment thread remotes/docker/pusher.go
Comment on lines +438 to 440
if _, err := pw.pipe.Write([]byte{}); err != nil && !errors.Is(err, io.ErrClosedPipe) {
return errors.Wrap(err, "pipe error before commit")
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Minor conflict in adjacent line here, as release/1.5 is still using pkg/errors here

@thaJeztah
Copy link
Copy Markdown
Member Author

I missed that the regression was also backported to 1.5, so opening a PR for this branch as well (if there's gonna be another 1.5 release)

/cc @jedevc @tonistiigi

@k8s-ci-robot
Copy link
Copy Markdown

@thaJeztah: GitHub didn't allow me to request PR reviews from the following users: jedevc.

Note that only containerd members and repo collaborators can review this PR, and authors cannot review their own PRs.

Details

In response to this:

I missed that the regression was also backported to 1.5, so opening a PR for this branch as well (if there's gonna be another 1.5 release)

/cc @jedevc @tonistiigi

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.

@AkihiroSuda AkihiroSuda merged commit 7bc9429 into containerd:release/1.5 Jan 25, 2023
@thaJeztah thaJeztah deleted the 1.5_backport_fix_push_error_propagate branch January 25, 2023 14:08
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.

4 participants