From bbfcf62a0f08739c99162b53549a7ac02c4d1a44 Mon Sep 17 00:00:00 2001 From: Pengfei Ni Date: Mon, 14 Nov 2016 14:26:06 +0800 Subject: [PATCH] Set timestamps to nanosecond. CRI requires all timestamps in nanosends instead of seconds. Signed-off-by: Pengfei Ni --- server/container.go | 14 +++++++------- server/sandbox.go | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/server/container.go b/server/container.go index 43dc3ecd..31d63cbe 100644 --- a/server/container.go +++ b/server/container.go @@ -490,7 +490,7 @@ func (s *Server) ListContainers(ctx context.Context, req *pb.ListContainersReque podSandboxID := ctr.Sandbox() cState := s.runtime.ContainerStatus(ctr) - created := cState.Created.Unix() + created := cState.Created.UnixNano() rState := pb.ContainerState_UNKNOWN cID := ctr.ID() @@ -551,21 +551,21 @@ func (s *Server) ContainerStatus(ctx context.Context, req *pb.ContainerStatusReq switch cState.Status { case oci.ContainerStateCreated: rStatus = pb.ContainerState_CREATED - created := cState.Created.Unix() + created := cState.Created.UnixNano() resp.Status.CreatedAt = int64Ptr(created) case oci.ContainerStateRunning: rStatus = pb.ContainerState_RUNNING - created := cState.Created.Unix() + created := cState.Created.UnixNano() resp.Status.CreatedAt = int64Ptr(created) - started := cState.Started.Unix() + started := cState.Started.UnixNano() resp.Status.StartedAt = int64Ptr(started) case oci.ContainerStateStopped: rStatus = pb.ContainerState_EXITED - created := cState.Created.Unix() + created := cState.Created.UnixNano() resp.Status.CreatedAt = int64Ptr(created) - started := cState.Started.Unix() + started := cState.Started.UnixNano() resp.Status.StartedAt = int64Ptr(started) - finished := cState.Finished.Unix() + finished := cState.Finished.UnixNano() resp.Status.FinishedAt = int64Ptr(finished) resp.Status.ExitCode = int32Ptr(cState.ExitCode) } diff --git a/server/sandbox.go b/server/sandbox.go index a84de4f2..f2153874 100644 --- a/server/sandbox.go +++ b/server/sandbox.go @@ -454,7 +454,7 @@ func (s *Server) PodSandboxStatus(ctx context.Context, req *pb.PodSandboxStatusR } cState := s.runtime.ContainerStatus(podInfraContainer) - created := cState.Created.Unix() + created := cState.Created.UnixNano() netNsPath, err := podInfraContainer.NetNsPath() if err != nil { @@ -545,7 +545,7 @@ func (s *Server) ListPodSandbox(ctx context.Context, req *pb.ListPodSandboxReque return nil, err } cState := s.runtime.ContainerStatus(podInfraContainer) - created := cState.Created.Unix() + created := cState.Created.UnixNano() rStatus := pb.PodSandBoxState_NOTREADY if cState.Status == oci.ContainerStateRunning { rStatus = pb.PodSandBoxState_READY