Fix potential panic in cgroup metrics in memory when it is nil.#9906
Fix potential panic in cgroup metrics in memory when it is nil.#9906zhanluxianshen wants to merge 1 commit intocontainerd:mainfrom zhanluxianshen:clean-metrics-cgroup-1
Conversation
Signed-off-by: zhanluxianshen <[email protected]>
|
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 Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
| unit: metrics.Bytes, | ||
| vt: prometheus.GaugeValue, | ||
| getValues: func(stats *v1.Metrics) []value { | ||
| if stats.Memory == nil { |
There was a problem hiding this comment.
Don't GetMemory() and chained funcs already handle this?
There was a problem hiding this comment.
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.
|
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. |
|
Thanks for quick response. |
/kind cleanup
Fix potential panic in cgroup metrics in memory when it is nil.