Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix(requestreply): unregister the request on an early return - #9518

Open
arpitjain099 wants to merge 1 commit into
knative:mainfrom
arpitjain099:fix/requestreply-ingress-entry-leak
Open

arpitjain099 wants to merge 1 commit into
knative:mainfrom
arpitjain099:fix/requestreply-ingress-entry-leak

Conversation

@arpitjain099

@arpitjain099 arpitjain099 commented Nov 9, 2026 •

Copy link
Copy Markdown

handleNewEvent registers the event in h.entries first, then four error paths return without calling deleteEvent: no broker address annotation, no AES key, a correlation id failure, a dispatch failure. Each one leaves a proxiedRequest holding the request's ResponseWriter in the map for the life of the pod. Only the reply and timeout paths clean up.

Moving the cleanup into a defer after addEvent covers every return. The new test posts five events at a broker that is not listening: 5 entries are left behind before the change, 0 after.

Proposed Changes

  • 🐛 Unregister the proxied request with a defer, so every return from handleNewEvent removes it from h.entries

Pre-review Checklist

  • At least 80% unit test coverage
  • E2E tests for any new behavior
  • Docs PR for any user-facing impact
  • Spec PR for any new API feature
  • Conformance test for any change to the spec

Release Note

The RequestReply ingress no longer keeps a request registered after it fails, so failed requests stop accumulating in memory.

This change was written with the assistance of generative AI. I have reviewed and understand every change in it.

@knative-prow
knative-prow Bot requested review from Cali0707 and aliok November 9, 2026 01:11
@knative-prow

knative-prow Bot commented Nov 9, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: arpitjain099
Once this PR has been reviewed and has the lgtm label, please assign arsenetar for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow

knative-prow Bot commented Nov 9, 2026

Copy link
Copy Markdown

Welcome @arpitjain099! It looks like this is your first PR to knative/eventing 🎉

@knative-prow knative-prow Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 9, 2026
@knative-prow

knative-prow Bot commented Nov 9, 2026

Copy link
Copy Markdown

Hi @arpitjain099. Thanks for your PR.

I'm waiting for a knative 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.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

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.

Copilot AI 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.

🟢 Approval recommended

No active review issues remain for the request-cleanup change.

No open issues 🎉

What changed in this PR

Fixes a memory leak in the RequestReply ingress by ensuring registered requests are removed when handleNewEvent returns, including on early errors.

Changes:

  • Defers request cleanup immediately after registration, replacing cleanup calls in individual return paths.
  • Adds a regression test verifying that five failed dispatches leave no registered requests.
File Description
pkg/​requestreply/​ingress_handler.go Ensures request cleanup runs on every return.
pkg/​requestreply/​ingress_handler_test.go Tests that dispatch failures do not retain registered requests.

Review effort: Balanced

This change was written with the assistance of generative AI. I have
reviewed and understand every change in it.

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
@arpitjain099
arpitjain099 force-pushed the fix/requestreply-ingress-entry-leak branch from ea6635f to 016a0b4 Compare November 12, 2026 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants