Add server implementation for exec sync

Signed-off-by: Mrunal Patel <mpatel@redhat.com>
This commit is contained in:
Mrunal Patel 2016-11-17 16:41:44 -08:00
parent b12a508e4e
commit 52e789c44b

View file

@ -577,7 +577,35 @@ func (s *Server) UpdateRuntimeConfig(ctx context.Context, req *pb.UpdateRuntimeC
// ExecSync runs a command in a container synchronously.
func (s *Server) ExecSync(ctx context.Context, req *pb.ExecSyncRequest) (*pb.ExecSyncResponse, error) {
return nil, nil
logrus.Debugf("ExecSyncRequest %+v", req)
c, err := s.getContainerFromRequest(req)
if err != nil {
return nil, err
}
if err := s.runtime.UpdateStatus(c); err != nil {
return nil, err
}
cState := s.runtime.ContainerStatus(c)
if !(cState.Status == oci.ContainerStateRunning || cState.Status == oci.ContainerStateCreated) {
return nil, fmt.Errorf("container is not created or running")
}
cmd := req.GetCmd()
if cmd == nil {
return nil, fmt.Errorf("exec command cannot be empty")
}
out, errout, rc, err := s.runtime.ExecSync(c, cmd, req.GetTimeout())
resp := &pb.ExecSyncResponse{
Stdout: out,
Stderr: errout,
ExitCode: &rc,
}
logrus.Debugf("ExecSyncResponse: %+v", resp)
return resp, err
}
// Exec prepares a streaming endpoint to execute a command in the container.