From d19c818cdc23e52e954878eb3571d06993475f42 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Fri, 12 Feb 2016 14:01:24 -0800 Subject: [PATCH] Don't get pids on create Signed-off-by: Michael Crosby --- api/grpc/server/server.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/api/grpc/server/server.go b/api/grpc/server/server.go index 9e1f45c..61685f6 100644 --- a/api/grpc/server/server.go +++ b/api/grpc/server/server.go @@ -51,7 +51,7 @@ func (s *apiServer) CreateContainer(ctx context.Context, c *types.CreateContaine return nil, err } r := <-e.StartResponse - apiC, err := createAPIContainer(r.Container) + apiC, err := createAPIContainer(r.Container, false) if err != nil { return nil, err } @@ -188,7 +188,7 @@ func (s *apiServer) State(ctx context.Context, r *types.StateRequest) (*types.St }, } for _, c := range e.Containers { - apiC, err := createAPIContainer(c) + apiC, err := createAPIContainer(c, true) if err != nil { return nil, err } @@ -197,7 +197,7 @@ func (s *apiServer) State(ctx context.Context, r *types.StateRequest) (*types.St return state, nil } -func createAPIContainer(c runtime.Container) (*types.Container, error) { +func createAPIContainer(c runtime.Container, getPids bool) (*types.Container, error) { processes, err := c.Processes() if err != nil { return nil, grpc.Errorf(codes.Internal, "get processes for container") @@ -223,9 +223,11 @@ func createAPIContainer(c runtime.Container) (*types.Container, error) { }, }) } - pids, err := c.Pids() - if err != nil { - return nil, grpc.Errorf(codes.Internal, "get all pids for container") + var pids []int + if getPids { + if pids, err = c.Pids(); err != nil { + return nil, grpc.Errorf(codes.Internal, "get all pids for container") + } } return &types.Container{ Id: c.ID(),