Skip to content

Commit 8a2d1cc

Browse files
committed
adds support for pod id lookup for filter
Signed-off-by: Mike Brown <[email protected]>
1 parent c209d01 commit 8a2d1cc

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

pkg/server/container_list.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,24 @@ func (c *criService) filterCRIContainers(containers []*runtime.Container, filter
6969
return containers
7070
}
7171

72+
// The containerd cri plugin supports short ids so long as there is only one
73+
// match. So we do a lookup against the store here if a pod id has been
74+
// included in the filter.
75+
sb := filter.GetPodSandboxId()
76+
if sb != "" {
77+
sandbox, err := c.sandboxStore.Get(sb)
78+
if err == nil {
79+
sb = sandbox.ID
80+
}
81+
}
82+
7283
c.normalizeContainerFilter(filter)
7384
filtered := []*runtime.Container{}
7485
for _, cntr := range containers {
7586
if filter.GetId() != "" && filter.GetId() != cntr.Id {
7687
continue
7788
}
78-
if filter.GetPodSandboxId() != "" && filter.GetPodSandboxId() != cntr.PodSandboxId {
89+
if sb != "" && sb != cntr.PodSandboxId {
7990
continue
8091
}
8192
if filter.GetState() != nil && filter.GetState().GetState() != cntr.State {

0 commit comments

Comments
 (0)