Skip to content

Fix potential panic in cgroup metrics in memory when it is nil. #9906

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

Closed
wants to merge 1 commit into from
Closed

Fix potential panic in cgroup metrics in memory when it is nil. #9906

wants to merge 1 commit into from

Conversation

zhanluxianshen
Copy link
Contributor

/kind cleanup

Fix potential panic in cgroup metrics in memory when it is nil.

Signed-off-by: zhanluxianshen <zhanluxianshen@163.com>
@k8s-ci-robot
Copy link

Hi @zhanluxianshen. Thanks for your PR.

I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

@@ -591,6 +600,9 @@ var memoryMetrics = []*metric{
unit: metrics.Bytes,
vt: prometheus.GaugeValue,
getValues: func(stats *v1.Metrics) []value {
if stats.Memory == nil {
Copy link
Member

Choose a reason for hiding this comment

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

Don't GetMemory() and chained funcs already handle this?

Copy link
Contributor Author

@zhanluxianshen zhanluxianshen Mar 1, 2024

Choose a reason for hiding this comment

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

Yep, I although can close this one.

But should not we keep the check nil before ? this will reduce the consule of method call stack twice.

@dcantah
Copy link
Member

dcantah commented Mar 2, 2024

Agree with @ktock, the grpc getters already handle the nil checks. While saving a stack frame is the plus, I don't think this is really worth it.

@zhanluxianshen
Copy link
Contributor Author

zhanluxianshen commented Mar 2, 2024

Thanks for quick response.
Close it .
I will go to others code to do that clean . 😂😂

@zhanluxianshen zhanluxianshen deleted the clean-metrics-cgroup-1 branch March 2, 2024 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants