wip: Get container name from annotation for containerd #1004
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.
What type of PR is this?
/kind bug
Any specific area of the project related to this PR?
/area plugins
What this PR does / why we need it:
This addresses an issue with the "container" plugin.
The container name is not correctly pulled in when fetching from a containerd source. It uses the shortened container ID instead. This change pulls in the container name from the K8s annotation if it exists and is not empty, otherwise defaulting back to the shortened container ID.
Which issue(s) this PR fixes:
Special notes for your reviewer:
This needs testing.
I identifed this issue in a GKE environment which has a CRI-O socket at /run/containerd/containerd.sock. I had the plugin configured to use CRI-O pointing to /run/crio/crio.sock, and containerd for /run/containerd/containerd.sock. The plugin used the containerd logic for pulling in the data, and this is where I found it was lacking the proper container name, and thus this code contribution. I was able to resolve this issue on my end by disabling containerd and pointing the crio socket to /run/containerd/containerd.sock, but I believe this issue still needs to be addressed for containerd, and I don't have a good way of testing it myself.