summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-09-08 09:56:23 +0200
committerGitHub <noreply@github.com>2021-09-08 09:56:23 +0200
commitae0a9c6c8acd4e675ce4afbff161f9e5857082e6 (patch)
tree85ccfae902261801ab73dee7536d9c5d4c7bc430
parent598d914e625616da49df7c068ffd84135d12571e (diff)
parentbfcd83ecd680fccd2efeadf695a9cd2c603a997f (diff)
downloadpodman-ae0a9c6c8acd4e675ce4afbff161f9e5857082e6.tar.gz
podman-ae0a9c6c8acd4e675ce4afbff161f9e5857082e6.tar.bz2
podman-ae0a9c6c8acd4e675ce4afbff161f9e5857082e6.zip
Merge pull request #11471 from mheon/checkpointed
Add Checkpointed bool to Inspect
-rw-r--r--libpod/container.go3
-rw-r--r--libpod/container_inspect.go25
-rw-r--r--libpod/container_internal.go2
-rw-r--r--libpod/container_internal_linux.go1
-rw-r--r--libpod/define/container_inspect.go29
-rw-r--r--test/e2e/checkpoint_test.go6
6 files changed, 40 insertions, 26 deletions
diff --git a/libpod/container.go b/libpod/container.go
index c57250d72..0986a0d80 100644
--- a/libpod/container.go
+++ b/libpod/container.go
@@ -159,6 +159,9 @@ type ContainerState struct {
// OOMKilled indicates that the container was killed as it ran out of
// memory
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 int `json:"pid,omitempty"`
// ConmonPID is the PID of the container's conmon
diff --git a/libpod/container_inspect.go b/libpod/container_inspect.go
index 97318a2e8..2ef4532cd 100644
--- a/libpod/container_inspect.go
+++ b/libpod/container_inspect.go
@@ -103,18 +103,19 @@ func (c *Container) getContainerInspectData(size bool, driverData *define.Driver
Path: path,
Args: args,
State: &define.InspectContainerState{
- OciVersion: ctrSpec.Version,
- Status: runtimeInfo.State.String(),
- Running: runtimeInfo.State == define.ContainerStateRunning,
- Paused: runtimeInfo.State == define.ContainerStatePaused,
- OOMKilled: runtimeInfo.OOMKilled,
- Dead: runtimeInfo.State.String() == "bad state",
- Pid: runtimeInfo.PID,
- ConmonPid: runtimeInfo.ConmonPID,
- ExitCode: runtimeInfo.ExitCode,
- Error: "", // can't get yet
- StartedAt: runtimeInfo.StartedTime,
- FinishedAt: runtimeInfo.FinishedTime,
+ OciVersion: ctrSpec.Version,
+ Status: runtimeInfo.State.String(),
+ Running: runtimeInfo.State == define.ContainerStateRunning,
+ Paused: runtimeInfo.State == define.ContainerStatePaused,
+ OOMKilled: runtimeInfo.OOMKilled,
+ Dead: runtimeInfo.State.String() == "bad state",
+ Pid: runtimeInfo.PID,
+ ConmonPid: runtimeInfo.ConmonPID,
+ ExitCode: runtimeInfo.ExitCode,
+ Error: "", // can't get yet
+ StartedAt: runtimeInfo.StartedTime,
+ FinishedAt: runtimeInfo.FinishedTime,
+ Checkpointed: runtimeInfo.Checkpointed,
},
Image: config.RootfsImageID,
ImageName: config.RootfsImageName,
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 9082b136a..4d1a25541 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -584,6 +584,7 @@ func resetState(state *ContainerState) {
state.StoppedByUser = false
state.RestartPolicyMatch = false
state.RestartCount = 0
+ state.Checkpointed = false
}
// 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.Checkpointed = false
c.state.ExitCode = 0
c.state.Exited = false
c.state.State = define.ContainerStateCreated
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index cafa3c642..eabe8efd2 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -1146,6 +1146,7 @@ func (c *Container) checkpoint(ctx context.Context, options ContainerCheckpointO
if !options.KeepRunning && !options.PreCheckPoint {
c.state.State = define.ContainerStateStopped
+ c.state.Checkpointed = true
// Cleanup Storage and Network
if err := c.cleanup(ctx); err != nil {
diff --git a/libpod/define/container_inspect.go b/libpod/define/container_inspect.go
index af8ba6ecf..90703a807 100644
--- a/libpod/define/container_inspect.go
+++ b/libpod/define/container_inspect.go
@@ -189,20 +189,21 @@ type InspectMount struct {
// Docker, but here we see more fields that are unused (nonsensical in the
// context of Libpod).
type InspectContainerState struct {
- OciVersion string `json:"OciVersion"`
- Status string `json:"Status"`
- Running bool `json:"Running"`
- Paused bool `json:"Paused"`
- Restarting bool `json:"Restarting"` // TODO
- OOMKilled bool `json:"OOMKilled"`
- Dead bool `json:"Dead"`
- Pid int `json:"Pid"`
- ConmonPid int `json:"ConmonPid,omitempty"`
- ExitCode int32 `json:"ExitCode"`
- Error string `json:"Error"` // TODO
- StartedAt time.Time `json:"StartedAt"`
- FinishedAt time.Time `json:"FinishedAt"`
- Healthcheck HealthCheckResults `json:"Healthcheck,omitempty"`
+ OciVersion string `json:"OciVersion"`
+ Status string `json:"Status"`
+ Running bool `json:"Running"`
+ Paused bool `json:"Paused"`
+ Restarting bool `json:"Restarting"` // TODO
+ OOMKilled bool `json:"OOMKilled"`
+ Dead bool `json:"Dead"`
+ Pid int `json:"Pid"`
+ ConmonPid int `json:"ConmonPid,omitempty"`
+ ExitCode int32 `json:"ExitCode"`
+ Error string `json:"Error"` // TODO
+ StartedAt time.Time `json:"StartedAt"`
+ FinishedAt time.Time `json:"FinishedAt"`
+ Healthcheck HealthCheckResults `json:"Healthcheck,omitempty"`
+ Checkpointed bool `json:"Checkpointed,omitempty"`
}
// HealthCheckResults describes the results/logs from a healthcheck
diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go
index 1c9a8dc6f..403d739f0 100644
--- a/test/e2e/checkpoint_test.go
+++ b/test/e2e/checkpoint_test.go
@@ -93,6 +93,12 @@ var _ = Describe("Podman checkpoint", func() {
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
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.WaitWithDefaultTimeout()