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

Commit

Permalink
v2: Change the event and error behavior of pause/resume
Browse files Browse the repository at this point in the history
1. Send the event when the container is paused/resumed successfully
2. Return the error of the pause/resume function rather than
`getContainerStatus`.

Fixes #2121

Signed-off-by: Li Yuxuan <liyuxuan04@baidu.com>
  • Loading branch information
darfux committed Oct 9, 2019
1 parent c26788c commit c1060a3
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions containerd-shim-v2/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,18 +592,18 @@ func (s *service) Pause(ctx context.Context, r *taskAPI.PauseRequest) (_ *ptypes
err = s.sandbox.PauseContainer(r.ID)
if err == nil {
c.status = task.StatusPaused
s.send(&eventstypes.TaskPaused{
ContainerID: c.id,
})
return empty, nil
}

c.status, err = s.getContainerStatus(c.id)
if err != nil {
if status, err := s.getContainerStatus(c.id); err != nil {
c.status = task.StatusUnknown
} else {
c.status = status
}

s.send(&eventstypes.TaskPaused{
ContainerID: c.id,
})

return empty, err
}

Expand All @@ -624,18 +624,18 @@ func (s *service) Resume(ctx context.Context, r *taskAPI.ResumeRequest) (_ *ptyp
err = s.sandbox.ResumeContainer(c.id)
if err == nil {
c.status = task.StatusRunning
s.send(&eventstypes.TaskResumed{
ContainerID: c.id,
})
return empty, nil
}

c.status, err = s.getContainerStatus(c.id)
if err != nil {
if status, err := s.getContainerStatus(c.id); err != nil {
c.status = task.StatusUnknown
} else {
c.status = status
}

s.send(&eventstypes.TaskResumed{
ContainerID: c.id,
})

return empty, err
}

Expand Down

0 comments on commit c1060a3

Please sign in to comment.