From e01df6956523a6fba6b6f74dc5d72ce7a598f2df Mon Sep 17 00:00:00 2001 From: Federico Simoncelli Date: Thu, 5 Feb 2015 17:24:48 -0500 Subject: [PATCH] api: add image's id to ContainerStatus Sometimes for external applications it is important to identify exactly what images are running. Since tags can be moved to point to newer builds this information can be used to identify old images running. Signed-off-by: Federico Simoncelli --- pkg/api/types.go | 1 + pkg/api/v1beta1/types.go | 1 + pkg/api/v1beta2/types.go | 1 + pkg/api/v1beta3/types.go | 3 ++- pkg/kubelet/dockertools/docker.go | 4 +++- 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/api/types.go b/pkg/api/types.go index fabb20f0a4c..589252eebd0 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -440,6 +440,7 @@ type ContainerStatus struct { PodIP string `json:"podIP,omitempty"` // TODO(dchen1107): Need to decide how to represent this in v1beta3 Image string `json:"image"` + ImageID string `json:"imageID" description:"ID of the container's image"` ContainerID string `json:"containerID,omitempty" description:"container's ID in the format 'docker://'"` } diff --git a/pkg/api/v1beta1/types.go b/pkg/api/v1beta1/types.go index 9f829a92b6d..9838916fc81 100644 --- a/pkg/api/v1beta1/types.go +++ b/pkg/api/v1beta1/types.go @@ -406,6 +406,7 @@ type ContainerStatus struct { PodIP string `json:"podIP,omitempty" description:"pod's IP address"` // TODO(dchen1107): Need to decide how to reprensent this in v1beta3 Image string `json:"image" description:"image of the container"` + ImageID string `json:"imageID" description:"ID of the container's image"` ContainerID string `json:"containerID,omitempty" description:"container's ID in the format 'docker://'"` } diff --git a/pkg/api/v1beta2/types.go b/pkg/api/v1beta2/types.go index ade358961b4..b1b497a9bf4 100644 --- a/pkg/api/v1beta2/types.go +++ b/pkg/api/v1beta2/types.go @@ -370,6 +370,7 @@ type ContainerStatus struct { PodIP string `json:"podIP,omitempty" description:"pod's IP address"` // TODO(dchen1107): Need to decide how to reprensent this in v1beta3 Image string `json:"image" description:"image of the container"` + ImageID string `json:"imageID" description:"ID of the container's image"` ContainerID string `json:"containerID,omitempty" description:"container's ID in the format 'docker://'"` } diff --git a/pkg/api/v1beta3/types.go b/pkg/api/v1beta3/types.go index 88dceecea78..2ded72e8a23 100644 --- a/pkg/api/v1beta3/types.go +++ b/pkg/api/v1beta3/types.go @@ -462,7 +462,8 @@ type ContainerStatus struct { PodIP string `json:"podIP,omitempty"` // TODO(dchen1107): Which image the container is running with? // The image the container is running - Image string `json:"image"` + Image string `json:"image"` + ImageID string `json:"imageID" description:"ID of the container's image"` } // PodInfo contains one entry for every container with available info. diff --git a/pkg/kubelet/dockertools/docker.go b/pkg/kubelet/dockertools/docker.go index 41e5a98ef66..bbe6b86f0bf 100644 --- a/pkg/kubelet/dockertools/docker.go +++ b/pkg/kubelet/dockertools/docker.go @@ -41,6 +41,7 @@ import ( const ( PodInfraContainerName = leaky.PodInfraContainerName + DockerPrefix = "docker://" ) // DockerInterface is an abstract interface for testability. It abstracts the interface of docker.Client. @@ -399,7 +400,8 @@ func inspectContainer(client DockerInterface, dockerID, containerName, tPath str glog.V(3).Infof("Container inspect result: %+v", *inspectResult) containerStatus := api.ContainerStatus{ Image: inspectResult.Config.Image, - ContainerID: "docker://" + dockerID, + ImageID: DockerPrefix + inspectResult.Image, + ContainerID: DockerPrefix + dockerID, } waiting := true