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

internal/store: fix metrics slice length #1731

Merged

Conversation

jan--f
Copy link
Contributor

@jan--f jan--f commented May 9, 2022

Problem: In #1723 a
potential panic in the pod metrics gathering was fixed by working around
a disconnect of Spec.Containers and Status.ContainerStatuses. The
slice storing the resulting metrics however was still defined based on
the length of the Status.ContainerStatuses list.

Solution: Make the slice dynamic and append metrics to it.

Signed-off-by: Jan Fajerski [email protected]

What this PR does / why we need it:

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

Problem: In kubernetes#1723 a
potential panic in the pod metrics gathering was fixed by working around
a disconnect of `Spec.Containers` and `Status.ContainerStatuses`. The
slice storing the resulting metrics however was still defined based on
the length of the `Status.ContainerStatuses` list.

Solution: Make the slice dynamic and append metrics to it.

Signed-off-by: Jan Fajerski <[email protected]>
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented May 9, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: jan--f / name: Jan Fajerski (85c6b44)

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 9, 2022
@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 May 9, 2022
@fpetkovski
Copy link
Contributor

Thanks. Instead of trying to guess the slice length, I think this is the more sane approach.

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fpetkovski, jan--f

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 May 10, 2022
@k8s-ci-robot k8s-ci-robot merged commit 9e97bb1 into kubernetes:master May 10, 2022
honpey pushed a commit to honpey/kube-state-metrics that referenced this pull request May 17, 2022
In kubernetes#1731,
the dynamic slice was introduced to fix potential panic under
Spec.Containers scenario, however there may be same panic for
Spec.InitContainers scenario.

This patch fix it referring to kubernetes#1731
honpey added a commit to honpey/kube-state-metrics that referenced this pull request May 17, 2022
In kubernetes#1731,
the dynamic slice was introduced to fix potential panic under
Spec.Containers scenario, however there may be same panic for
Spec.InitContainers scenario.

This patch fix it referring to kubernetes#1731

Signed-off-by: honpey <[email protected]>
honpey added a commit to honpey/kube-state-metrics that referenced this pull request May 30, 2022
In kubernetes#1731,
the dynamic slice was introduced to fix potential panic under
Spec.Containers scenario, however there may be same panic for
Spec.InitContainers scenario.

This patch fix it referring to kubernetes#1731

Signed-off-by: honpey <[email protected]>
@mrueg mrueg mentioned this pull request Jun 2, 2022
sherifabdlnaby pushed a commit to sherifabdlnaby/kube-state-metrics that referenced this pull request Jul 9, 2022
In kubernetes#1731,
the dynamic slice was introduced to fix potential panic under
Spec.Containers scenario, however there may be same panic for
Spec.InitContainers scenario.

This patch fix it referring to kubernetes#1731

Signed-off-by: honpey <[email protected]>
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. 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.

3 participants