Skip to content

proxy: break up writes from the remote writer to avoid grpc limits#11441

Merged
dmcgowan merged 1 commit intocontainerd:mainfrom
jsternberg:remote-write-grpc-limits-exceeded
Feb 27, 2025
Merged

proxy: break up writes from the remote writer to avoid grpc limits#11441
dmcgowan merged 1 commit intocontainerd:mainfrom
jsternberg:remote-write-grpc-limits-exceeded

Conversation

@jsternberg
Copy link
Copy Markdown
Contributor

The remote content writer proxy already has the capability to break up
large files into multiple writes, but the current API doesn't recognize
when it's about to exceed the limits and attempts to send the data over
grpc in one message instead of breaking it into multiple messages.

This changes the behavior of Write to automatically break up the size
of the content based on the max send message size.

Fixes #11440.

@k8s-ci-robot
Copy link
Copy Markdown

Hi @jsternberg. 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-sigs/prow repository.

@dosubot dosubot Bot added the kind/bug label Feb 26, 2025
Comment thread core/content/proxy/content_writer.go Outdated
if n < len(p) {
err = io.ErrShortWrite
}
if sz := proto.Size(req); sz > defaults.DefaultMaxSendMsgSize {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Using this variable seemed wrong to me but I couldn't think of any alternative. The max send message size can be changed through a grpc.CallOption which can be arbitrarily set on the grpc connection for containerd. I don't believe there's anyway to retrieve what the real value is for this connection other than just overriding whatever the user determined, setting the value to something conservative enough it would generally always work, or documenting that lowering the max send message size could result in failures.

@jsternberg jsternberg force-pushed the remote-write-grpc-limits-exceeded branch from d134bb3 to f033405 Compare February 26, 2025 22:03
Comment thread core/content/proxy/content_writer.go Outdated
rw.digest = digest.Digest(resp.Digest)
}
n += written
p = p[written:]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did you consider slices.Chunk here? Should make chunk iteration much nicer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't realize this function existed but it also seems to require go 1.23 and the go.mod for this project is on go 1.22.

I can add an implementation using this function for the future though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

#11398 is updating it to 1.23.0

Copy link
Copy Markdown
Member

@mxpv mxpv Feb 27, 2025

Choose a reason for hiding this comment

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

I believe we target 2 last versions of Go (#11377), e.g. as of now its 1.24 and 1.23.

go.mod directive indicates the minimum Go version that should be used to build the module, this is different from the target Go version.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've rebased and updated the PR to use slices.Chunk.

@jsternberg jsternberg force-pushed the remote-write-grpc-limits-exceeded branch from f033405 to 017ab5f Compare February 27, 2025 15:41
The remote content writer proxy already has the capability to break up
large files into multiple writes, but the current API doesn't recognize
when it's about to exceed the limits and attempts to send the data over
grpc in one message instead of breaking it into multiple messages.

This changes the behavior of `Write` to automatically break up the size
of the content based on the max send message size.

Signed-off-by: Jonathan A. Sternberg <[email protected]>
Copy link
Copy Markdown
Member

@dmcgowan dmcgowan left a comment

Choose a reason for hiding this comment

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

LGTM

We should backport this to 2.0. We may need to replace slices.Chunk (only in backport) if it requires 1.23 which 2.0 currently does not seem to require via go.mod.

@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Feb 27, 2025
@mxpv mxpv added this pull request to the merge queue Feb 27, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Feb 27, 2025
@dmcgowan dmcgowan added this pull request to the merge queue Feb 27, 2025
Merged via the queue into containerd:main with commit 34e4bd2 Feb 27, 2025
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Feb 27, 2025
@jsternberg jsternberg deleted the remote-write-grpc-limits-exceeded branch February 28, 2025 00:49
@austinvazquez austinvazquez added cherry-picked/2.0.x PR commits are cherry picked into the release/2.0 branch and removed cherry-pick/2.0.x Change to be cherry picked to release/2.0 branch labels May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked/2.0.x PR commits are cherry picked into the release/2.0 branch kind/bug ok-to-test size/M

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Remote content store can exceed grpc size limits when performing a write

7 participants