ROX-33893: glob patterns for header name#19723
Conversation
|
Images are ready for the commit at f2435e7. To use with deploy scripts, first |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #19723 +/- ##
=======================================
Coverage 49.60% 49.60%
=======================================
Files 2763 2763
Lines 208271 208301 +30
=======================================
+ Hits 103309 103337 +28
- Misses 97294 97295 +1
- Partials 7668 7669 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
2e708df to
27967f6
Compare
737025b to
8050edc
Compare
8050edc to
694e641
Compare
2aa5f95 to
5f7202d
Compare
e6be8b7 to
a2443b7
Compare
a2443b7 to
9024b12
Compare
9024b12 to
f2435e7
Compare
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe changes refactor header matching logic to support glob patterns for both header names and values instead of just values, updating method signatures and implementations across the telemetry and phonehome packages, including tests and telemetry client usage. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pkg/telemetry/phonehome/headers_multimap.go`:
- Around line 54-74: GetMatching on Headers returns nil for a nil/empty Headers
when value == NoHeaderOrAnyValue, causing inconsistent behavior versus the
loop's special-case; update Headers.GetMatching so that if h is nil (or empty)
and value == NoHeaderOrAnyValue it returns an empty map instead of nil, e.g. in
the beginning of GetMatching check if value == NoHeaderOrAnyValue and return
make(map[string][]string) when h == nil (and then remove/keep the in-loop
initialization accordingly); reference: Headers.GetMatching, NoHeaderOrAnyValue,
GetMatchingValues.
In `@pkg/telemetry/phonehome/request_params.go`:
- Around line 34-45: RequestParams.MatchHeaders currently uses maps.Copy to
merge per-pattern matches which causes later patterns to overwrite earlier
concrete header entries (non-deterministic for overlapping globs). Replace the
maps.Copy(result, matching) behavior in RequestParams.MatchHeaders with a
per-key merge: iterate over each concrete header key returned by GetMatching and
if that header already exists in result, combine/union the values instead of
replacing them; ensure the merge semantics match the Headers type (e.g., append
or deduplicate values). Alternatively, add a validation step when constructing
the GlobMap to detect and reject overlapping header-name patterns (X-* vs
X-Test) so MatchHeaders can keep deterministic behavior; reference
RequestParams.MatchHeaders, GetMatching, Headers, GlobMap and NoHeaderOrAnyValue
when implementing the fix.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Central YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: d7b9db3c-5c82-43f3-afa3-2e6d81168f75
📒 Files selected for processing (10)
central/telemetry/centralclient/interceptors.gocentral/telemetry/centralclient/interceptors_test.gopkg/telemetry/phonehome/campaign.gopkg/telemetry/phonehome/campaign_test.gopkg/telemetry/phonehome/headers_multimap.gopkg/telemetry/phonehome/headers_multimap_test.gopkg/telemetry/phonehome/interceptor.gopkg/telemetry/phonehome/interceptor_test.gopkg/telemetry/phonehome/request_params.gopkg/telemetry/phonehome/request_params_test.go
|
/retest |
|
/retest |
646fe3c to
1b30c5d
Compare
🚀 Build Images ReadyImages are ready for commit 1b30c5d. To use with deploy scripts: export MAIN_IMAGE_TAG=4.11.x-561-g1b30c5da4e |
Description
Support glob patterns in telemetry header names, not just values. Previously, campaigns could only match exact header names. Now both header names and values support globs (e.g.,
"Rh-*": NoHeaderOrAnyValue).Key changes:
APICallCampaignCriterion.Headers:map[string]glob.Pattern->map[glob.Pattern]glob.PatternHeaders.GetAll: matches both header names and values using globs"Rh-*"pattern instead of hardcoded header nameMotivation:
ServiceNow sets headers with a common
Rh-prefix, but the exact name may vary. Glob patterns for header names allow tracking related headers without hardcoding each variant.User-facing documentation
Testing and quality
Automated testing
How I validated my change
Headersfield"Rh-*"pattern matchinggo test ./pkg/telemetry/phonehome/... ./central/telemetry/centralclient/...Current dependencies on/for this PR: