Merge pull request #123583 from saschagrunert/image-id-container-status
Add `image_id` to CRI `ContainerStatus` message
This commit is contained in:
@@ -273,6 +273,7 @@ func ConvertPodStatusToRunningPod(runtimeName string, podStatus *PodStatus) Pod
|
||||
Name: containerStatus.Name,
|
||||
Image: containerStatus.Image,
|
||||
ImageID: containerStatus.ImageID,
|
||||
ImageRef: containerStatus.ImageRef,
|
||||
ImageRuntimeHandler: containerStatus.ImageRuntimeHandler,
|
||||
Hash: containerStatus.Hash,
|
||||
HashWithoutResources: containerStatus.HashWithoutResources,
|
||||
|
@@ -357,6 +357,8 @@ type Status struct {
|
||||
Image string
|
||||
// ID of the image.
|
||||
ImageID string
|
||||
// The digested reference of the image used by the container.
|
||||
ImageRef string
|
||||
// Runtime handler used to pull the image if any.
|
||||
ImageRuntimeHandler string
|
||||
// Hash of the container, used for comparison.
|
||||
|
@@ -1986,8 +1986,11 @@ func (kl *Kubelet) convertToAPIContainerStatuses(pod *v1.Pod, podStatus *kubecon
|
||||
Name: cs.Name,
|
||||
RestartCount: int32(cs.RestartCount),
|
||||
Image: cs.Image,
|
||||
ImageID: cs.ImageID,
|
||||
ContainerID: cid,
|
||||
// Converting the digested image ref to the Kubernetes public
|
||||
// ContainerStatus.ImageID is historically intentional and should
|
||||
// not change.
|
||||
ImageID: cs.ImageRef,
|
||||
ContainerID: cid,
|
||||
}
|
||||
switch {
|
||||
case cs.State == kubecontainer.ContainerStateRunning:
|
||||
|
@@ -4585,7 +4585,8 @@ func TestConvertToAPIContainerStatusesForResources(t *testing.T) {
|
||||
Name: testContainerName,
|
||||
ID: testContainerID,
|
||||
Image: "img",
|
||||
ImageID: "img1234",
|
||||
ImageID: "1234",
|
||||
ImageRef: "img1234",
|
||||
State: kubecontainer.ContainerStateRunning,
|
||||
StartedAt: nowTime,
|
||||
}
|
||||
|
@@ -609,6 +609,13 @@ func toKubeContainerStatus(status *runtimeapi.ContainerStatus, runtimeName strin
|
||||
// If runtime reports cpu & memory resources info, add it to container status
|
||||
cStatusResources = toKubeContainerResources(status.Resources)
|
||||
}
|
||||
|
||||
// Keep backwards compatibility to older runtimes, status.ImageId has been added in v1.30
|
||||
imageID := status.ImageRef
|
||||
if status.ImageId != "" {
|
||||
imageID = status.ImageId
|
||||
}
|
||||
|
||||
cStatus := &kubecontainer.Status{
|
||||
ID: kubecontainer.ContainerID{
|
||||
Type: runtimeName,
|
||||
@@ -616,7 +623,8 @@ func toKubeContainerStatus(status *runtimeapi.ContainerStatus, runtimeName strin
|
||||
},
|
||||
Name: labeledInfo.ContainerName,
|
||||
Image: status.Image.Image,
|
||||
ImageID: status.ImageRef,
|
||||
ImageID: imageID,
|
||||
ImageRef: status.ImageRef,
|
||||
ImageRuntimeHandler: status.Image.RuntimeHandler,
|
||||
Hash: annotatedInfo.Hash,
|
||||
HashWithoutResources: annotatedInfo.HashWithoutResources,
|
||||
|
Reference in New Issue
Block a user