Skip to content

Conversation

gnosek
Copy link
Contributor

@gnosek gnosek commented Jan 25, 2019

Pause containers are reported in CRI as having container_id = pod_id (they do not exist as far as ContainerStatus is concerned).

If ContainerStatus fails for a container, try calling PodSandboxStatus. If that returns success, mark this container as a pod sandbox.

context.set_deadline(deadline);
grpc::Status status = s_cri->PodSandboxStatus(&context, req, &resp);

return status.ok();
Copy link
Contributor

@anoop-sysd anoop-sysd Jan 29, 2019

Choose a reason for hiding this comment

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

before returning, may be a DEBUG message logged if status is not ok would help in debugging.

Not having this on by default breaks installs where we actually
have both Docker and containerd sockets (this happens on some Docker
versions).
We cannot rely on CRI succeeding and in the worst case, we'll at least
have the container ID.
Testing shows that we can fail to get the metadata early in the
container's lifetime, so don't add an empty container in that case,
just return a failure and we'll pick it up the next time around.
This allows container engines to return `false` but still set
a container_id, which is useful for Docker and CRI (they may detect
a container but fail to fetch its metadata, at least temporarily).
In that case, we don't want to add a container object (so that a future
lookup may succeed) but still record this process as a part of that
container.
Pod sandbox containers _start_ with `k8s_POD`.
The cgroup may either be a container id or a pod id, but if it's
neither, it's interesting enough to at least log a DEBUG message.
@gnosek gnosek merged commit 8ae2f13 into dev Feb 1, 2019
@gnosek gnosek deleted the cri branch February 1, 2019 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants