dockershim: fix sandbox/container filtering

This commit is contained in:
Yu-Ju Hong 2016-09-15 12:05:54 -07:00
parent 224cbeede5
commit fd70d94330
2 changed files with 5 additions and 4 deletions

View File

@ -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 {

View File

@ -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 {