From 8a2d1cc802e60e3c93c606270b92978c036fb432 Mon Sep 17 00:00:00 2001 From: Mike Brown Date: Wed, 29 Jul 2020 12:15:23 -0500 Subject: [PATCH] adds support for pod id lookup for filter Signed-off-by: Mike Brown --- pkg/server/container_list.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/server/container_list.go b/pkg/server/container_list.go index 3930c03ed..c9e88d13d 100644 --- a/pkg/server/container_list.go +++ b/pkg/server/container_list.go @@ -69,13 +69,24 @@ func (c *criService) filterCRIContainers(containers []*runtime.Container, filter return containers } + // The containerd cri plugin supports short ids so long as there is only one + // match. So we do a lookup against the store here if a pod id has been + // included in the filter. + sb := filter.GetPodSandboxId() + if sb != "" { + sandbox, err := c.sandboxStore.Get(sb) + if err == nil { + sb = sandbox.ID + } + } + c.normalizeContainerFilter(filter) filtered := []*runtime.Container{} for _, cntr := range containers { if filter.GetId() != "" && filter.GetId() != cntr.Id { continue } - if filter.GetPodSandboxId() != "" && filter.GetPodSandboxId() != cntr.PodSandboxId { + if sb != "" && sb != cntr.PodSandboxId { continue } if filter.GetState() != nil && filter.GetState().GetState() != cntr.State {