Skip to content

Commit

Permalink
bugfix: we should set Running flag to true when started container
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Wan <zirenwan@gmail.com>
  • Loading branch information
HusterWan committed Jun 27, 2018
1 parent b5b25ae commit 335533e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions daemon/mgr/container_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func (c *Container) SetStatusRunning(pid int64) {
c.State.StartedAt = time.Now().UTC().Format(utils.TimeLayout)
c.State.Pid = pid
c.State.ExitCode = 0
c.State.Running = true
}

// SetStatusStopped sets a container to be status stopped.
Expand Down
19 changes: 19 additions & 0 deletions test/cli_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,22 @@ func (suite *PouchRunMemorySuite) TestRunWithShm(c *check.C) {

util.PartialEqual(res.Stdout(), "1048576")
}

// TestRunSetRunningFlag is to verfy whether set Running Flag in ContainerState
// when started a container
func (suite *PouchRunSuite) TestRunSetRunningFlag(c *check.C) {
cname := "TestRunSetRunningFlag"
res := command.PouchRun("run", "-d", "--name", cname, busyboxImage, "top")
defer DelContainerForceMultyTime(c, cname)
res.Assert(c, icmd.Success)

// test if the value is in inspect result
res = command.PouchRun("inspect", cname)
res.Assert(c, icmd.Success)

result := []types.ContainerJSON{}
if err := json.Unmarshal([]byte(res.Stdout()), &result); err != nil {
c.Errorf("failed to decode inspect output: %v", err)
}
c.Assert(result[0].State.Running, check.Equals, true)
}

0 comments on commit 335533e

Please sign in to comment.