Skip to content

Conversation

@shreealt
Copy link
Contributor

@shreealt shreealt commented Oct 11, 2025

What type of PR is this?

Enhancement.

What this PR does / why we need it:

Chash on multiple headers is a legit use case. Example: when user identity is split across multiple headers, X-Tenant-ID + X-User-ID in multi-tenant apps.

Which issue(s) this PR fixes:

Fixes #7186

Release Notes: Yes/No

@shreealt shreealt requested a review from a team as a code owner October 11, 2025 10:02
@shreealt shreealt changed the title feat: support chash based on multiple headers feat: support chash on multiple headers Oct 11, 2025
@shreealt shreealt marked this pull request as draft October 11, 2025 16:14
@shreealt shreealt marked this pull request as ready for review October 12, 2025 09:25
Comment on lines 137 to +149
HeaderConsistentHashType ConsistentHashType = "Header"
// HeadersConsistentHashType hashes based on multiple request headers.
HeadersConsistentHashType ConsistentHashType = "Headers"
Copy link
Contributor

Choose a reason for hiding this comment

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

The API and implementation between HeadersConsistentHashType and HeaderConsistentHashType looks nearly identical. Should we instead deprecate HeaderConsistentHashType?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, that was actually the ask by Arko in the issue description, I was unaware how we would deprecate the HeaderConsistentHashType.

Do we replace HeaderConsistentHashType with the new HeadersConsistentHashType directly in the code?

Copy link
Contributor

Choose a reason for hiding this comment

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

You'd mark the API field as deprecated similar to

// Deprecated: use targetRefs/targetSelectors instead
with a mention that HeadersConsistentHashType should be used instead as well as including it in the release notes file.

It would stick around in deprecated fashion for the upcoming release and actually removed in a future one (most likely the following release).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, thanks a lot for the help <3

@codecov
Copy link

codecov bot commented Oct 13, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.01%. Comparing base (c68db79) to head (c1173f1).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
internal/gatewayapi/clustersettings.go 38.46% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7198      +/-   ##
==========================================
- Coverage   71.04%   71.01%   -0.03%     
==========================================
  Files         229      229              
  Lines       41099    41113      +14     
==========================================
  Hits        29198    29198              
- Misses      10181    10194      +13     
- Partials     1720     1721       +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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

// Hash based on the Source IP Address
SourceIP *bool `json:"sourceIP,omitempty" yaml:"sourceIP,omitempty"`
Header *Header `json:"header,omitempty" yaml:"header,omitempty"`
Headers []*Header `json:"headers,omitempty" yaml:"headers,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

in this layer can you delete Header and copy over the Header API field into Headers ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

doing so would introduce a breaking change, won't it?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is an internal layer, not user facing, and our libs are /internal too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, please review again

Copy link
Contributor

Choose a reason for hiding this comment

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

still see Header, suggestion was to delete it to improve maintenance

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry for the confusion. I removed it finally.

// Header configures the header hash policy when the consistent hash type is set to Header.
//
// +optional
// Deprecated: use Headers instead
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add the optional tag back

@shreealt shreealt force-pushed the feat/implement-multi-header-hash-in-chash branch from 8e3632d to c82805c Compare October 16, 2025 18:34
name: seventh-route
route:
cluster: seventh-route-dest
hashPolicy:
Copy link
Contributor

Choose a reason for hiding this comment

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

can the input file be fixed with headers to fix this output

Copy link
Contributor

@arkodg arkodg left a comment

Choose a reason for hiding this comment

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

LGTM thanks

@arkodg arkodg requested review from a team and jukie October 21, 2025 17:43
Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Shreemaan Abhishek <[email protected]>
This reverts commit 5c1e2f0.

Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Shreemaan Abhishek <[email protected]>
@zirain zirain force-pushed the feat/implement-multi-header-hash-in-chash branch from 1ff0f42 to c1173f1 Compare October 22, 2025 06:06
@arkodg arkodg merged commit 06f961e into envoyproxy:main Oct 22, 2025
33 of 35 checks passed
linmosko pushed a commit to linmosko/gateway that referenced this pull request Oct 27, 2025
* feat: support chash based on multiple headers

Signed-off-by: Shreemaan Abhishek <[email protected]>
Signed-off-by: Lin Moskovitch <[email protected]>
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.

consistent hashing on multiple headers

4 participants