[Feat]: Mirror request plugins execution to the response path#2369
[Feat]: Mirror request plugins execution to the response path#2369k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
Conversation
✅ Deploy Preview for gateway-api-inference-extension ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
|
|
Welcome @abdallahsamabd! |
|
Hi @abdallahsamabd. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
cbe0448 to
0e97f0e
Compare
0e97f0e to
3270c9a
Compare
|
/retest |
|
@abdallahsamabd: Cannot trigger testing until a trusted user reviews the PR and leaves an DetailsIn response to this:
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. |
3270c9a to
bf72793
Compare
| This extension works by parsing the request body. If it finds a `model` parameter in the | ||
| request body, it will copy the value of that parameter into a request header. | ||
|
|
||
| ## Pluggable BBR Plugins |
There was a problem hiding this comment.
can we revert the change in the README.md?
on the one hand, yes we're starting the add the pluging support.
but on the other hand, this is still not wired properly, so we still don't want to expose it to users (we don't want a user to try and don't understand why it is still not working).
There was a problem hiding this comment.
ok sure
done
bf72793 to
2fe818f
Compare
|
@abdallahsamabd a general comment that spreads across multiple files: more concretely - if we can leave the --response plugins out of runner, as well as the helm chart updates. |
2fe818f to
5456972
Compare
|
/ok-to-test |
|
@nirrozenbaum |
Add response plugin support to the pluggable BBR system, enabling use cases like response guardrails and content filtering. Changes: - Add responsePlugins to BBR Server struct - Implement response plugin execution loop in HandleResponseBody - Add processResponseBody for streaming response body buffering - Add --response-plugin CLI flag (mirrors --plugin) - Thread response plugins through ExtProcServerRunner - Update Helm chart templates and values for responsePlugins - Add unit tests (6) and gRPC integration tests (2) - Update pkg/bbr/README.md and chart README with plugin docs Signed-off-by: abdallahsamabd <abdallahsamabd@gmail.com> Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
e74d362 to
26471c5
Compare
| noopPlugin := &fakeResponsePlugin{ | ||
| name: "noop", | ||
| mutateFn: func(_ context.Context, headers map[string]string, body map[string]any) (map[string]string, map[string]any, error) { | ||
| return headers, body, nil | ||
| }, | ||
| } |
There was a problem hiding this comment.
can you explain what is this text with noop plugin? why is it needed?
There was a problem hiding this comment.
The noop plugin is needed to bypass the len(s.responsePlugins) == 0 early return in HandleResponseBody. Without it, the test would only exercise the no-plugins shortcut path. The noop ensures we go through the full code path (JSON unmarshal → plugin execution → response construction) in streaming mode, validating it completes without errors.
"Noop" stands for no operation — it's a plugin that does nothing. It receives the headers and body, and returns them unchanged. It exists purely to satisfy the "has plugins" condition so the code doesn't take the early-return shortcut.
There was a problem hiding this comment.
got it. maybe it would be good to reuse the mutating plugin, so we can check that plugin is actually executed correctly in streaming mode.
There was a problem hiding this comment.
since mutations are not yet applied to the response in this PR, we can't verify the plugin's effect from the returned response. Once we add mutation in the follow-up we'll update this test to use a mutating plugin
nirrozenbaum
left a comment
There was a problem hiding this comment.
/lgtm
/approve
Thanks!
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: abdallahsamabd, nirrozenbaum The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop (request body -> response headers -> response body) to validate that response plugins can mutate the response body over a real gRPC ext_proc stream. Covers: - Unary mode: response plugin mutates the response body - Unary mode: no response plugins results in passthrough behavior Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
…s#2369) Add response plugin support to the pluggable BBR system, enabling use cases like response guardrails and content filtering. Changes: - Add responsePlugins to BBR Server struct - Implement response plugin execution loop in HandleResponseBody - Add processResponseBody for streaming response body buffering - Add --response-plugin CLI flag (mirrors --plugin) - Thread response plugins through ExtProcServerRunner - Update Helm chart templates and values for responsePlugins - Add unit tests (6) and gRPC integration tests (2) - Update pkg/bbr/README.md and chart README with plugin docs Signed-off-by: abdallahsamabd <abdallahsamabd@gmail.com> Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop (request body -> response headers -> response body) to validate that response plugins can mutate the response body over a real gRPC ext_proc stream. Covers: - Unary mode: response plugin mutates the response body - Unary mode: no response plugins results in passthrough behavior Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop (request body -> response headers -> response body) to validate that response plugins can mutate the response body over a real gRPC ext_proc stream. Covers: - Unary mode: response plugin mutates the response body - Unary mode: no response plugins results in passthrough behavior Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop (request body -> response headers -> response body) to validate that response plugins can mutate the response body over a real gRPC ext_proc stream. Covers: - Unary mode: response plugin mutates the response body - Unary mode: no response plugins results in passthrough behavior Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop (request body -> response headers -> response body) to validate that response plugins can mutate the response body over a real gRPC ext_proc stream. Covers: - Unary mode: response plugin mutates the response body - Unary mode: no response plugins results in passthrough behavior Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com> Made-with: Cursor
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop (request body -> response headers -> response body) to validate that response plugins can mutate the response body over a real gRPC ext_proc stream. Covers: - Unary mode: response plugin mutates the response body - Unary mode: no response plugins results in passthrough behavior Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com> Made-with: Cursor
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop (request body -> response headers -> response body) to validate that response plugins can mutate the response body over a real gRPC ext_proc stream. Covers: - Unary mode: response plugin mutates the response body - Unary mode: no response plugins results in passthrough behavior Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com> Made-with: Cursor
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop (request body -> response headers -> response body) to validate that response plugins can mutate the response body over a real gRPC ext_proc stream. Covers: - Unary mode: response plugin mutates the response body - Unary mode: no response plugins results in passthrough behavior Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com> Made-with: Cursor
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop (request body -> response headers -> response body) to validate that response plugins can mutate the response body over a real gRPC ext_proc stream. Covers: - Unary mode: response plugin mutates the response body - Unary mode: no response plugins results in passthrough behavior Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com> Made-with: Cursor
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop (request body -> response headers -> response body) to validate that response plugins can mutate the response body over a real gRPC ext_proc stream. Covers: - Unary mode: response plugin mutates the response body - Unary mode: no response plugins results in passthrough behavior Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com> Made-with: Cursor
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop (request body -> response headers -> response body) to validate that response plugins can mutate the response body over a real gRPC ext_proc stream. Covers: - Unary mode: response plugin mutates the response body - Unary mode: no response plugins results in passthrough behavior Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com> Made-with: Cursor
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop (request body -> response headers -> response body) to validate that response plugins can mutate the response body over a real gRPC ext_proc stream. Covers: - Unary mode: response plugin mutates the response body - Unary mode: no response plugins results in passthrough behavior Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com> Made-with: Cursor
Follow-up to kubernetes-sigs#2354 / PR kubernetes-sigs#2369. Exercises the full Process loop (request body -> response headers -> response body) to validate that response plugins can mutate the response body over a real gRPC ext_proc stream. Covers: - Unary mode: response plugin mutates the response body - Unary mode: no response plugins results in passthrough behavior Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com> Made-with: Cursor
Follow-up to #2354 / PR #2369. Exercises the full Process loop (request body -> response headers -> response body) to validate that response plugins can mutate the response body over a real gRPC ext_proc stream. Covers: - Unary mode: response plugin mutates the response body - Unary mode: no response plugins results in passthrough behavior Made-with: Cursor Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
…s/gateway-api-inference-extension#2369) Add response plugin support to the pluggable BBR system, enabling use cases like response guardrails and content filtering. Changes: - Add responsePlugins to BBR Server struct - Implement response plugin execution loop in HandleResponseBody - Add processResponseBody for streaming response body buffering - Add --response-plugin CLI flag (mirrors --plugin) - Thread response plugins through ExtProcServerRunner - Update Helm chart templates and values for responsePlugins - Add unit tests (6) and gRPC integration tests (2) - Update pkg/bbr/README.md and chart README with plugin docs Signed-off-by: abdallahsamabd <abdallahsamabd@gmail.com> Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
…gateway-api-inference-extension#2450) Follow-up to kubernetes-sigs/gateway-api-inference-extension#2354 / PR kubernetes-sigs/gateway-api-inference-extension#2369. Exercises the full Process loop (request body -> response headers -> response body) to validate that response plugins can mutate the response body over a real gRPC ext_proc stream. Covers: - Unary mode: response plugin mutates the response body - Unary mode: no response plugins results in passthrough behavior Made-with: Cursor Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
Add response plugin execution support to the BBR (Body-Based Router) system, mirroring the existing request plugin path. This enables use cases like response guardrails and content filtering before returning responses to the user.
Changes:
responsePluginsfield to BBRServerstruct andNewServerconstructorHandleResponseBodyto execute response plugins on the response bodyprocessResponseBodyfor streaming response body buffering (mirrorsprocessRequestBody)ResponsePluginsthroughExtProcServerRunnerNote: Plugins are executed for validation, logging, and side effects, but mutated body/headers are not yet applied to the ext_proc response. Applying mutations (including updating dependent headers like content-length) is deferred to a follow-up to avoid inconsistencies
What type of PR is this?
/kind feature
What this PR does / why we need it:
The BBR plugin system currently only supports executing plugins on the request path. This PR mirrors that execution to the response path, allowing plugins implementing the
PayloadProcessorinterface to inspect and mutate response bodies before they are returned to the client. This is useful for response guardrails, content filtering, auditing, and other post-processing use cases.Which issue(s) this PR fixes:
Ref #2354
Does this PR introduce a user-facing change?: