Skip to content
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

Allow optional VK in CR metrics #1851

Merged
merged 1 commit into from
May 19, 2023
Merged

Allow optional VK in CR metrics #1851

merged 1 commit into from
May 19, 2023

Conversation

rexagod
Copy link
Member

@rexagod rexagod commented Oct 7, 2022

What this PR does / why we need it: Allow optional VK in CR metrics, while only requiring the group to be fixed. This would allow users to define custom metrics for:

  • a specific API version: version is fixed, kind varies.
  • all the API versions of a resource: version varies, kind is fixed.
  • all the APIs part of an API group: version varies, kind varies.

How does this change affect the cardinality of KSM: Increases, or stays the same, depending on the cardinality of the version(s) and/or kind(s), present under a group.

Which issue(s) this PR fixes: Fixes #1848

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 7, 2022
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Oct 7, 2022
@rexagod rexagod changed the title Represent GVK information as labels Allow optional VK in CR metrics Oct 7, 2022
@rexagod rexagod force-pushed the 1848 branch 2 times, most recently from 91acc37 to 09bec65 Compare October 7, 2022 21:25
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 7, 2022
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 4, 2022
@logicalhan
Copy link
Member

There seems to be angry bots yelling about things in the integration tests.

@rexagod
Copy link
Member Author

rexagod commented Nov 8, 2022

@logicalhan Yes, checks were passing with the older implementation (till the first fixup commit), but due to the half-baked rewrite they are failing now (support for multi-valued VKs is not yet fully implemented here). I wanted to reach a consensus first on the approach we should be going with (in the thread above), as I wasn't fully sure, before going futher with the code changes.

@rexagod
Copy link
Member Author

rexagod commented Nov 17, 2022

After proposing the following plan to @mrueg in order to have a much more performant implementation in place, I'm reworking this PR to adhere to the following:

  • We watch CRDs.
  • Whenever a CRD is created, edited, or removed, we update the CRD store, always knowing which CRDs are present on the cluster.
  • CRs will always be created based on those CRDs, which in turn have the GVK for those resources.
  • So ultimately, we always know the exhaustive list of GVKs for CRs, at any point of time in the cluster.
  • We pass that information to the existing mechanism (as mentioned in the comment above) and from there onwards, things would be the same as they were.

However, currently, we have the CRD types to implement this feature, but if I'm not mistaken client-go's clientset seems to lack apiextension support.

I suppose we can go ahead with releasing v2.7.0, because this could take some time, as some of the implementation details are uncertain at the moment.

False alarm, I missed this, resuming work on this.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 17, 2022
@dashpole dashpole added the kind/feature Categorizes issue or PR as related to a new feature. label Nov 17, 2022
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 17, 2022
internal/store/builder.go Outdated Show resolved Hide resolved
@logicalhan
Copy link
Member

(for other reviewers)

@rexagod rexagod requested a review from mrueg May 19, 2023 19:52
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 19, 2023
@rexagod rexagod requested a review from logicalhan May 19, 2023 19:52
@logicalhan
Copy link
Member

/lgtm
/hold cancel

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels May 19, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: logicalhan, 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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rexagod
Copy link
Member Author

rexagod commented May 19, 2023

FYI @\reviewers, just pushed #1851 (comment) and #1851 (comment) in the latest commit, nothing else.

Add support for variable VKs in CRS config, while maintaining a cache
of discovered GVKs in the cluster, and updating it every 30s.

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 19, 2023
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot merged commit 5010c4a into kubernetes:main May 19, 2023
6 checks passed
@mrueg
Copy link
Member

mrueg commented May 21, 2023

🥳 thanks for your work on this @rexagod

@rexagod
Copy link
Member Author

rexagod commented May 22, 2023

Thank you for the all the top-notch reviews that helped shape this PR, @mrueg @logicalhan @dgrisonnet! 🥳

@rexagod rexagod mentioned this pull request May 23, 2023
robbat2 added a commit to coreweave/kube-state-metrics that referenced this pull request Jun 28, 2024
PR#1851 introduced accidental breakage for custom metrics on resources
with an empty empty, e.g. Node.

Fix it, and add tests to catch the next breakage.

Reference: kubernetes#1851
Signed-off-by: Robin H. Johnson <rjohnson@coreweave.com>
Fixes: kubernetes#2434
robbat2 added a commit to coreweave/kube-state-metrics that referenced this pull request Jun 28, 2024
PR#1851 introduced accidental breakage for custom metrics on resources
with an empty empty, e.g. Node.

Fix it, and add tests to catch the next breakage.

Reference: kubernetes#1851
Reference: kubernetes#2434
Signed-off-by: Robin H. Johnson <rjohnson@coreweave.com>
robbat2 added a commit to coreweave/kube-state-metrics that referenced this pull request Jun 28, 2024
PR#1851 introduced accidental breakage for custom metrics on resources
with an empty empty, e.g. Node.

Fix it, and add tests to catch the next breakage.

Reference: kubernetes#1851
Reference: kubernetes#2434
Signed-off-by: Robin H. Johnson <rjohnson@coreweave.com>
robbat2 added a commit to coreweave/kube-state-metrics that referenced this pull request Jun 28, 2024
PR#1851 introduced accidental breakage for custom metrics on resources
with an empty empty, e.g. Node.

Fix it, and add tests to catch the next breakage.

```
demo_timestamp{customresource_group="",customresource_kind="Node",customresource_version="v1",node="kind-control-plane"} 1.719618433e+09
```

Reference: kubernetes#1851
Reference: kubernetes#2434
Signed-off-by: Robin H. Johnson <rjohnson@coreweave.com>
robbat2 added a commit to coreweave/kube-state-metrics that referenced this pull request Jun 29, 2024
PR#1851 introduced accidental breakage for custom metrics on resources
with an empty empty, e.g. Node.

Fix it, and add tests to catch the next breakage.

```
demo_timestamp{customresource_group="",customresource_kind="Node",customresource_version="v1",node="kind-control-plane"} 1.719618433e+09
```

Reference: kubernetes#1851
Reference: kubernetes#2434
Signed-off-by: Robin H. Johnson <rjohnson@coreweave.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

We should be able to watch all CRDs in a given APIGroup
6 participants