diff --git a/server/container_list.go b/server/container_list.go index 42ddb4e2..85681489 100644 --- a/server/container_list.go +++ b/server/container_list.go @@ -30,7 +30,9 @@ func filterContainer(c *pb.Container, filter *pb.ContainerFilter) bool { // filterContainerList applies a protobuf-defined filter to retrieve only intended containers. Not matching // the filter is not considered an error but will return an empty response. -func (s *Server) filterContainerList(filter *pb.ContainerFilter) (ctrList []*oci.Container, err error) { +func (s *Server) filterContainerList(filter *pb.ContainerFilter, origCtrList []*oci.Container) (ctrList []*oci.Container, err error) { + ctrList = origCtrList + // Filter using container id and pod id first. if filter.Id != "" { id, err := s.CtrIDIndex().Get(filter.Id) @@ -83,7 +85,7 @@ func (s *Server) ListContainers(ctx context.Context, req *pb.ListContainersReque } if filter != nil { - ctrList, err = s.filterContainerList(filter) + ctrList, err = s.filterContainerList(filter, ctrList) if err != nil { return nil, err } diff --git a/server/container_stats_list.go b/server/container_stats_list.go index 5749d2f6..b6a81f6b 100644 --- a/server/container_stats_list.go +++ b/server/container_stats_list.go @@ -28,7 +28,7 @@ func (s *Server) ListContainerStats(ctx context.Context, req *pb.ListContainerSt PodSandboxId: req.Filter.PodSandboxId, LabelSelector: req.Filter.LabelSelector, } - ctrList, err = s.filterContainerList(cFilter) + ctrList, err = s.filterContainerList(cFilter, ctrList) if err != nil { return nil, err }