Replace kubelet logging %s--%s--%s with dockertools.BuildDockerName()

Fixes issue #3454
This commit is contained in:
George Kuan 2015-01-15 19:47:54 -08:00
parent b1f5b3f287
commit af4bbd1a1b

View File

@ -1023,6 +1023,7 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
for _, container := range pod.Spec.Containers { for _, container := range pod.Spec.Containers {
expectedHash := dockertools.HashContainer(&container) expectedHash := dockertools.HashContainer(&container)
dockerContainerName := dockertools.BuildDockerName(uid, podFullName, &container)
if dockerContainer, found, hash := dockerContainers.FindPodContainer(podFullName, uid, container.Name); found { if dockerContainer, found, hash := dockerContainers.FindPodContainer(podFullName, uid, container.Name); found {
containerID := dockertools.DockerID(dockerContainer.ID) containerID := dockertools.DockerID(dockerContainer.ID)
glog.V(3).Infof("pod %q container %q exists as %v", podFullName, container.Name, containerID) glog.V(3).Infof("pod %q container %q exists as %v", podFullName, container.Name, containerID)
@ -1062,27 +1063,27 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
// Check RestartPolicy for container // Check RestartPolicy for container
recentContainers, err := dockertools.GetRecentDockerContainersWithNameAndUUID(kl.dockerClient, podFullName, uid, container.Name) recentContainers, err := dockertools.GetRecentDockerContainersWithNameAndUUID(kl.dockerClient, podFullName, uid, container.Name)
if err != nil { if err != nil {
glog.Errorf("Error listing recent containers with name and uid:%s--%s--%s", podFullName, uid, container.Name) glog.Errorf("Error listing recent containers:%s", dockerContainerName)
// TODO(dawnchen): error handling here? // TODO(dawnchen): error handling here?
} }
if len(recentContainers) > 0 && pod.Spec.RestartPolicy.Always == nil { if len(recentContainers) > 0 && pod.Spec.RestartPolicy.Always == nil {
if pod.Spec.RestartPolicy.Never != nil { if pod.Spec.RestartPolicy.Never != nil {
glog.V(3).Infof("Already ran container with name %s--%s--%s, do nothing", glog.V(3).Infof("Already ran container with name %s, do nothing",
podFullName, uid, container.Name) dockerContainerName)
continue continue
} }
if pod.Spec.RestartPolicy.OnFailure != nil { if pod.Spec.RestartPolicy.OnFailure != nil {
// Check the exit code of last run // Check the exit code of last run
if recentContainers[0].State.ExitCode == 0 { if recentContainers[0].State.ExitCode == 0 {
glog.V(3).Infof("Already successfully ran container with name %s--%s--%s, do nothing", glog.V(3).Infof("Already successfully ran container with name %s, do nothing",
podFullName, uid, container.Name) dockerContainerName)
continue continue
} }
} }
} }
glog.V(3).Infof("Container with name %s--%s--%s doesn't exist, creating %#v", podFullName, uid, container.Name, container) glog.V(3).Infof("Container with name %s doesn't exist, creating %#v", dockerContainerName)
ref, err := containerRef(pod, &container) ref, err := containerRef(pod, &container)
if err != nil { if err != nil {
glog.Errorf("Couldn't make a ref to pod %v, container %v: '%v'", pod.Name, container.Name, err) glog.Errorf("Couldn't make a ref to pod %v, container %v: '%v'", pod.Name, container.Name, err)