mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
Merge pull request #34574 from Random-Liu/cri-unix-to-unixnano
Automatic merge from submit-queue CRI: Change dockershim to use UnixNano instead of Unix. Fixes https://github.com/kubernetes/kubernetes/issues/34492. This PR changes the dockershim to use `UnixNano` instead of `Unix` to return timestamp in nanoseconds. @yujuhong
This commit is contained in:
commit
272703702a
@ -280,7 +280,7 @@ func (ds *dockerService) ContainerStatus(containerID string) (*runtimeApi.Contai
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert to unix timestamps.
|
// Convert to unix timestamps.
|
||||||
ct, st, ft := createdAt.Unix(), startedAt.Unix(), finishedAt.Unix()
|
ct, st, ft := createdAt.UnixNano(), startedAt.UnixNano(), finishedAt.UnixNano()
|
||||||
exitCode := int32(r.State.ExitCode)
|
exitCode := int32(r.State.ExitCode)
|
||||||
|
|
||||||
metadata, err := parseContainerName(r.Name)
|
metadata, err := parseContainerName(r.Name)
|
||||||
|
@ -101,7 +101,7 @@ func TestContainerStatus(t *testing.T) {
|
|||||||
config := makeContainerConfig(sConfig, "pause", "iamimage", 0, labels, annotations)
|
config := makeContainerConfig(sConfig, "pause", "iamimage", 0, labels, annotations)
|
||||||
|
|
||||||
var defaultTime time.Time
|
var defaultTime time.Time
|
||||||
dt := defaultTime.Unix()
|
dt := defaultTime.UnixNano()
|
||||||
ct, st, ft := dt, dt, dt
|
ct, st, ft := dt, dt, dt
|
||||||
state := runtimeApi.ContainerState_CREATED
|
state := runtimeApi.ContainerState_CREATED
|
||||||
// The following variables are not set in FakeDockerClient.
|
// The following variables are not set in FakeDockerClient.
|
||||||
@ -127,7 +127,7 @@ func TestContainerStatus(t *testing.T) {
|
|||||||
|
|
||||||
// Create the container.
|
// Create the container.
|
||||||
fClock.SetTime(time.Now().Add(-1 * time.Hour))
|
fClock.SetTime(time.Now().Add(-1 * time.Hour))
|
||||||
*expected.CreatedAt = fClock.Now().Unix()
|
*expected.CreatedAt = fClock.Now().UnixNano()
|
||||||
const sandboxId = "sandboxid"
|
const sandboxId = "sandboxid"
|
||||||
id, err := ds.CreateContainer(sandboxId, config, sConfig)
|
id, err := ds.CreateContainer(sandboxId, config, sConfig)
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ func TestContainerStatus(t *testing.T) {
|
|||||||
|
|
||||||
// Advance the clock and start the container.
|
// Advance the clock and start the container.
|
||||||
fClock.SetTime(time.Now())
|
fClock.SetTime(time.Now())
|
||||||
*expected.StartedAt = fClock.Now().Unix()
|
*expected.StartedAt = fClock.Now().UnixNano()
|
||||||
*expected.State = runtimeApi.ContainerState_RUNNING
|
*expected.State = runtimeApi.ContainerState_RUNNING
|
||||||
|
|
||||||
err = ds.StartContainer(id)
|
err = ds.StartContainer(id)
|
||||||
@ -156,7 +156,7 @@ func TestContainerStatus(t *testing.T) {
|
|||||||
|
|
||||||
// Advance the clock and stop the container.
|
// Advance the clock and stop the container.
|
||||||
fClock.SetTime(time.Now().Add(1 * time.Hour))
|
fClock.SetTime(time.Now().Add(1 * time.Hour))
|
||||||
*expected.FinishedAt = fClock.Now().Unix()
|
*expected.FinishedAt = fClock.Now().UnixNano()
|
||||||
*expected.State = runtimeApi.ContainerState_EXITED
|
*expected.State = runtimeApi.ContainerState_EXITED
|
||||||
*expected.Reason = "Completed"
|
*expected.Reason = "Completed"
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ func (ds *dockerService) PodSandboxStatus(podSandboxID string) (*runtimeApi.PodS
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to parse timestamp for container %q: %v", podSandboxID, err)
|
return nil, fmt.Errorf("failed to parse timestamp for container %q: %v", podSandboxID, err)
|
||||||
}
|
}
|
||||||
ct := createdAt.Unix()
|
ct := createdAt.UnixNano()
|
||||||
|
|
||||||
// Translate container to sandbox state.
|
// Translate container to sandbox state.
|
||||||
state := runtimeApi.PodSandBoxState_NOTREADY
|
state := runtimeApi.PodSandBoxState_NOTREADY
|
||||||
|
@ -111,7 +111,7 @@ func TestSandboxStatus(t *testing.T) {
|
|||||||
|
|
||||||
// Create the sandbox.
|
// Create the sandbox.
|
||||||
fClock.SetTime(time.Now())
|
fClock.SetTime(time.Now())
|
||||||
*expected.CreatedAt = fClock.Now().Unix()
|
*expected.CreatedAt = fClock.Now().UnixNano()
|
||||||
id, err := ds.RunPodSandbox(config)
|
id, err := ds.RunPodSandbox(config)
|
||||||
|
|
||||||
// Check internal labels
|
// Check internal labels
|
||||||
|
Loading…
Reference in New Issue
Block a user