Skip to content

Conversation

@aviralgarg05
Copy link
Contributor

Pull Request Description

Fixes #16298

Proposed Changes

  • API Development: Added the AppendHeaders field (type map[string]string) to the TrafficTarget struct in pkg/apis/serving/v1/route_types.go. This allows users to specify custom HTTP headers for specific traffic targets in a Knative Route.
  • Validation: Implemented validateAppendHeaders in pkg/apis/serving/v1/route_validation.go to ensure that all keys provided in AppendHeaders are valid HTTP header names according to RFC 7230 and that the field is not present in the Status of the Route.
  • Ingress Propagation: Updated the Ingress generation logic in pkg/reconciler/route/resources/ingress.go. The AppendHeaders from the Route's TrafficTarget are now merged with system-level headers (like activator headers) using kmeta.UnionMaps and propagated to the IngressBackendSplit.
  • DeepCopy Logic: Manually updated pkg/apis/serving/v1/zz_generated.deepcopy.go to include deep copy support for the new AppendHeaders map, ensuring the field survives reconciliation cycles.
  • Unit Testing:
    • Added test cases to pkg/apis/serving/v1/route_validation_test.go to verify valid and invalid header configurations.
    • Added TestMakeIngressSpecWithAppendHeaders to pkg/reconciler/route/resources/ingress_test.go to confirm that headers are correctly passed through to the networking layer.

Release Note

Added `AppendHeaders` field to `TrafficTarget` in the Route API (v1) to allow specifying additional HTTP headers to be added before forwarding a request to the destination service.

    - Add AppendHeaders to TrafficTarget
    - Update Route validation
    - Update Ingress generation to propagate AppendHeaders
    - Add unit tests
    - Manually update DeepCopy for AppendHeaders
@knative-prow knative-prow bot requested review from dprotaso and skonto January 25, 2026 14:38
@knative-prow knative-prow bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 25, 2026
@knative-prow
Copy link

knative-prow bot commented Jan 25, 2026

Hi @aviralgarg05. 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. Regular contributors should join the org to skip this step.

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.

@knative-prow
Copy link

knative-prow bot commented Jan 25, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: aviralgarg05
Once this PR has been reviewed and has the lgtm label, please assign dprotaso 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

@codecov
Copy link

codecov bot commented Jan 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.20%. Comparing base (2d3f345) to head (ea18c4a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16355      +/-   ##
==========================================
- Coverage   80.23%   80.20%   -0.03%     
==========================================
  Files         216      216              
  Lines       13440    13450      +10     
==========================================
+ Hits        10784    10788       +4     
- Misses       2293     2298       +5     
- Partials      363      364       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@linkvt
Copy link
Contributor

linkvt commented Jan 25, 2026

Hi @aviralgarg05 ,
thanks for the PR, this topic is a bit more complicated though as the PR is only one side of solving this problem.
The other side is net-... implementations like https://github.com/knative-extensions/net-kourier that follow the specification to actually add the headers to the requests they route to the knative service.

I'm not experienced enough to know extending the spec would work especially considering that adding headers might not be supported by all implementations, I guess @dprotaso has more background on what could be done?

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/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow customization in managed VirtualServices #16297

2 participants