Merge pull request #1547 from mikebrow/containerd-list-podid-should-search
adds support for pod id lookup for filter
This commit is contained in:
commit
858a766264
@ -69,13 +69,24 @@ func (c *criService) filterCRIContainers(containers []*runtime.Container, filter
|
|||||||
return containers
|
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)
|
c.normalizeContainerFilter(filter)
|
||||||
filtered := []*runtime.Container{}
|
filtered := []*runtime.Container{}
|
||||||
for _, cntr := range containers {
|
for _, cntr := range containers {
|
||||||
if filter.GetId() != "" && filter.GetId() != cntr.Id {
|
if filter.GetId() != "" && filter.GetId() != cntr.Id {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if filter.GetPodSandboxId() != "" && filter.GetPodSandboxId() != cntr.PodSandboxId {
|
if sb != "" && sb != cntr.PodSandboxId {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if filter.GetState() != nil && filter.GetState().GetState() != cntr.State {
|
if filter.GetState() != nil && filter.GetState().GetState() != cntr.State {
|
||||||
|
Loading…
Reference in New Issue
Block a user