Skip to content

Support two ext_proc filters in the chain 2nd attempt (#43175) (#618) - #620

Merged
jwendell merged 1 commit into
envoyproxy:release/v1.34from
jwendell:backport-ext-proc-two-filters-1.34
Sep 23, 2026
Merged

jwendell merged 1 commit into
envoyproxy:release/v1.34from
jwendell:backport-ext-proc-two-filters-1.34

Conversation

@jwendell

Copy link
Copy Markdown
Member

Backport to release/v1.34 of #43175. This is a cherry-pick of the release/v1.35 commit 05ae42b, which in turn backported the release/v1.36 commit
ac77ca1, itself a cherry-pick of the release/v1.37 commit 567847a5ed947b0ae3a6f10ecefb0b9ac8c17605, itself a cherry-pick of the main-branch commit
867251ab48bb4fda89ead154bbc600131cf614ad.

This is the 2nd attempt to fix
envoyproxy/envoy#41654.

The 1st attempt is envoyproxy/envoy#43042

The root cause of the issue is when the 2nd filter resume the processing, doData(observedEndStream() && !had_trailers_before_data) in source/common/http/filter_manager.cc uses an outdated observedEndStream() flag as end_of_stream. This flag is set to true once Envoy sees data with end_of_stream set to true either from downstream client or backend server. However, in the ext_proc case, after the data with end_of_stream=true is received by Envoy, it is sent out to the side-stream server and re-injected back to Envoy, the observedEndStream() flag has to be updated during re-injection. Otherwise, the 2nd filter commonContinue() deems the full body is in buffer, i.e. end_of_stream=true, even the 1st filter is still injecting more data.

The issue is reproduced in both ext_proc STREAMED and FULL_DUPLEX_STREAMED modes, also in both request and response directions. Please check the added integration tests.

Backport notes (changes needed to resolve conflicts against 1.34):

  • The source fix (filter_manager.cc, processor_state.cc) applied cleanly.
  • runtime_features.cc: kept 1.34's existing ext_proc guards and inserted only the new envoy.reloadable_features.ext_proc_inject_data_with_state_update guard alphabetically; the 1.35-only ext_proc_fail_close_spurious_resp context guard does not exist on 1.34 and was dropped.
  • All test changes were ported into 1.34's monolithic ext_proc_integration_test.cc: the two_ext_proc_filters_ config path and its helpers (addDownstreamExtProcFilter, server1* gRPC helpers), the extracted initializeConfigDuplexStreamed, the renamed header/body helpers, and the five new TwoExtProcFilters* tests.
  • The ServerSendOutOfOrderResponseDuplexStreamed test kept 1.34's own 400-response behavior; only the mechanical helper renames were applied (the 1.35 500-response variant was not adopted).
  • The 1.35-only tests that appeared in the conflict but are unrelated to this feature (DISABLED_DuplexStreamedServerResponseWithSynthesizedTrailer, BufferedModeOverSizeRequestLocalReply, FilterStateAccessLogSerialization, and the other Pack*/Trailers tests) belong to other commits not backported to 1.34 and were dropped.

…proxy#618)

Backport to release/v1.34 of #43175. This is a cherry-pick of the
release/v1.35 commit 05ae42b, which in
turn backported the release/v1.36 commit
ac77ca1, itself a cherry-pick of the
release/v1.37 commit 567847a5ed947b0ae3a6f10ecefb0b9ac8c17605, itself a
cherry-pick of the main-branch commit
867251ab48bb4fda89ead154bbc600131cf614ad.

This is the 2nd attempt to fix
envoyproxy/envoy#41654.

The 1st attempt is envoyproxy/envoy#43042

The root cause of the issue is when the 2nd filter resume the
processing, `doData(observedEndStream() && !had_trailers_before_data)`
in `source/common/http/filter_manager.cc` uses an outdated
`observedEndStream()` flag as `end_of_stream`. This flag is set to true
once Envoy sees data with end_of_stream set to true either from
downstream client or backend server. However, in the ext_proc case,
after the data with end_of_stream=true is received by Envoy, it is sent
out to the side-stream server and re-injected back to Envoy, the
`observedEndStream()` flag has to be updated during re-injection.
Otherwise, the 2nd filter `commonContinue()` deems the full body is in
buffer, i.e. end_of_stream=true, even the 1st filter is still injecting
more data.

The issue is reproduced in both ext_proc STREAMED and
FULL_DUPLEX_STREAMED modes, also in both request and response
directions. Please check the added integration tests.

Backport notes (changes needed to resolve conflicts against 1.34):

- The source fix (filter_manager.cc, processor_state.cc) applied
  cleanly.
- runtime_features.cc: kept 1.34's existing ext_proc guards and inserted
  only the new
  `envoy.reloadable_features.ext_proc_inject_data_with_state_update`
  guard alphabetically; the 1.35-only `ext_proc_fail_close_spurious_resp`
  context guard does not exist on 1.34 and was dropped.
- All test changes were ported into 1.34's monolithic
  `ext_proc_integration_test.cc`: the `two_ext_proc_filters_` config
  path and its helpers (`addDownstreamExtProcFilter`, `server1*` gRPC
  helpers), the extracted `initializeConfigDuplexStreamed`, the renamed
  header/body helpers, and the five new `TwoExtProcFilters*` tests.
- The `ServerSendOutOfOrderResponseDuplexStreamed` test kept 1.34's own
  400-response behavior; only the mechanical helper renames were applied
  (the 1.35 500-response variant was not adopted).
- The 1.35-only tests that appeared in the conflict but are unrelated to
  this feature (`DISABLED_DuplexStreamedServerResponseWithSynthesizedTrailer`,
  `BufferedModeOverSizeRequestLocalReply`,
  `FilterStateAccessLogSerialization`, and the other Pack*/*Trailers*
  tests) belong to other commits not backported to 1.34 and were dropped.

Signed-off-by: Jonh Wendell <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
@dcillera
dcillera self-requested a review September 23, 2026 20:21

@dcillera dcillera left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good — faithful, correct backport.
Verification

  • filter_manager.cc — matches upstream byte-for-byte, including the intentional (and harmless) asymmetry: decode uses parent_.state().observed_decode_end_stream_, encode uses parent_.state_.observed_encode_end_stream_. Both resolve to the same State member (state() just returns state_). Both fields exist in filter_manager.h.
  • processor_state.cc — receivedData().length() > 0 → !chunkQueue().empty() matches upstream. This is a real behavioral fix (the queue can hold an empty end-stream chunk that must still be injected). ChunkQueue::empty() exists in the 1.34 header.
  • runtime_features.cc — new RUNTIME_GUARD inserted in correct alphabetical position; default-on, matching upstream. The dropped 1.35-only ext_proc_fail_close_spurious_resp guard is correctly absent from 1.34.
  • Test filter changes (continue_headers_only_..., stop_iteration_headers_...) — match upstream exactly; the end_stream→/* end_stream */ change in the stop-iteration filter correctly avoids an unused-param, and the continue filter keeps the name because it's still used later.
  • Test helpers — all rename/signature changes are internally consistent; no stale references to the old serverReceiveHeaderDuplexStreamed / serverSendHeaderRespDuplexStreamed names, and every serverSendBodyRespDuplexStreamed/serverReceiveBodyDuplexStreamed call passes the new processor_stream argument.
  • Changelog — present, correct format/location, and documents the revert guard.
  • Backport notes in the PR description accurately describe the conflict resolution.

The following tests are successful in a local run:
//test/extensions/filters/http/ext_proc:ext_proc_integration_test //test/extensions/filters/http/ext_proc:filter_test //test/extensions/filters/http/ext_proc/unit_test_fuzz:ext_proc_unit_test_fuzz

@jwendell
jwendell merged commit 7231aaf into envoyproxy:release/v1.34 Sep 23, 2026
1 check passed
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.

2 participants