mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-04 02:56:18 +00:00
containerd-shim-kata-v2: add the service State support
Add the State api support to get a container or exec process's states. Signed-off-by: fupan <lifupan@gmail.com>
This commit is contained in:
parent
fbaefc9af1
commit
fd18b2289d
@ -347,7 +347,46 @@ func (s *service) ResizePty(ctx context.Context, r *taskAPI.ResizePtyRequest) (*
|
|||||||
|
|
||||||
// State returns runtime state information for a process
|
// State returns runtime state information for a process
|
||||||
func (s *service) State(ctx context.Context, r *taskAPI.StateRequest) (*taskAPI.StateResponse, error) {
|
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
|
// Pause the container
|
||||||
|
Loading…
Reference in New Issue
Block a user