-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Allow prefixing wildcard labelsFromPath
#2052
Conversation
|
c0605bd
to
7ead8b6
Compare
labelsFromPath
/triage accepted |
After looking a bit closer at what this does, do the semantics of this syntax look intentional to users? If I see |
7ead8b6
to
2957903
Compare
Closing in favor of the newer model. |
Reopening in favor of #2068 (comment). |
/triage accepted |
2957903
to
e35fe45
Compare
labelsFromPath
labelsFromPath
Allow prefixing * paths, for instance, foo_*: [foo, bar, baz], will result in foo_baz being the key for all object resolutions under baz. Signed-off-by: Pranshu Srivastava <[email protected]>
e35fe45
to
a379639
Compare
Up for reviews. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just support globbing in general for labels from path and use https://github.com/gobwas/glob instead of doing the parsing manually?
For the CRS snippet below, the output will contain labels with the prefix labelsFromPath:
"foo_*": ["bar", "fooObj"] An actual regex match over a sample set of |
This basically builds on top of the originally present |
I can modify this PR, or send another patch in the future to truly denote |
Do you mean supporting expressions such as |
@@ -134,12 +134,15 @@ func Test_addPathLabels(t *testing.T) { | |||
{name: "*", args: args{ | |||
obj: cr, | |||
labels: map[string]valuePath{ | |||
"*1": mustCompilePath(t, "metadata", "annotations"), | |||
"bar": mustCompilePath(t, "metadata", "labels", "foo"), | |||
"*1": mustCompilePath(t, "metadata", "annotations"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to the actual PR, but why does *1
yield "qux": "quxx"
. Is this the way we tell the code to take the first annotation?
Disregard #2052 (review), I got super confused with the syntax. The use of the The current approach has 4 scenarios:
This relies on an implicit behavior from the parser that requires users to have an understand of the code. Whereas we could make it more expressive and have something like:
IMO, the more explicit a syntax is, the easier it is for an external user to understand. Prometheus-adapter is a prime example of a very bad syntax. Its configuration was made overly complex in an attempt to make it more generic and adaptable (I guess), but the result is that it confuses everyone and discourage users from using the project. rules:
- seriesQuery: '{__name__=~"^container_.*",container!="POD",namespace!="",pod!=""}'
resources:
overrides:
namespace: {resource: "namespace"}
pod: {resource: "pod"}
name:
matches: "^container_(.*)_seconds_total$"
metricsQuery: "sum(rate(<<.Series>>{<<.LabelMatchers>>,container!="POD"}[2m])) by (<<.GroupBy>>)" We need to avoid reaching that point at all cost. |
I see. My only concern here is when moving from,
to,
will require multiple
as compared to,
which may give rise to ambiguous conclusions since there's a |
I see what you mean here, although that was already the case implicitly, it will now be explicit and could be very confusing. Maybe we could call it |
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
@dgrisonnet Please correct me if I'm wrong but I believe transforming
could either be,
or,
both being breaking changes to the existing configuration interpretation logic IIUC. |
Yes it would be a breaking changes. That would also be the case for this comment on your other PR which would apply also here: #2068 (comment) We will need to break the config entirely if we want to build solid foundation with CEL, so hopefully we will change it in the future. In the meantime we can continue with the current UX, but we will need to draw a line at one point. I would be fine with drawing it once your two PRs are merged and then stop accepting feature requests until we've migrated to CEL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dgrisonnet, mrueg, rexagod The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What this PR does / why we need it: Allow prefixing * paths, for instance, a "foo_" prefix like so, foo_*: [foo, bar, baz], will result in foo_baz being the key for all object resolutions under baz.
How does this change affect the cardinality of KSM: No change.
Which issue(s) this PR fixes: Self-driven.