From c1060a3b9e5ded9a96c4a4b50b330392298659f3 Mon Sep 17 00:00:00 2001 From: Li Yuxuan Date: Wed, 9 Oct 2019 19:00:04 +0800 Subject: [PATCH] v2: Change the event and error behavior of pause/resume 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 --- containerd-shim-v2/service.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/containerd-shim-v2/service.go b/containerd-shim-v2/service.go index 89a4642fbd..4ffccbea9b 100644 --- a/containerd-shim-v2/service.go +++ b/containerd-shim-v2/service.go @@ -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 } @@ -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 }