mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
dockershim: fix sandbox/container filtering
This commit is contained in:
parent
224cbeede5
commit
fd70d94330
@ -37,6 +37,8 @@ func (ds *dockerService) ListContainers(filter *runtimeApi.ContainerFilter) ([]*
|
||||
|
||||
opts.Filter = dockerfilters.NewArgs()
|
||||
f := newDockerFilter(&opts.Filter)
|
||||
// Add filter to get *only* (non-sandbox) containers.
|
||||
f.AddLabel(containerTypeLabelKey, containerTypeLabelContainer)
|
||||
|
||||
if filter != nil {
|
||||
if filter.Id != nil {
|
||||
@ -54,8 +56,6 @@ func (ds *dockerService) ListContainers(filter *runtimeApi.ContainerFilter) ([]*
|
||||
f.AddLabel(k, v)
|
||||
}
|
||||
}
|
||||
// Filter out sandbox containers.
|
||||
f.AddLabel(containerTypeLabelKey, containerTypeLabelContainer)
|
||||
}
|
||||
containers, err := ds.client.ListContainers(opts)
|
||||
if err != nil {
|
||||
|
@ -145,6 +145,9 @@ func (ds *dockerService) ListPodSandbox(filter *runtimeApi.PodSandboxFilter) ([]
|
||||
|
||||
opts.Filter = dockerfilters.NewArgs()
|
||||
f := newDockerFilter(&opts.Filter)
|
||||
// Add filter to select only sandbox containers.
|
||||
f.AddLabel(containerTypeLabelKey, containerTypeLabelSandbox)
|
||||
|
||||
if filter != nil {
|
||||
if filter.Id != nil {
|
||||
f.Add("id", filter.GetId())
|
||||
@ -168,8 +171,6 @@ func (ds *dockerService) ListPodSandbox(filter *runtimeApi.PodSandboxFilter) ([]
|
||||
f.AddLabel(k, v)
|
||||
}
|
||||
}
|
||||
// Filter out sandbox containers.
|
||||
f.AddLabel(containerTypeLabelKey, containerTypeLabelSandbox)
|
||||
}
|
||||
containers, err := ds.client.ListContainers(opts)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user