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 wait support
Add the Wait api to wait on a started container or exec process. Signed-off-by: fupan <lifupan@gmail.com>
This commit is contained in:
parent
269c940edc
commit
fbaefc9af1
@ -400,7 +400,30 @@ func (s *service) Update(ctx context.Context, r *taskAPI.UpdateTaskRequest) (*pt
|
|||||||
|
|
||||||
// Wait for a process to exit
|
// Wait for a process to exit
|
||||||
func (s *service) Wait(ctx context.Context, r *taskAPI.WaitRequest) (*taskAPI.WaitResponse, error) {
|
func (s *service) Wait(ctx context.Context, r *taskAPI.WaitRequest) (*taskAPI.WaitResponse, error) {
|
||||||
return nil, errdefs.ErrNotImplemented
|
var ret uint32
|
||||||
|
|
||||||
|
s.Lock()
|
||||||
|
c, err := s.getContainer(r.ID)
|
||||||
|
s.Unlock()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
//wait for container
|
||||||
|
if r.ExecID == "" {
|
||||||
|
ret = <-c.exitCh
|
||||||
|
} else { //wait for exec
|
||||||
|
execs, err := c.getExec(r.ExecID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
ret = <-execs.exitCh
|
||||||
|
}
|
||||||
|
|
||||||
|
return &taskAPI.WaitResponse{
|
||||||
|
ExitStatus: ret,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) processExits() {
|
func (s *service) processExits() {
|
||||||
|
Loading…
Reference in New Issue
Block a user