mirror of https://github.com/containers/podman.git
Add Checkpointed bool to Inspect
When inspecting a container, we now report whether the container was stopped by a `podman checkpoint` operation via a new bool in the State portion of inspected, `Checkpointed`. Signed-off-by: Matthew Heon <mheon@redhat.com>
This commit is contained in:
parent
536f23c0b7
commit
bfcd83ecd6
|
@ -159,6 +159,9 @@ type ContainerState struct {
|
||||||
// OOMKilled indicates that the container was killed as it ran out of
|
// OOMKilled indicates that the container was killed as it ran out of
|
||||||
// memory
|
// memory
|
||||||
OOMKilled bool `json:"oomKilled,omitempty"`
|
OOMKilled bool `json:"oomKilled,omitempty"`
|
||||||
|
// Checkpointed indicates that the container was stopped by a checkpoint
|
||||||
|
// operation.
|
||||||
|
Checkpointed bool `json:"checkpointed,omitempty"`
|
||||||
// PID is the PID of a running container
|
// PID is the PID of a running container
|
||||||
PID int `json:"pid,omitempty"`
|
PID int `json:"pid,omitempty"`
|
||||||
// ConmonPID is the PID of the container's conmon
|
// ConmonPID is the PID of the container's conmon
|
||||||
|
|
|
@ -103,18 +103,19 @@ func (c *Container) getContainerInspectData(size bool, driverData *define.Driver
|
||||||
Path: path,
|
Path: path,
|
||||||
Args: args,
|
Args: args,
|
||||||
State: &define.InspectContainerState{
|
State: &define.InspectContainerState{
|
||||||
OciVersion: ctrSpec.Version,
|
OciVersion: ctrSpec.Version,
|
||||||
Status: runtimeInfo.State.String(),
|
Status: runtimeInfo.State.String(),
|
||||||
Running: runtimeInfo.State == define.ContainerStateRunning,
|
Running: runtimeInfo.State == define.ContainerStateRunning,
|
||||||
Paused: runtimeInfo.State == define.ContainerStatePaused,
|
Paused: runtimeInfo.State == define.ContainerStatePaused,
|
||||||
OOMKilled: runtimeInfo.OOMKilled,
|
OOMKilled: runtimeInfo.OOMKilled,
|
||||||
Dead: runtimeInfo.State.String() == "bad state",
|
Dead: runtimeInfo.State.String() == "bad state",
|
||||||
Pid: runtimeInfo.PID,
|
Pid: runtimeInfo.PID,
|
||||||
ConmonPid: runtimeInfo.ConmonPID,
|
ConmonPid: runtimeInfo.ConmonPID,
|
||||||
ExitCode: runtimeInfo.ExitCode,
|
ExitCode: runtimeInfo.ExitCode,
|
||||||
Error: "", // can't get yet
|
Error: "", // can't get yet
|
||||||
StartedAt: runtimeInfo.StartedTime,
|
StartedAt: runtimeInfo.StartedTime,
|
||||||
FinishedAt: runtimeInfo.FinishedTime,
|
FinishedAt: runtimeInfo.FinishedTime,
|
||||||
|
Checkpointed: runtimeInfo.Checkpointed,
|
||||||
},
|
},
|
||||||
Image: config.RootfsImageID,
|
Image: config.RootfsImageID,
|
||||||
ImageName: config.RootfsImageName,
|
ImageName: config.RootfsImageName,
|
||||||
|
|
|
@ -584,6 +584,7 @@ func resetState(state *ContainerState) {
|
||||||
state.StoppedByUser = false
|
state.StoppedByUser = false
|
||||||
state.RestartPolicyMatch = false
|
state.RestartPolicyMatch = false
|
||||||
state.RestartCount = 0
|
state.RestartCount = 0
|
||||||
|
state.Checkpointed = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh refreshes the container's state after a restart.
|
// Refresh refreshes the container's state after a restart.
|
||||||
|
@ -1110,6 +1111,7 @@ func (c *Container) init(ctx context.Context, retainRetries bool) error {
|
||||||
c.state.ExecSessions = make(map[string]*ExecSession)
|
c.state.ExecSessions = make(map[string]*ExecSession)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.state.Checkpointed = false
|
||||||
c.state.ExitCode = 0
|
c.state.ExitCode = 0
|
||||||
c.state.Exited = false
|
c.state.Exited = false
|
||||||
c.state.State = define.ContainerStateCreated
|
c.state.State = define.ContainerStateCreated
|
||||||
|
|
|
@ -1146,6 +1146,7 @@ func (c *Container) checkpoint(ctx context.Context, options ContainerCheckpointO
|
||||||
|
|
||||||
if !options.KeepRunning && !options.PreCheckPoint {
|
if !options.KeepRunning && !options.PreCheckPoint {
|
||||||
c.state.State = define.ContainerStateStopped
|
c.state.State = define.ContainerStateStopped
|
||||||
|
c.state.Checkpointed = true
|
||||||
|
|
||||||
// Cleanup Storage and Network
|
// Cleanup Storage and Network
|
||||||
if err := c.cleanup(ctx); err != nil {
|
if err := c.cleanup(ctx); err != nil {
|
||||||
|
|
|
@ -189,20 +189,21 @@ type InspectMount struct {
|
||||||
// Docker, but here we see more fields that are unused (nonsensical in the
|
// Docker, but here we see more fields that are unused (nonsensical in the
|
||||||
// context of Libpod).
|
// context of Libpod).
|
||||||
type InspectContainerState struct {
|
type InspectContainerState struct {
|
||||||
OciVersion string `json:"OciVersion"`
|
OciVersion string `json:"OciVersion"`
|
||||||
Status string `json:"Status"`
|
Status string `json:"Status"`
|
||||||
Running bool `json:"Running"`
|
Running bool `json:"Running"`
|
||||||
Paused bool `json:"Paused"`
|
Paused bool `json:"Paused"`
|
||||||
Restarting bool `json:"Restarting"` // TODO
|
Restarting bool `json:"Restarting"` // TODO
|
||||||
OOMKilled bool `json:"OOMKilled"`
|
OOMKilled bool `json:"OOMKilled"`
|
||||||
Dead bool `json:"Dead"`
|
Dead bool `json:"Dead"`
|
||||||
Pid int `json:"Pid"`
|
Pid int `json:"Pid"`
|
||||||
ConmonPid int `json:"ConmonPid,omitempty"`
|
ConmonPid int `json:"ConmonPid,omitempty"`
|
||||||
ExitCode int32 `json:"ExitCode"`
|
ExitCode int32 `json:"ExitCode"`
|
||||||
Error string `json:"Error"` // TODO
|
Error string `json:"Error"` // TODO
|
||||||
StartedAt time.Time `json:"StartedAt"`
|
StartedAt time.Time `json:"StartedAt"`
|
||||||
FinishedAt time.Time `json:"FinishedAt"`
|
FinishedAt time.Time `json:"FinishedAt"`
|
||||||
Healthcheck HealthCheckResults `json:"Healthcheck,omitempty"`
|
Healthcheck HealthCheckResults `json:"Healthcheck,omitempty"`
|
||||||
|
Checkpointed bool `json:"Checkpointed,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// HealthCheckResults describes the results/logs from a healthcheck
|
// HealthCheckResults describes the results/logs from a healthcheck
|
||||||
|
|
|
@ -93,6 +93,12 @@ var _ = Describe("Podman checkpoint", func() {
|
||||||
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
|
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
|
||||||
Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Exited"))
|
Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Exited"))
|
||||||
|
|
||||||
|
inspect := podmanTest.Podman([]string{"inspect", cid})
|
||||||
|
inspect.WaitWithDefaultTimeout()
|
||||||
|
Expect(inspect).Should(Exit(0))
|
||||||
|
inspectOut := inspect.InspectContainerToJSON()
|
||||||
|
Expect(inspectOut[0].State.Checkpointed).To(BeTrue())
|
||||||
|
|
||||||
result = podmanTest.Podman([]string{"container", "restore", cid})
|
result = podmanTest.Podman([]string{"container", "restore", cid})
|
||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue