Skip to content

Commit

Permalink
Improve description of Running and Paused booleans
Browse files Browse the repository at this point in the history
Commit abd72d4 added
a "FIXME" comment to the container "State", mentioning
that a container cannot be both "Running" and "Paused".

This comment was incorrect, because containers on
Linux actually _must_ be running in order to be
paused.

This patch adds additional information both in a
comment, and in the API documentation to clarify
that these booleans are not mutually exclusive.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed May 19, 2017
1 parent ab83b92 commit b654b62
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
16 changes: 14 additions & 2 deletions api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3107,10 +3107,22 @@ paths:
type: "object"
properties:
Status:
description: "The status of the container. For example, `running` or `exited`."
description: |
The status of the container. For example, `"running"` or `"exited"`.
type: "string"
enum: ["created", "running", "paused", "restarting", "removing", "exited", "dead"]
Running:
description: "Whether this container is running."
description: |
Whether this container is running.
Note that a running container can be _paused_. The `Running` and `Paused`
booleans are not mutually exclusive:
When pausing a container (on Linux), the cgroups freezer is used to suspend
all processes in the container. Freezing the process requires the process to
be running. As a result, paused containers are both `Running` _and_ `Paused`.
Use the `Status` field instead to determin if a container's state is "running".
type: "boolean"
Paused:
description: "Whether this container is paused."
Expand Down
2 changes: 1 addition & 1 deletion api/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ type Health struct {
// ContainerState stores container's running state
// it's part of ContainerJSONBase and will return by "inspect" command
type ContainerState struct {
Status string
Status string // String representation of the container state. Can be one of "created", "running", "paused", "restarting", "removing", "exited", or "dead"
Running bool
Paused bool
Restarting bool
Expand Down
6 changes: 4 additions & 2 deletions container/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import (
// functions defined against State to run against Container.
type State struct {
sync.Mutex
// FIXME: Why do we have both paused and running if a
// container cannot be paused and running at the same time?
// Note that `Running` and `Paused` are not mutually exclusive:
// When pausing a container (on Linux), the cgroups freezer is used to suspend
// all processes in the container. Freezing the process requires the process to
// be running. As a result, paused containers are both `Running` _and_ `Paused`.
Running bool
Paused bool
Restarting bool
Expand Down

0 comments on commit b654b62

Please sign in to comment.