mirror of https://github.com/k3s-io/k3s
Merge pull request #24630 from euank/redundant-created
Automatic merge from submit-queue kubelet: Remove redundant `Container.Created` As far as I can tell, this has been supplanted by a) the `DockerJSON.CreatedAt` field and b) the `ContainerStatus.CreatedAt`, where the first is used for creating the second. The `.Created` field was only written to as far as I can see. cc @yifan-gu & @Random-Liu Is there any reason we might want to keep this around?pull/6/head
commit
fe135fc251
|
@ -91,12 +91,11 @@ func ConvertPodStatusToRunningPod(podStatus *PodStatus) Pod {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
container := &Container{
|
container := &Container{
|
||||||
ID: containerStatus.ID,
|
ID: containerStatus.ID,
|
||||||
Name: containerStatus.Name,
|
Name: containerStatus.Name,
|
||||||
Image: containerStatus.Image,
|
Image: containerStatus.Image,
|
||||||
Hash: containerStatus.Hash,
|
Hash: containerStatus.Hash,
|
||||||
Created: containerStatus.CreatedAt.Unix(),
|
State: containerStatus.State,
|
||||||
State: containerStatus.State,
|
|
||||||
}
|
}
|
||||||
runningPod.Containers = append(runningPod.Containers, container)
|
runningPod.Containers = append(runningPod.Containers, container)
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,9 +237,6 @@ type Container struct {
|
||||||
// Hash of the container, used for comparison. Optional for containers
|
// Hash of the container, used for comparison. Optional for containers
|
||||||
// not managed by kubelet.
|
// not managed by kubelet.
|
||||||
Hash uint64
|
Hash uint64
|
||||||
// The timestamp of the creation time of the container.
|
|
||||||
// TODO(yifan): Consider to move it to api.ContainerStatus.
|
|
||||||
Created int64
|
|
||||||
// State is the state of the container.
|
// State is the state of the container.
|
||||||
State ContainerState
|
State ContainerState
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,11 +56,10 @@ func toRuntimeContainer(c *dockertypes.Container) (*kubecontainer.Container, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &kubecontainer.Container{
|
return &kubecontainer.Container{
|
||||||
ID: kubecontainer.DockerID(c.ID).ContainerID(),
|
ID: kubecontainer.DockerID(c.ID).ContainerID(),
|
||||||
Name: dockerName.ContainerName,
|
Name: dockerName.ContainerName,
|
||||||
Image: c.Image,
|
Image: c.Image,
|
||||||
Hash: hash,
|
Hash: hash,
|
||||||
Created: c.Created,
|
|
||||||
// (random-liu) docker uses status to indicate whether a container is running or exited.
|
// (random-liu) docker uses status to indicate whether a container is running or exited.
|
||||||
// However, in kubernetes we usually use state to indicate whether a container is running or exited,
|
// However, in kubernetes we usually use state to indicate whether a container is running or exited,
|
||||||
// while use status to indicate the comprehensive status of the container. So we have different naming
|
// while use status to indicate the comprehensive status of the container. So we have different naming
|
||||||
|
|
|
@ -44,19 +44,17 @@ func TestMapState(t *testing.T) {
|
||||||
|
|
||||||
func TestToRuntimeContainer(t *testing.T) {
|
func TestToRuntimeContainer(t *testing.T) {
|
||||||
original := &dockertypes.Container{
|
original := &dockertypes.Container{
|
||||||
ID: "ab2cdf",
|
ID: "ab2cdf",
|
||||||
Image: "bar_image",
|
Image: "bar_image",
|
||||||
Created: 12345,
|
Names: []string{"/k8s_bar.5678_foo_ns_1234_42"},
|
||||||
Names: []string{"/k8s_bar.5678_foo_ns_1234_42"},
|
Status: "Up 5 hours",
|
||||||
Status: "Up 5 hours",
|
|
||||||
}
|
}
|
||||||
expected := &kubecontainer.Container{
|
expected := &kubecontainer.Container{
|
||||||
ID: kubecontainer.ContainerID{Type: "docker", ID: "ab2cdf"},
|
ID: kubecontainer.ContainerID{Type: "docker", ID: "ab2cdf"},
|
||||||
Name: "bar",
|
Name: "bar",
|
||||||
Image: "bar_image",
|
Image: "bar_image",
|
||||||
Hash: 0x5678,
|
Hash: 0x5678,
|
||||||
Created: 12345,
|
State: kubecontainer.ContainerStateRunning,
|
||||||
State: kubecontainer.ContainerStateRunning,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
actual, err := toRuntimeContainer(original)
|
actual, err := toRuntimeContainer(original)
|
||||||
|
|
|
@ -812,11 +812,10 @@ func apiPodToruntimePod(uuid string, pod *api.Pod) *kubecontainer.Pod {
|
||||||
for i := range pod.Spec.Containers {
|
for i := range pod.Spec.Containers {
|
||||||
c := &pod.Spec.Containers[i]
|
c := &pod.Spec.Containers[i]
|
||||||
p.Containers = append(p.Containers, &kubecontainer.Container{
|
p.Containers = append(p.Containers, &kubecontainer.Container{
|
||||||
ID: buildContainerID(&containerID{uuid, c.Name}),
|
ID: buildContainerID(&containerID{uuid, c.Name}),
|
||||||
Name: c.Name,
|
Name: c.Name,
|
||||||
Image: c.Image,
|
Image: c.Image,
|
||||||
Hash: kubecontainer.HashContainer(c),
|
Hash: kubecontainer.HashContainer(c),
|
||||||
Created: time.Now().Unix(),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return p
|
return p
|
||||||
|
@ -1193,10 +1192,9 @@ func (r *Runtime) convertRktPod(rktpod *rktapi.Pod) (*kubecontainer.Pod, error)
|
||||||
ID: buildContainerID(&containerID{rktpod.Id, app.Name}),
|
ID: buildContainerID(&containerID{rktpod.Id, app.Name}),
|
||||||
Name: app.Name,
|
Name: app.Name,
|
||||||
// By default, the version returned by rkt API service will be "latest" if not specified.
|
// By default, the version returned by rkt API service will be "latest" if not specified.
|
||||||
Image: fmt.Sprintf("%s:%s", app.Image.Name, app.Image.Version),
|
Image: fmt.Sprintf("%s:%s", app.Image.Name, app.Image.Version),
|
||||||
Hash: containerHash,
|
Hash: containerHash,
|
||||||
State: appStateToContainerState(app.State),
|
State: appStateToContainerState(app.State),
|
||||||
Created: time.Unix(0, rktpod.CreatedAt).Unix(), // convert ns to s
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -379,20 +379,18 @@ func TestGetPods(t *testing.T) {
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
Containers: []*kubecontainer.Container{
|
Containers: []*kubecontainer.Container{
|
||||||
{
|
{
|
||||||
ID: kubecontainer.BuildContainerID("rkt", "uuid-4002:app-1"),
|
ID: kubecontainer.BuildContainerID("rkt", "uuid-4002:app-1"),
|
||||||
Name: "app-1",
|
Name: "app-1",
|
||||||
Image: "img-name-1:latest",
|
Image: "img-name-1:latest",
|
||||||
Hash: 1001,
|
Hash: 1001,
|
||||||
Created: 10,
|
State: "running",
|
||||||
State: "running",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: kubecontainer.BuildContainerID("rkt", "uuid-4002:app-2"),
|
ID: kubecontainer.BuildContainerID("rkt", "uuid-4002:app-2"),
|
||||||
Name: "app-2",
|
Name: "app-2",
|
||||||
Image: "img-name-2:latest",
|
Image: "img-name-2:latest",
|
||||||
Hash: 1002,
|
Hash: 1002,
|
||||||
Created: 10,
|
State: "exited",
|
||||||
State: "exited",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -439,20 +437,18 @@ func TestGetPods(t *testing.T) {
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
Containers: []*kubecontainer.Container{
|
Containers: []*kubecontainer.Container{
|
||||||
{
|
{
|
||||||
ID: kubecontainer.BuildContainerID("rkt", "uuid-4002:app-1"),
|
ID: kubecontainer.BuildContainerID("rkt", "uuid-4002:app-1"),
|
||||||
Name: "app-1",
|
Name: "app-1",
|
||||||
Image: "img-name-1:latest",
|
Image: "img-name-1:latest",
|
||||||
Hash: 1001,
|
Hash: 1001,
|
||||||
Created: 10,
|
State: "running",
|
||||||
State: "running",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: kubecontainer.BuildContainerID("rkt", "uuid-4002:app-2"),
|
ID: kubecontainer.BuildContainerID("rkt", "uuid-4002:app-2"),
|
||||||
Name: "app-2",
|
Name: "app-2",
|
||||||
Image: "img-name-2:latest",
|
Image: "img-name-2:latest",
|
||||||
Hash: 1002,
|
Hash: 1002,
|
||||||
Created: 10,
|
State: "exited",
|
||||||
State: "exited",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -462,36 +458,32 @@ func TestGetPods(t *testing.T) {
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
Containers: []*kubecontainer.Container{
|
Containers: []*kubecontainer.Container{
|
||||||
{
|
{
|
||||||
ID: kubecontainer.BuildContainerID("rkt", "uuid-4003:app-11"),
|
ID: kubecontainer.BuildContainerID("rkt", "uuid-4003:app-11"),
|
||||||
Name: "app-11",
|
Name: "app-11",
|
||||||
Image: "img-name-11:latest",
|
Image: "img-name-11:latest",
|
||||||
Hash: 10011,
|
Hash: 10011,
|
||||||
Created: 30,
|
State: "exited",
|
||||||
State: "exited",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: kubecontainer.BuildContainerID("rkt", "uuid-4003:app-22"),
|
ID: kubecontainer.BuildContainerID("rkt", "uuid-4003:app-22"),
|
||||||
Name: "app-22",
|
Name: "app-22",
|
||||||
Image: "img-name-22:latest",
|
Image: "img-name-22:latest",
|
||||||
Hash: 10022,
|
Hash: 10022,
|
||||||
Created: 30,
|
State: "exited",
|
||||||
State: "exited",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: kubecontainer.BuildContainerID("rkt", "uuid-4004:app-11"),
|
ID: kubecontainer.BuildContainerID("rkt", "uuid-4004:app-11"),
|
||||||
Name: "app-11",
|
Name: "app-11",
|
||||||
Image: "img-name-11:latest",
|
Image: "img-name-11:latest",
|
||||||
Hash: 10011,
|
Hash: 10011,
|
||||||
Created: 50,
|
State: "running",
|
||||||
State: "running",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: kubecontainer.BuildContainerID("rkt", "uuid-4004:app-22"),
|
ID: kubecontainer.BuildContainerID("rkt", "uuid-4004:app-22"),
|
||||||
Name: "app-22",
|
Name: "app-22",
|
||||||
Image: "img-name-22:latest",
|
Image: "img-name-22:latest",
|
||||||
Hash: 10022,
|
Hash: 10022,
|
||||||
Created: 50,
|
State: "running",
|
||||||
State: "running",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue