Skip to content

Conversation

taraspos
Copy link
Contributor

@taraspos taraspos commented Aug 4, 2025

What this PR does / why we need it:

Fixes following panic:

E0804 12:57:09.762257       1 panic.go:115] "Observed a panic" panic="runtime error: index out of range [1] with length 1" panicGoValue="runtime.boundsError{x:1, y:1, signed:true, code:0x0}" stacktrace=<
        goroutine 233 [running]:
        k8s.io/apimachinery/pkg/util/runtime.logPanic({0x27e71d0, 0x3c38b80}, {0x22cf3a0, 0xc00272ea08})
                /go/pkg/mod/k8s.io/apimachinery@v0.32.6/pkg/util/runtime/runtime.go:107 +0xbc
        k8s.io/apimachinery/pkg/util/runtime.handleCrash({0x27e71d0, 0x3c38b80}, {0x22cf3a0, 0xc00272ea08}, {0x3c38b80, 0x0, 0x10000c002706f60?})
                /go/pkg/mod/k8s.io/apimachinery@v0.32.6/pkg/util/runtime/runtime.go:82 +0x5a
        k8s.io/apimachinery/pkg/util/runtime.HandleCrash({0x0, 0x0, 0x2540be400?})
                /go/pkg/mod/k8s.io/apimachinery@v0.32.6/pkg/util/runtime/runtime.go:59 +0x105
        panic({0x22cf3a0?, 0xc00272ea08?})
                /usr/local/go/src/runtime/panic.go:792 +0x132
        k8s.io/kube-state-metrics/v2/pkg/customresourcestate.compilePath.func2({0x1f22ea0?, 0xc002706ea0?})
                /go/src/k8s.io/kube-state-metrics/pkg/customresourcestate/registry_factory.go:658 +0x24a
        k8s.io/kube-state-metrics/v2/pkg/customresourcestate.valuePath.Get(...)
                /go/src/k8s.io/kube-state-metrics/pkg/customresourcestate/registry_factory.go:564
        k8s.io/kube-state-metrics/v2/pkg/customresourcestate.addPathLabels({0x21177a0, 0xc002705d70}, 0xc0011d9080, 0xc002778ea0)
                /go/src/k8s.io/kube-state-metrics/pkg/customresourcestate/registry_factory.go:543 +0x552
        k8s.io/kube-state-metrics/v2/pkg/customresourcestate.compiledFamily.BaseLabels({{0x7f25fd19f198, 0xc000d4bd40}, 0xc0011d8f90, 0xc0011d9080, {0xc003d0a740, 0x39}, {0xc000058e10, 0x44}, 0x0}, 0xc002705d70)
                /go/src/k8s.io/kube-state-metrics/pkg/customresourcestate/registry_factory.go:514 +0x13c
        k8s.io/kube-state-metrics/v2/pkg/customresourcestate.generate(0xc00019a7f8, {{0x7f25fd19f198, 0xc000d4bd40}, 0xc0011d8f90, 0xc0011d9080, {0xc003d0a740, 0x39}, {0xc000058e10, 0x44}, 0x0}, ...)
                /go/src/k8s.io/kube-state-metrics/pkg/customresourcestate/registry_factory.go:684 +0x248
        k8s.io/kube-state-metrics/v2/pkg/customresourcestate.famGen.func1({0x2452f00?, 0xc00019a7f8?})
                /go/src/k8s.io/kube-state-metrics/pkg/customresourcestate/registry_factory.go:675 +0x65
        k8s.io/kube-state-metrics/v2/pkg/metric_generator.(*FamilyGenerator).Generate(0xc000993a08, {0x2452f00?, 0xc00019a7f8?})
                /go/src/k8s.io/kube-state-metrics/pkg/metric_generator/generator.go:73 +0x2f
        k8s.io/kube-state-metrics/v2/internal/store.(*Builder).buildCustomResourceStores.ComposeMetricGenFuncs.func1({0x2452f00, 0xc00019a7f8})
                /go/src/k8s.io/kube-state-metrics/pkg/metric_generator/generator.go:117 +0xf0
        k8s.io/kube-state-metrics/v2/pkg/metrics_store.(*MetricsStore).Add(0xc00042bea0, {0x2452f00, 0xc00019a7f8})
                /go/src/k8s.io/kube-state-metrics/pkg/metrics_store/metrics_store.go:65 +0x65
        k8s.io/kube-state-metrics/v2/pkg/metrics_store.(*MetricsStore).Replace(0xc00042bea0, {0xc00270f1e0, 0x2, 0x3c159e0?}, {0x247d328?, 0x11?})
                /go/src/k8s.io/kube-state-metrics/pkg/metrics_store/metrics_store.go:122 +0x68
        k8s.io/client-go/tools/cache.(*Reflector).syncWith(0xc0005b1590, {0xc00270f1c0, 0x2, 0x0?}, {0xc00270ac78, 0x8})
                /go/pkg/mod/k8s.io/client-go@v0.32.6/tools/cache/reflector.go:726 +0x123
        k8s.io/client-go/tools/cache.(*Reflector).list(0xc0005b1590, 0xc003cf0f50)
                /go/pkg/mod/k8s.io/client-go@v0.32.6/tools/cache/reflector.go:599 +0x7a5
        k8s.io/client-go/tools/cache.(*Reflector).ListAndWatch(0xc0005b1590, 0xc003cf0f50)
                /go/pkg/mod/k8s.io/client-go@v0.32.6/tools/cache/reflector.go:370 +0x285
        k8s.io/client-go/tools/cache.(*Reflector).Run.func1()
                /go/pkg/mod/k8s.io/client-go@v0.32.6/tools/cache/reflector.go:315 +0x25
        k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1(0xc000180008?)
                /go/pkg/mod/k8s.io/apimachinery@v0.32.6/pkg/util/wait/backoff.go:226 +0x33
        k8s.io/apimachinery/pkg/util/wait.BackoffUntil(0xc000993f98, {0x27c1dc0, 0xc0001f4730}, 0x1, 0xc003cf0f50)
                /go/pkg/mod/k8s.io/apimachinery@v0.32.6/pkg/util/wait/backoff.go:227 +0xaf
        k8s.io/client-go/tools/cache.(*Reflector).Run(0xc0005b1590, 0xc003cf0f50)
                /go/pkg/mod/k8s.io/client-go@v0.32.6/tools/cache/reflector.go:314 +0x1af
        created by k8s.io/kube-state-metrics/v2/internal/store.(*Builder).startReflector in goroutine 118
                /go/src/k8s.io/kube-state-metrics/internal/store/builder.go:624 +0x3f3

How does this change affect the cardinality of KSM: (increases, decreases or does not change cardinality)
Doesn't affect 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 #2718

Copy link

linux-foundation-easycla bot commented Aug 4, 2025

CLA Signed


The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Aug 4, 2025
@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 needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Aug 4, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @taraspos!

It looks like this is your first PR to kubernetes/kube-state-metrics 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kube-state-metrics has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Aug 4, 2025
@mrueg mrueg changed the title customresourcestate: fix panic fix(customresourcestate): fix panic Aug 4, 2025
@taraspos taraspos changed the title fix(customresourcestate): fix panic fix(customresourcestate): fix index out of range Aug 4, 2025
@mrueg
Copy link
Member

mrueg commented Aug 4, 2025

Thanks, looks like I made a mistake when migrating to golangci-lint v2.

Can you sign the CLA?

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 4, 2025
@mrueg
Copy link
Member

mrueg commented Aug 4, 2025

/lgtm

Thanks for the quick response!

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

[APPROVALNOTIFIER] This PR is APPROVED

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

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 Aug 4, 2025
@k8s-ci-robot k8s-ci-robot merged commit 9add5df into kubernetes:main Aug 4, 2025
14 of 15 checks passed
@taraspos taraspos deleted the patch-1 branch August 4, 2025 18:55
@taraspos
Copy link
Contributor Author

taraspos commented Aug 4, 2025

Thanks @mrueg ,
Would it be possible to release a new patch version with the fix?

@taraspos taraspos mentioned this pull request Aug 25, 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/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.

Panic due to an index out of range
3 participants