receive: handle empty tenant_matcher_type as exact match in shuffle sharding - #8974
receive: handle empty tenant_matcher_type as exact match in shuffle sharding#8974bisshwajitsamanta wants to merge 8 commits into
Conversation
Signed-off-by: Bisshwajit Samanta <bisshwajitsamanta@gmail.com>
7555390 to
924b772
Compare
|
|
|
Thanks for the feedback! To answer your question about when it can be empty: tenant_matcher_type is an optional field in the hashring configuration (json:"tenant_matcher_type,omitempty"). When users leave it out of their configuration file, Go unmarshals it as an empty string "", which Thanos defaults to "exact" matching behavior. That said, validating early in ParseConfig via a custom UnmarshalJSON on tenantMatcher makes total sense—it's a much cleaner way to fail fast on invalid matchers while still accepting "exact", "glob", and "". I'm working on implementing the custom unmarshaler and adding the corresponding unit tests soon! |
- Add custom UnmarshalJSON for tenantMatcher to fail fast on invalid types and explicit empty strings - Hydrate omitted tenant_matcher_type fields to 'exact' in ParseConfig - Add table-driven tests for tenantMatcher unmarshaling Signed-off-by: Bisshwajit Samanta <bisshwajitsamanta@gmail.com>
293e58f to
92b53a3
Compare
Summary of Changes
Verification Output |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8974 +/- ##
==========================================
+ Coverage 64.50% 64.53% +0.02%
==========================================
Files 289 289
Lines 37352 37372 +20
==========================================
+ Hits 24094 24117 +23
+ Misses 11160 11156 -4
- Partials 2098 2099 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dc180cc to
c68e281
Compare
97975ab to
9b79b8e
Compare
- Remove redundant empty string case from getShardSize since ParseConfig hydrates omitted fields to exact - Rely strictly on TenantMatcherTypeExact and TenantMatcherGlob at runtime Signed-off-by: Bisshwajit Samanta <bisshwajitsamanta@gmail.com>
Signed-off-by: Bisshwajit Samanta <bisshwajitsamanta@gmail.com>
Signed-off-by: Bisshwajit Samanta <bisshwajitsamanta@gmail.com>
Signed-off-by: Bisshwajit Samanta <bisshwajitsamanta@gmail.com>
9b79b8e to
3d7a99f
Compare
|
Hi @GiedriusS , I've completed the implementation and updated the test suite. All CI checks (including DCO sign-off) are now green. 📌 Summary of Changes:
The PR is ready for final review and approval! 🚀 |
Description ⚙️
When
tenant_matcher_typeis omitted in a shuffle sharding override configuration, Go's YAML parser initializes the struct field as""(empty string) due to theomitemptytag. Previously,getShardSize()only checked forTenantMatcherTypeExact("exact"), causing overrides with an omitted matcher type to be silently skipped and fall back to the default shard size.This PR updates the
switchevaluation ingetShardSize()to match bothTenantMatcherTypeExactand"", restoring the expected default fallback behavior.Special Notes for Reviewer 🧪
""to the exact matchcasestatement inreceive/hashring.go.receive/hashring_test.goto verify that overrides apply correctly whentenant_matcher_typeis omitted.