summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatej Vasek <mvasek@redhat.com>2021-05-10 10:17:04 +0200
committerMatej Vasek <mvasek@redhat.com>2021-05-10 11:21:14 +0200
commitdd98e703023225eacae9f3cf93ae92026686df5f (patch)
tree5b2c16fa151811ba0007c0a711448c653e4785c7
parent54bed1025d07bc5f77ee4e1e7f942157e211ec0a (diff)
downloadpodman-dd98e703023225eacae9f3cf93ae92026686df5f.tar.gz
podman-dd98e703023225eacae9f3cf93ae92026686df5f.tar.bz2
podman-dd98e703023225eacae9f3cf93ae92026686df5f.zip
fix: use UTC Time Stamps in response JSON
Signed-off-by: Matej Vasek <mvasek@redhat.com>
-rw-r--r--pkg/api/handlers/compat/containers.go7
-rw-r--r--test/apiv2/20-containers.at6
2 files changed, 12 insertions, 1 deletions
diff --git a/pkg/api/handlers/compat/containers.go b/pkg/api/handlers/compat/containers.go
index 263d64a7b..6bc02dd2b 100644
--- a/pkg/api/handlers/compat/containers.go
+++ b/pkg/api/handlers/compat/containers.go
@@ -379,6 +379,11 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
if err != nil {
return nil, err
}
+ // Docker uses UTC
+ if inspect != nil && inspect.State != nil {
+ inspect.State.StartedAt = inspect.State.StartedAt.UTC()
+ inspect.State.FinishedAt = inspect.State.FinishedAt.UTC()
+ }
i, err := json.Marshal(inspect.State)
if err != nil {
return nil, err
@@ -425,7 +430,7 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
cb := types.ContainerJSONBase{
ID: l.ID(),
- Created: l.CreatedTime().Format(time.RFC3339Nano),
+ Created: l.CreatedTime().UTC().Format(time.RFC3339Nano), // Docker uses UTC
Path: inspect.Path,
Args: inspect.Args,
State: &state,
diff --git a/test/apiv2/20-containers.at b/test/apiv2/20-containers.at
index 23dd374d6..a81210855 100644
--- a/test/apiv2/20-containers.at
+++ b/test/apiv2/20-containers.at
@@ -161,6 +161,12 @@ t GET libpod/containers/myctr/json 200 \
.OCIConfigPath~.*config\.json \
.GraphDriver.Data.MergedDir~.*merged
+# Test TS are in UTC
+t GET containers/myctr/json 200 \
+ .Created~.*Z \
+ .State.StartedAt~.*Z \
+ .State.FinishedAt~.*Z
+
t DELETE images/localhost/newrepo:latest?force=true 200
t DELETE images/localhost/newrepo:v1?force=true 200
t DELETE images/localhost/newrepo:v2?force=true 200