Repository navigation
cri: add streaming RPCs - #13187
cri: add streaming RPCs#13187
Conversation
bec4ab9 to
06658ad
Compare
|
New tests seems to be failing. |
|
/assign @samuelkarp (as shepherd from #12814) |
06658ad to
f87d0d7
Compare
20eb872 to
8099d75
Compare
|
Can anyone take a look? |
|
Hi @samuelkarp ! Can you please take a look? thanks! |
|
/retest |
|
|
||
| import "context" | ||
|
|
||
| const defaultStreamBatchSize = 5000 |
There was a problem hiding this comment.
Did you measure this somehow? (I also noticed that crio did 3000). My understanding of the KEP is that the goal is to avoid gRPC max message failures on large nodes. Fixed 5000 likely mitigates it a lot, but this guarantee is incomplete given that contracts has no fixed size. Would using https://pkg.go.dev/google.golang.org/protobuf/proto#Size make more sense? (e.g. define batch size in bytes and pack messages while remaining size > 0)
There was a problem hiding this comment.
Based on the motivation in the CRI pagination KEP, the estimated limit is around 10,000. For context, issue #134750 shows it failing with roughly 18.5k containers. I roughly halved or 1/3 the value.
I avoided using proto.Size() because it was 5–10% slower than using a fixed batch size (see this comment). While that performance hit might be acceptable, a fixed batch size solves the bulk of the problem anyway, which is why I went with this approach.
That said, I'm starting to think it might be better to make this configurable. What do you think?
| runtime "k8s.io/cri-api/pkg/apis/runtime/v1" | ||
| ) | ||
|
|
||
| const defaultStreamBatchSize = 5000 |
There was a problem hiding this comment.
can you extract sendInBatches into a common package, so we define this once?
(internal/cri/util or internal/cri/io) ?
| return err | ||
| } | ||
|
|
||
| return errors.Join(errs...) |
There was a problem hiding this comment.
Just for my understanding. Do we want to send the whole stream first, and then errors at very end?
There was a problem hiding this comment.
ah this is wrong. Thanks.
We should return an error as soon as we get the error, like StreamContainerStats.
3129f83 to
8799415
Compare
|
@mxpv Can you take another look? |
|
|
||
| import "context" | ||
|
|
||
| const DefaultStreamBatchSize = 5000 |
There was a problem hiding this comment.
As the CRI client getting these lists is not the only workload running on the host... and the resource availability over time will vary widely. I agree with your proposal to make this a new config field
There was a problem hiding this comment.
as to the performance issue, avoiding "proto.Size() because it was 5–10% slower than using a fixed batch size"
an alternative would be to intermittently, keep a variable calculated from proto.Size(), and use the config as a "min/max" option
essentially auto tuning bytes used based on actuals...
There was a problem hiding this comment.
does config has to be part of this PR? It would be great to merge this PR so feature gate can be scheduled for promotion in 1.38
There was a problem hiding this comment.
it is fair to do config and further optimization investigations in a follow up to this PR
Add server-streaming variants of CRI list RPCs (StreamContainers, StreamPodSandboxes, StreamContainerStats, StreamPodSandboxStats, StreamPodSandboxMetrics, StreamImages) that send results in batches of 5000 items. Signed-off-by: Ayato Tokubi <[email protected]>
8799415 to
47c7085
Compare
mikebrow
left a comment
There was a problem hiding this comment.
LGTM on green with a follow-up after merge for configuration and further tuning.
|
Sorry I've been busy, and don't have time to look into it. I'll follow it up with the config PR later. |
Implements CRI List Streaming
Add server-streaming variants of CRI list RPCs (StreamContainers, StreamPodSandboxes, StreamContainerStats, StreamPodSandboxStats, StreamPodSandboxMetrics, StreamImages) that send results in batches of 5000 items (it's half of the estimated limit https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/5825-cri-pagination#motivation)
Size calculation will slow down the RPCs. See kubernetes/kubernetes#136987 (comment) for the details.
Fixes #12814
cc @samuelkarp @SergeyKanzhelev