Skip to content

Conversation

@afro-coder
Copy link
Contributor

Description

This adds the option to disable envoy generated request IDs and also preserve any external request ID that is sent.

Adds new fields to ListenerPolicy and HTTPListenerPolicy

Fixes #13249

Change Type

/kind feature

Changelog

  • add preserveExternalRequestId generateRequestId to HttpListenerPolicy and ListenerPolicy
add `preserveExternalRequestId` `generateRequestId` to `HttpListenerPolicy` and `ListenerPolicy` users can now disable the generation of Request ID and preserve external request ID

Additional Notes

Copilot AI review requested due to automatic review settings January 9, 2026 08:36
@afro-coder afro-coder requested a review from a team as a code owner January 9, 2026 08:36
@gateway-bot gateway-bot added kind/feature Categorizes issue or PR as related to a new feature. release-note labels Jan 9, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for controlling Envoy's request ID generation and preservation behavior by introducing two new fields (preserveExternalRequestId and generateRequestId) to both HTTPListenerPolicy and ListenerPolicy resources.

Key changes:

  • Added preserveExternalRequestId and generateRequestId boolean fields to the HTTPSettings API
  • Implemented merge and translation logic for the new fields
  • Added test cases and example configurations

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
api/v1alpha1/kgateway/listener_policy_types.go Added PreserveExternalRequestId and GenerateRequestId fields to HTTPSettings struct with documentation
api/v1alpha1/kgateway/zz_generated.deepcopy.go Generated DeepCopy methods for the new fields
install/helm/kgateway-crds/templates/*.yaml Updated CRD schemas for both ListenerPolicy and HTTPListenerPolicy
pkg/kgateway/extensions2/plugins/listenerpolicy/http.go Added new fields to HttpListenerPolicyIr struct and initialization logic
pkg/kgateway/extensions2/plugins/listenerpolicy/merge_http.go Implemented merge functions for the new fields
pkg/kgateway/extensions2/plugins/listenerpolicy/listener_plugin.go Applied the new fields to Envoy HCM configuration
pkg/kgateway/translator/gateway/gateway_translator_test.go Added test cases for both new fields
pkg/kgateway/translator/gateway/testutils/inputs/httplistenerpolicy/*.yaml Created test input files (with typo in filenames)
pkg/kgateway/translator/gateway/testutils/outputs/httplistenerpolicy/*.yaml Created expected output files (with typo in filenames)
test/e2e/features/listener_policy/testdata/*.yaml Added e2e test configurations
examples/example-gw-with-http-listener-policy.yaml Updated example with preserveExternalRequestId field

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

})
})


Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

Extra blank line should be removed to maintain consistent spacing with other test cases.

Suggested change

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,152 @@
Clusters:
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The filename has a typo: "preseve" should be "preserve". This filename is inconsistent with the test reference which uses "preserve-external-request-id.yaml".

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,47 @@
apiVersion: gateway.networking.k8s.io/v1
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The filename has a typo: "preseve" should be "preserve". This filename is inconsistent with the test reference which uses "preserve-external-request-id.yaml".

Copilot uses AI. Check for mistakes.
out.UseRemoteAddress = wrapperspb.Bool(*policy.useRemoteAddress)
}
if policy.preserveExternalRequestId != nil {
out.PreserveExternalRequestId = *policy.preserveExternalRequestId
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

Inconsistent wrapping with wrapperspb.Bool(). Line 358 sets preserveExternalRequestId without wrapping (dereferencing directly), while line 361 sets generateRequestId with wrapperspb.Bool(). Both fields should be handled consistently. Looking at how useRemoteAddress is set on line 355, it uses wrapperspb.Bool(), so preserveExternalRequestId should also use wrapperspb.Bool().

Suggested change
out.PreserveExternalRequestId = *policy.preserveExternalRequestId
out.PreserveExternalRequestId = wrapperspb.Bool(*policy.preserveExternalRequestId)

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

@afro-coder afro-coder Jan 9, 2026

Choose a reason for hiding this comment

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

If I use wrapperspb I get, as this doesn't match the envoy proto

cannot use wrapperspb.Bool(*policy.preserveExternalRequestId) (value of type *wrapperspb.BoolValue) as bool value in assignment

apiVersion: gateway.kgateway.dev/v1alpha1
kind: HTTPListenerPolicy
metadata:
name: generate-request-id
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The metadata name "generate-request-id" doesn't match the filename "generate-request-id-false.yaml". For consistency with other test files and the actual test behavior (testing when the value is false), consider renaming to "generate-request-id-false" to match the filename.

Suggested change
name: generate-request-id
name: generate-request-id-false

Copilot uses AI. Check for mistakes.
apiVersion: gateway.kgateway.dev/v1alpha1
kind: ListenerPolicy
metadata:
name: http-listener-policy-all-fields
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The policy name "http-listener-policy-all-fields" is misleading. This file tests only the generateRequestId field set to false, not "all fields". For clarity and consistency with the filename, the name should be something like "http-listener-policy-generate-request-id" or "http-listener-policy-generate-request-id-false".

Suggested change
name: http-listener-policy-all-fields
name: http-listener-policy-generate-request-id

Copilot uses AI. Check for mistakes.
@yuval-k
Copy link
Contributor

yuval-k commented Jan 9, 2026

looks good to me, can you make CI happy and we can merge?

@afro-coder
Copy link
Contributor Author

Thanks for checking @yuval-k I fixed the errors, hoping the tests pass, did the rebase too for the DCO

@yuval-k yuval-k added this pull request to the merge queue Jan 9, 2026
Merged via the queue into kgateway-dev:main with commit 9d84bf1 Jan 9, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. release-note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for PreserveExternalRequestId and generateRequestId in HTTPListenerPolicy

3 participants