-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[processor/k8sattributes] agent passthrough, gateway k8s.pod.ip configuration broken post v0.55.0 release #13765
Comments
Pinging code owners: @owais @dmitryax. See Adding Labels via Comments if you do not have permissions to add labels yourself. |
Hi @evantorrie I made a fix based on your suggestion, but need to reproduce issue in order to confirm the solution |
Do we have any existing integration tests which set up a collector in an agent/gateway deployment in a k8s cluster? |
I do not know about such |
@sumo-drosiek I created a repo with instructions (and appropriate files) to reliably reproduce the problem of Resources failing to get augmented with k8s metadata. Reproduction instructions demonstrate it working with opentelemetry-collector-contrib:0.54.0, but failing as soon as it's upgraded to opentelemetry-collector-contrib:0.55.0. Here: https://github.com/evantorrie/k8sattributes-repro |
@evantorrie It helped a lot. I confirm that after the fix, the output looks the following way:
image is available as:
if you want to test it on your own |
Yes. Works for me! |
Describe the bug
In an agent/gateway k8s deployment, the
k8sattributes
processor no longer correctly adds k8s metadata to the Resource associated with traces emitted by a pod elsewhere in the cluster. I suspect this may have broken due to PR #8465Steps to reproduce
Create a daemonset agent/deployment gateway collector setup in a k8s cluster with the configuration files shown below. Generate traces from a pod that sends to the local daemonset agent pod. Observe the debug logs on the gateway collector.
What did you expect to see?
Logs for each ResourceSpans indicating each Resource with a preexisting
k8s.pod.ip
attribute had the Resource augmented withk8s.namespace.name
,k8s.pod.uid
andk8s.pod.name
.What did you see instead?
Logs showing the incoming traces have a
Resource
with the correct pod IP in thek8s.pod.ip
attribute, but none ofk8s.namespace.name
,k8s.pod.uid
nork8s.pod.name
.What version did you use?
Version: v0.56.0
What config did you use?
On the agent side:
and on the gateway side
Environment
OS: RHEL8 Linux
Compiler(if manually compiled): go1.17
Additional context
From the extension debug logs, the incoming Resource is already augmented by the agent pod with
k8s.pod.ip=<podIP>
.In
kubernetesprocessor.processResource()
, the debug message"evaluating pod identifier [ {Source: { From: "resource_attribute", Name: "k8s.pod.ip" }, Value: "<podIp>" }, ..]"
is printed, but it appears to return false fromWatchClient.GetPod(<podIdentifier>)
. This seems to indicate that there is no entry inc.Pods[]
for that specific PodIdentifier.The primary place in the code where pods are added to the
c.Pods[]
map is inWatchClient.addOrUpdatePod()
.Prior to the aforementioned PR, the keys for the Pods map were Strings containing either the IP address or the pod UID, and there was no distinction between whether it came from the "connection" or from a "resource_attribute".
After the PR, the key(s) returned from
WatchClient.getIdentifiersFromAssoc()
are inserted into the Pods map, with each key pointing to the pod info. To correctly match the key which is printed inevaluating pod identifier...
,getIdentifiersFromAssoc()
should return the key{Source: { From: "resource_attribute", Name: "k8s.pod.ip" }, Value: "<podip>" }
when given the input association specification, namely:Based on code inspection, it appears this does not happen. I suspect changing the switch statement in
getIdentifiersFromAssoc()
from:to
would probably fix this problem. But I have only ascertained this via code inspection, not compiling and running the code!
Possibly related: #13119
The text was updated successfully, but these errors were encountered: