mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-13 21:56:32 +00:00
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 <liyuxuan04@baidu.com>
This commit is contained in:
parent
c26788c329
commit
c1060a3b9e
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user