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: panic in util.GVRFromType for core objects #2535

Merged
merged 1 commit into from
Oct 27, 2024

Conversation

L3n41c
Copy link
Contributor

@L3n41c L3n41c commented Oct 25, 2024

What this PR does / why we need it:

Fixes a panic in the util.GVRFromType function when called for a core object.

For a pod object, for example, the apiVersion would be v1,

expectedTypeSlice := strings.Split(apiVersion, "/")

would return a slice of a single element because apiVersion has no /.
And

v := expectedTypeSlice[1]

would panic because of an array out-of-bound access.

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

Does not change.

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 #

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 25, 2024
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Oct 25, 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 added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Oct 25, 2024
@CatherineF-dev
Copy link
Contributor

Core resource metrics are exposed using these functions https://github.com/kubernetes/kube-state-metrics/tree/main/internal/store

@L3n41c L3n41c changed the title Fix a panic in util.GVRFromType for core objects fix: panic in util.GVRFromType for core objects Oct 25, 2024
@mrueg
Copy link
Member

mrueg commented Oct 27, 2024

Core resource metrics are exposed using these functions https://github.com/kubernetes/kube-state-metrics/tree/main/internal/store

Yes, that's correct. We keep core resource metrics internal.
I still agree that the function shouldn't panic when used externally (or we should move the whole code into internal)

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: L3n41c, mrueg

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 Oct 27, 2024
@k8s-ci-robot k8s-ci-robot merged commit eb5e347 into kubernetes:main Oct 27, 2024
12 of 13 checks passed
@L3n41c L3n41c deleted the fix_gvrfromtype branch October 29, 2024 20:51
@mrueg mrueg added this to the v2.14.0 milestone Nov 6, 2024
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/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants