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

fix: Fix CR cache for GVK all specified case #2567

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

chelseychen
Copy link
Contributor

@chelseychen chelseychen commented Dec 2, 2024

What this PR does / why we need it:

Currently in CR discoverer, for the case where the GVK are all specified for a CR in CRS config (see below example) but CRD not registered, it will still have that CR enabled in CR factories.

kind: CustomResourceStateMetrics
spec:
  resources:
    - groupVersionKind:
        group: jobset.x-k8s.io
        kind: "JobSet"
        version: "v1alpha2"

The expected behaviour is that that resource shouldn't be enabled since the cache map doesn't contain that CRD.

This PR fixes this issue.

How does this change affect the cardinality of KSM: (increases, decreases or does not change cardinality)

No change for cardinality.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #2566

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Dec 2, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If kube-state-metrics contributors determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot requested review from mrueg and rexagod December 2, 2024 20:19
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 2, 2024
@mrueg mrueg changed the title Fix CR cache for GVK all specified case fix: Fix CR cache for GVK all specified case Dec 2, 2024
@chelseychen chelseychen force-pushed the fix-ResolveGVKToGVKPs branch from 7f469c5 to d8fb76d Compare December 2, 2024 20:43
Copy link
Member

@rexagod rexagod left a comment

Choose a reason for hiding this comment

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

Good catch, thank you! Just one nit.

Comment on lines +167 to +182
desc: "fixed version and kind, no matching cache entry",
gvkmaps: &CRDiscoverer{
Map: map[string]map[string][]kindPlural{
"testgroup": {
"v1": {
kindPlural{
Kind: "TestObject2",
Plural: "testobjects2",
},
},
},
},
},
gvk: schema.GroupVersionKind{Group: "testgroup", Version: "v1", Kind: "TestObject1"},
want: nil,
},
Copy link
Member

Choose a reason for hiding this comment

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

I believe this is the only test case needed to verify the change above (the fact that the first case ends up taking whatever the group is). The other three seem to pass before this patch too.

@chelseychen chelseychen force-pushed the fix-ResolveGVKToGVKPs branch from d8fb76d to 5631601 Compare December 5, 2024 03:23
@chelseychen chelseychen requested a review from rexagod December 5, 2024 03:27
@rexagod
Copy link
Member

rexagod commented Dec 5, 2024

/lgtm

Thank you!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 5, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chelseychen, 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 5, 2024
@k8s-ci-robot k8s-ci-robot merged commit ca0df61 into kubernetes:main Dec 5, 2024
12 checks passed
@chelseychen chelseychen deleted the fix-ResolveGVKToGVKPs branch December 5, 2024 15:30
@mrueg mrueg added this to the v2.15.0 milestone Jan 29, 2025
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

List/watch store shouldn't be created for non-existing CRD
4 participants