[receiver/k8s_cluster] [chore] Fix nil dereference in setting image attributes#47538
Closed
kangyili wants to merge 3 commits into
Closed
[receiver/k8s_cluster] [chore] Fix nil dereference in setting image attributes#47538kangyili wants to merge 3 commits into
kangyili wants to merge 3 commits into
Conversation
dmitryax
reviewed
Apr 10, 2026
dmitryax
left a comment
Member
There was a problem hiding this comment.
Thank you for catching this before the release!
| return 0, false | ||
| } | ||
|
|
||
| func TestRecordSpecMetrics(t *testing.T) { |
Member
There was a problem hiding this comment.
Thanks for the additional coverage. The preferred pattern in such tests is pkg/golden + pmetrictest.CompareMetrics. See the sibling pod package for reference. If that feels like too much, moving metricValue helper to receiver/k8sclusterreceiver/internal/testutils/metrics.go would at least keep it reusable.
dmitryax
reviewed
Apr 10, 2026
| # Use this changelog template to create an entry for release notes. | ||
|
|
||
| # One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
| change_type: bug_fix |
Member
There was a problem hiding this comment.
This bug seems to be introduced in #46542 ind hasn't been released yet. So we don't need a changelog in this case
dmitryax
added a commit
that referenced
this pull request
Apr 10, 2026
…cs when container status is missing (#47554) Replacing #47538 as we need to merge it before the next release to avoid regression. Guard `docker.ParseImageName` and `LastTerminationState` access under a single cs != nil block to avoid a panic when a container spec exists but kubelet has not yet reported its status. Taking opportunity to increase test coverage of the `receiver/k8sclusterreceiver/internal/container` package
Member
AndrewCharlesHay
pushed a commit
to AndrewCharlesHay/opentelemetry-collector-contrib
that referenced
this pull request
Apr 23, 2026
…cs when container status is missing (open-telemetry#47554) Replacing open-telemetry#47538 as we need to merge it before the next release to avoid regression. Guard `docker.ParseImageName` and `LastTerminationState` access under a single cs != nil block to avoid a panic when a container spec exists but kubelet has not yet reported its status. Taking opportunity to increase test coverage of the `receiver/k8sclusterreceiver/internal/container` package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a pod has no matching
ContainerStatusentry for a given container (e.g. the container spec exists but kubelet hasn't reported status yet),csisnil. The call todocker.ParseImageName(cs.Image)was not guarded by the existingcs != nilcheck, causing a panic at runtime.The issue was found when testing with image
otel/opentelemetry-collector-contrib-dev:latest