Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
containerd-shim-kata-v2: add the service State support
Browse files Browse the repository at this point in the history
Add the State api support to get a container
or exec process's states.

Signed-off-by: fupan <[email protected]>
  • Loading branch information
lifupan committed Nov 28, 2018
1 parent fbaefc9 commit fd18b22
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion containerd-shim-v2/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,46 @@ func (s *service) ResizePty(ctx context.Context, r *taskAPI.ResizePtyRequest) (*

// State returns runtime state information for a process
func (s *service) State(ctx context.Context, r *taskAPI.StateRequest) (*taskAPI.StateResponse, error) {
return nil, errdefs.ErrNotImplemented
s.Lock()
defer s.Unlock()

c, err := s.getContainer(r.ID)
if err != nil {
return nil, err
}

if r.ExecID == "" {
return &taskAPI.StateResponse{
ID: c.id,
Bundle: c.bundle,
Pid: s.pid,
Status: c.status,
Stdin: c.stdin,
Stdout: c.stdout,
Stderr: c.stderr,
Terminal: c.terminal,
ExitStatus: c.exit,
}, nil
}

//deal with exec case
execs, err := c.getExec(r.ExecID)
if err != nil {
return nil, err
}

return &taskAPI.StateResponse{
ID: execs.id,
Bundle: c.bundle,
Pid: s.pid,
Status: execs.status,
Stdin: execs.tty.stdin,
Stdout: execs.tty.stdout,
Stderr: execs.tty.stderr,
Terminal: execs.tty.terminal,
ExitStatus: uint32(execs.exitCode),
}, nil

}

// Pause the container
Expand Down

0 comments on commit fd18b22

Please sign in to comment.