Skip to content

Commit 48e1e0e

Browse files
authored
Merge pull request #1144 from allencloud/add-finishat
feature: add FinishedAt and StartAt in container get api
2 parents 3e4e195 + 3d85808 commit 48e1e0e

4 files changed

Lines changed: 45 additions & 3 deletions

File tree

apis/swagger.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2879,6 +2879,7 @@ definitions:
28792879

28802880
ContainerState:
28812881
type: "object"
2882+
required: [StartedAt, FinishedAt]
28822883
properties:
28832884
Status:
28842885
$ref: "#/definitions/Status"
@@ -2919,9 +2920,11 @@ definitions:
29192920
StartedAt:
29202921
description: "The time when this container was last started."
29212922
type: "string"
2923+
x-nullable: false
29222924
FinishedAt:
29232925
description: "The time when this container last exited."
29242926
type: "string"
2927+
x-nullable: false
29252928

29262929
ContainerLogsOptions:
29272930
type: "object"

apis/types/container_state.go

Lines changed: 33 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

daemon/mgr/container.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,9 @@ func (mgr *ContainerManager) Create(ctx context.Context, name string, config *ty
450450

451451
meta := &ContainerMeta{
452452
State: &types.ContainerState{
453-
Status: types.StatusCreated,
453+
Status: types.StatusCreated,
454+
StartedAt: time.Time{}.UTC().Format(utils.TimeLayout),
455+
FinishedAt: time.Time{}.UTC().Format(utils.TimeLayout),
454456
},
455457
ID: id,
456458
Image: image.ID,

test/api_container_inspect_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package main
22

33
import (
4+
"time"
5+
46
"github.com/alibaba/pouch/apis/types"
57
"github.com/alibaba/pouch/test/environment"
68
"github.com/alibaba/pouch/test/request"
@@ -45,6 +47,10 @@ func (suite *APIContainerInspectSuite) TestInpectOk(c *check.C) {
4547
c.Assert(got.Image, check.Equals, busyboxImage)
4648
c.Assert(got.Name, check.Equals, cname)
4749
c.Assert(got.Created, check.NotNil)
50+
// StartedAt time should be 0001-01-01T00:00:00Z for a non-started container
51+
c.Assert(got.State.StartedAt, check.Equals, time.Time{}.UTC().Format(time.RFC3339Nano))
52+
// FinishAt time should be 0001-01-01T00:00:00Z for a non-stopped container
53+
c.Assert(got.State.FinishedAt, check.Equals, time.Time{}.UTC().Format(time.RFC3339Nano))
4854

4955
DelContainerForceOk(c, cname)
5056
}

0 commit comments

Comments
 (0)