Skip to content

Conversation

@akhilerm
Copy link
Member

@akhilerm akhilerm commented May 27, 2022

A dynamic pipe is created in the body of the request, so that everytime a GetBody() call is made, a new pipe gets generated to which the content can be written, and the http body can be read from the PipeReader, thus solving the body reuse issue.

Fixes: #5978

@k8s-ci-robot
Copy link

Hi @akhilerm. Thanks for your PR.

I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

@akhilerm
Copy link
Member Author

cc: @dmcgowan updated the changes in the PR as discussed. Also added a reference to a commit that is used for testing with docker config.

@akhilerm akhilerm force-pushed the retry-on-reset branch 3 times, most recently from be51db7 to 62854c4 Compare August 17, 2022 06:02
@akhilerm akhilerm marked this pull request as ready for review August 17, 2022 06:06
@akhilerm
Copy link
Member Author

@dmcgowan @tonistiigi Can you take a look at this PR?

@mikebrow
Copy link
Member

/ok-to-test

Copy link
Contributor

@endocrimes endocrimes left a comment

Choose a reason for hiding this comment

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

first pass makes sense - but lack of tests make it somewhat difficult to have confidence.

The main Copy control loop definitely needs a bit of tweaking for readability, but logic seems ~ok.

tracker StatusTracker
}

func newPushWriter(db *dockerBase, ref string, expected digest.Digest, tracker StatusTracker, isManifest bool) *pushWriter {
Copy link
Contributor

Choose a reason for hiding this comment

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

the pushWriter is getting complex enough that it might be worth trying to write some basic tests for, partially to document intent.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added test cases for both push() and Copy() method

@akhilerm akhilerm requested review from endocrimes and mikebrow and removed request for endocrimes and mikebrow September 7, 2022 18:32
@akhilerm akhilerm requested review from mikebrow and removed request for endocrimes September 12, 2022 11:18
Copy link
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

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

See comments...

when a put request is retried due to the response from registry,
the body of the request should be seekable. A dynamic pipe is added
to the body so that the content of the body can be read again.
Currently a maximum of 5 resets are allowed, above which will fail the
request. A new error ErrReset is introduced which informs that a
reset has occured and request needs to be retried.

also added tests for Copy() and push() to test the new functionality

Signed-off-by: Akhil Mohan <makhil@vmware.com>
@akhilerm
Copy link
Member Author

@mikebrow Can you review this PR once more?

Copy link
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

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

LGTM

@samuelkarp samuelkarp merged commit b7a8a54 into containerd:main Sep 28, 2022
@akhilerm akhilerm deleted the retry-on-reset branch September 29, 2022 05:25
@akhilerm
Copy link
Member Author

Should this change be cherry-picked to 1.6 / 1.5 ?

@estesp
Copy link
Member

estesp commented Sep 29, 2022

Should this change be cherry-picked to 1.6 / 1.5 ?

Yes, I think so. This is a long-standing bug that has affected quite a few users so should be cherry-picked to our supported releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked/1.6.x PR commits are cherry-picked into release/1.6 branch kind/bug ok-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"cannot reuse body, request must be retried" on ctr images push

7 participants