Skip to content

Conversation

@cratelyn
Copy link
Member

@cratelyn cratelyn commented Jun 2, 2025

see linkerd/linkerd2#14050.

this change fixes a logical bug with
linkerd_http_retry::peek_trailers::PeekTrailersBody::<B>::read_body(..).

read_body(..) constructs a PeekTrailersBody<B>, by polling the inner
body to see whether or not it can reach the end of the stream by only
yielding to the asynchronous runtime once.

in #3559, we restructured this middleware's
internal modeling to reflect the Frame<T>-oriented signatures of the
http_body::Body trait's 1.0 interface.

unfortunately, this included a bug which could cause the first frame in
a stream to be discarded if the second Body::poll_frame() call
(invoked via now_or_never()) returns Pending. this could cause
non-deterministic errors for users when sending traffic to HTTPRoutes
and GRPCRoutes with retry annotations applied.

this change rectifies this problem, ensuring that the first frame is not
discarded when attempting to peek a body's trailers.

to confirm that this works as expected, additional test coverage is
introduced that confirms that the data and trailers of the inner body
are passed through faithfully.

cratelyn added 3 commits June 2, 2025 09:27
this commit introduces additional test coverage to
`linker_http_retry::peek_trailers::PeekTrailersBody<B>`.

this body middleware is used to facilitate transparent http retries, and
allows callers to possibly inspect the trailers for a response, by
polling an `http_body::Body`.

this commit introduces additional unit test coverage that confirms that
the data and trailers of the inner body are passed through faithfully.

Signed-off-by: katelyn martin <[email protected]>
this commit introduces some additional coverage for bodies that return
`Pending` when polled a second time.

Signed-off-by: katelyn martin <[email protected]>
this commit fixes a logical bug with
`linkerd_http_retry::peek_trailers::PeekTrailersBody::<B>::read_body(..)`.

`read_body(..)` constructs a `PeekTrailersBody<B>`, by polling the inner
body to see whether or not it can reach the end of the stream by only
yielding to the asynchronous runtime once.

in #3559, we restructured this middleware's
internal modeling to reflect the `Frame<T>`-oriented signatures of the
`http_body::Body` trait's 1.0 interface.

unfortunately, this included a bug which could cause the first frame in
a stream to be discarded if the second `Body::poll_frame()` call
(_invoked via `now_or_never()`_) returns `Pending`. this could cause
non-deterministic errors for users when sending traffic to HTTPRoutes
and GRPCRoutes with retry annotations applied.

this commit rectifies this problem, ensuring that the first frame is not
discarded when attempting to peek a body's trailers.

Signed-off-by: katelyn martin <[email protected]>
@cratelyn cratelyn self-assigned this Jun 2, 2025
@cratelyn cratelyn marked this pull request as ready for review June 2, 2025 16:36
@cratelyn cratelyn requested a review from a team as a code owner June 2, 2025 16:36
@cratelyn cratelyn enabled auto-merge (squash) June 2, 2025 16:37
@cratelyn cratelyn merged commit ea6f407 into main Jun 2, 2025
15 checks passed
@cratelyn cratelyn deleted the kate/http-retry.fix-peek-trailers-regression-3559 branch June 2, 2025 16:53
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.

3 participants