summaryrefslogtreecommitdiffhomepage
path: root/runsc/container/container.go
diff options
context:
space:
mode:
authorJustine Olshan <justineolshan@google.com>2018-06-19 15:22:23 -0700
committerShentubot <shentubot@google.com>2018-06-19 15:23:36 -0700
commita6dbef045ff684e92f472280eb6f7f688b9bc87a (patch)
tree35aad9e3d975e0c217f12adec007d9a35521fc3d /runsc/container/container.go
parentbda2a1ed3503699b8cb814bb3cc7ad0b9694155b (diff)
Added a resume command to unpause a paused container.
Resume checks the status of the container and unpauses the kernel if its status is paused. Otherwise nothing happens. Tests were added to ensure that the process is in the correct state after various commands. PiperOrigin-RevId: 201251234 Change-Id: Ifd11b336c33b654fea6238738f864fcf2bf81e19
Diffstat (limited to 'runsc/container/container.go')
-rw-r--r--runsc/container/container.go21
1 files changed, 18 insertions, 3 deletions
diff --git a/runsc/container/container.go b/runsc/container/container.go
index dc7fccdee..571784e07 100644
--- a/runsc/container/container.go
+++ b/runsc/container/container.go
@@ -361,8 +361,23 @@ func (c *Container) Pause() error {
c.Status = Paused
return c.save()
default:
- log.Warningf("container %q not created or running, not pausing", c.ID)
- return nil
+ return fmt.Errorf("container %q not created or running, not pausing", c.ID)
+ }
+}
+
+// Resume unpauses the container and its kernel.
+// The call only succeeds if the container's status is paused.
+func (c *Container) Resume() error {
+ log.Debugf("Resuming container %q", c.ID)
+ switch c.Status {
+ case Paused:
+ if err := c.Sandbox.Resume(c.ID); err != nil {
+ return fmt.Errorf("error resuming container: %v", err)
+ }
+ c.Status = Running
+ return c.save()
+ default:
+ return fmt.Errorf("container %q not paused, not resuming", c.ID)
}
}
@@ -380,7 +395,7 @@ func (c *Container) State() specs.State {
// Processes retrieves the list of processes and associated metadata inside a
// container.
func (c *Container) Processes() ([]*control.Process, error) {
- if c.Status != Running {
+ if c.Status != Running && c.Status != Paused {
return nil, fmt.Errorf("cannot get processes of container %q because it isn't running. It is in state %v", c.ID, c.Status)
}
return c.Sandbox.Processes(c.ID)