Replace %s with %q to make empty strings more obvious

pull/6/head
saadali 2015-01-05 16:38:47 -08:00
parent eb831919d9
commit d6d18a32e7
1 changed files with 32 additions and 32 deletions

View File

@ -244,7 +244,7 @@ func (kl *Kubelet) GarbageCollectImages() error {
} }
for ix := range images { for ix := range images {
if err := kl.dockerClient.RemoveImage(images[ix]); err != nil { if err := kl.dockerClient.RemoveImage(images[ix]); err != nil {
glog.Errorf("Failed to remove image: %s (%v)", images[ix], err) glog.Errorf("Failed to remove image: %q (%v)", images[ix], err)
} }
} }
return nil return nil
@ -383,7 +383,7 @@ func makePortsAndBindings(container *api.Container) (map[docker.Port]struct{}, m
case "TCP": case "TCP":
protocol = "/tcp" protocol = "/tcp"
default: default:
glog.Warningf("Unknown protocol '%s': defaulting to TCP", port.Protocol) glog.Warningf("Unknown protocol %q: defaulting to TCP", port.Protocol)
protocol = "/tcp" protocol = "/tcp"
} }
dockerPort := docker.Port(strconv.Itoa(interiorPort) + protocol) dockerPort := docker.Port(strconv.Itoa(interiorPort) + protocol)
@ -559,12 +559,12 @@ func (kl *Kubelet) runContainer(pod *api.BoundPod, container *api.Container, pod
if len(container.TerminationMessagePath) != 0 { if len(container.TerminationMessagePath) != 0 {
p := kl.GetPodContainerDir(pod.UID, container.Name) p := kl.GetPodContainerDir(pod.UID, container.Name)
if err := os.MkdirAll(p, 0750); err != nil { if err := os.MkdirAll(p, 0750); err != nil {
glog.Errorf("Error on creating %s: %v", p, err) glog.Errorf("Error on creating %q: %v", p, err)
} else { } else {
containerLogPath := path.Join(p, dockerContainer.ID) containerLogPath := path.Join(p, dockerContainer.ID)
fs, err := os.Create(containerLogPath) fs, err := os.Create(containerLogPath)
if err != nil { if err != nil {
glog.Errorf("Error on creating termination-log file %s: %v", containerLogPath, err) glog.Errorf("Error on creating termination-log file %q: %v", containerLogPath, err)
} }
defer fs.Close() defer fs.Close()
b := fmt.Sprintf("%s:%s", containerLogPath, container.TerminationMessagePath) b := fmt.Sprintf("%s:%s", containerLogPath, container.TerminationMessagePath)
@ -672,7 +672,7 @@ func (kl *Kubelet) killContainer(dockerContainer *docker.APIContainers) error {
} }
func (kl *Kubelet) killContainerByID(ID, name string) error { func (kl *Kubelet) killContainerByID(ID, name string) error {
glog.V(2).Infof("Killing container with id %s and name %s", ID, name) glog.V(2).Infof("Killing container with id %q and name %q", ID, name)
err := kl.dockerClient.StopContainer(ID, 10) err := kl.dockerClient.StopContainer(ID, 10)
if len(name) == 0 { if len(name) == 0 {
return err return err
@ -715,7 +715,7 @@ func (kl *Kubelet) createNetworkContainer(pod *api.BoundPod) (dockertools.Docker
ok, err := kl.dockerPuller.IsImagePresent(container.Image) ok, err := kl.dockerPuller.IsImagePresent(container.Image)
if err != nil { if err != nil {
if ref != nil { if ref != nil {
record.Eventf(ref, "failed", "failed", "Failed to inspect image %s", container.Image) record.Eventf(ref, "failed", "failed", "Failed to inspect image %q", container.Image)
} }
return "", err return "", err
} }
@ -725,7 +725,7 @@ func (kl *Kubelet) createNetworkContainer(pod *api.BoundPod) (dockertools.Docker
} }
} }
if ref != nil { if ref != nil {
record.Eventf(ref, "waiting", "pulled", "Successfully pulled image %s", container.Image) record.Eventf(ref, "waiting", "pulled", "Successfully pulled image %q", container.Image)
} }
return kl.runContainer(pod, container, nil, "") return kl.runContainer(pod, container, nil, "")
} }
@ -735,7 +735,7 @@ func (kl *Kubelet) pullImage(img string, ref *api.ObjectReference) error {
defer kl.pullLock.RUnlock() defer kl.pullLock.RUnlock()
if err := kl.dockerPuller.Pull(img); err != nil { if err := kl.dockerPuller.Pull(img); err != nil {
if ref != nil { if ref != nil {
record.Eventf(ref, "failed", "failed", "Failed to pull image %s", img) record.Eventf(ref, "failed", "failed", "Failed to pull image %q", img)
} }
return err return err
} }
@ -757,7 +757,7 @@ func (kl *Kubelet) killContainersInPod(pod *api.BoundPod, dockerContainers docke
go func() { go func() {
err := kl.killContainer(dockerContainer) err := kl.killContainer(dockerContainer)
if err != nil { if err != nil {
glog.Errorf("Failed to delete container: %v; Skipping pod %s", err, podFullName) glog.Errorf("Failed to delete container: %v; Skipping pod %q", err, podFullName)
errs <- err errs <- err
} }
wg.Done() wg.Done()
@ -783,7 +783,7 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
uuid := pod.UID uuid := pod.UID
containersToKeep := make(map[dockertools.DockerID]empty) containersToKeep := make(map[dockertools.DockerID]empty)
killedContainers := make(map[dockertools.DockerID]empty) killedContainers := make(map[dockertools.DockerID]empty)
glog.V(4).Infof("Syncing Pod, podFullName: %s, uuid: %s", podFullName, uuid) glog.V(4).Infof("Syncing Pod, podFullName: %q, uuid: %q", podFullName, uuid)
// Make sure we have a network container // Make sure we have a network container
var netID dockertools.DockerID var netID dockertools.DockerID
@ -797,7 +797,7 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
} }
netID, err = kl.createNetworkContainer(pod) netID, err = kl.createNetworkContainer(pod)
if err != nil { if err != nil {
glog.Errorf("Failed to introspect network container: %v; Skipping pod %s", err, podFullName) glog.Errorf("Failed to introspect network container: %v; Skipping pod %q", err, podFullName)
return err return err
} }
if count > 0 { if count > 0 {
@ -813,14 +813,14 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
podVolumes, err := kl.mountExternalVolumes(pod) podVolumes, err := kl.mountExternalVolumes(pod)
if err != nil { if err != nil {
glog.Errorf("Unable to mount volumes for pod %s: %v; skipping pod", podFullName, err) glog.Errorf("Unable to mount volumes for pod %q: %v; skipping pod", podFullName, err)
return err return err
} }
podStatus := api.PodStatus{} podStatus := api.PodStatus{}
info, err := kl.GetPodInfo(podFullName, uuid) info, err := kl.GetPodInfo(podFullName, uuid)
if err != nil { if err != nil {
glog.Errorf("Unable to get pod with name %s and uuid %s info, health checks may be invalid", podFullName, uuid) glog.Errorf("Unable to get pod with name %q and uuid %q info, health checks may be invalid", podFullName, uuid)
} }
netInfo, found := info[networkContainerName] netInfo, found := info[networkContainerName]
if found { if found {
@ -831,7 +831,7 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
expectedHash := dockertools.HashContainer(&container) expectedHash := dockertools.HashContainer(&container)
if dockerContainer, found, hash := dockerContainers.FindPodContainer(podFullName, uuid, container.Name); found { if dockerContainer, found, hash := dockerContainers.FindPodContainer(podFullName, uuid, container.Name); found {
containerID := dockertools.DockerID(dockerContainer.ID) containerID := dockertools.DockerID(dockerContainer.ID)
glog.V(3).Infof("pod %s container %s exists as %v", podFullName, container.Name, containerID) glog.V(3).Infof("pod %q container %q exists as %v", podFullName, container.Name, containerID)
// look for changes in the container. // look for changes in the container.
if hash == 0 || hash == expectedHash { if hash == 0 || hash == expectedHash {
@ -846,12 +846,12 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
containersToKeep[containerID] = empty{} containersToKeep[containerID] = empty{}
continue continue
} }
glog.V(1).Infof("pod %s container %s is unhealthy. Container will be killed and re-created.", podFullName, container.Name, healthy) glog.V(1).Infof("pod %q container %q is unhealthy. Container will be killed and re-created.", podFullName, container.Name, healthy)
} else { } else {
glog.V(1).Infof("pod %s container %s hash changed (%d vs %d). Container will be killed and re-created.", podFullName, container.Name, hash, expectedHash) glog.V(1).Infof("pod %q container %q hash changed (%d vs %d). Container will be killed and re-created.", podFullName, container.Name, hash, expectedHash)
} }
if err := kl.killContainer(dockerContainer); err != nil { if err := kl.killContainer(dockerContainer); err != nil {
glog.V(1).Infof("Failed to kill container %s: %v", dockerContainer.ID, err) glog.V(1).Infof("Failed to kill container %q: %v", dockerContainer.ID, err)
continue continue
} }
killedContainers[containerID] = empty{} killedContainers[containerID] = empty{}
@ -859,7 +859,7 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
// Also kill associated network container // Also kill associated network container
if netContainer, found, _ := dockerContainers.FindPodContainer(podFullName, uuid, networkContainerName); found { if netContainer, found, _ := dockerContainers.FindPodContainer(podFullName, uuid, networkContainerName); found {
if err := kl.killContainer(netContainer); err != nil { if err := kl.killContainer(netContainer); err != nil {
glog.V(1).Infof("Failed to kill network container %s: %v", netContainer.ID, err) glog.V(1).Infof("Failed to kill network container %q: %v", netContainer.ID, err)
continue continue
} }
} }
@ -898,9 +898,9 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
latest := dockertools.RequireLatestImage(container.Image) latest := dockertools.RequireLatestImage(container.Image)
if err != nil { if err != nil {
if ref != nil { if ref != nil {
record.Eventf(ref, "failed", "failed", "Failed to inspect image %s", container.Image) record.Eventf(ref, "failed", "failed", "Failed to inspect image %q", container.Image)
} }
glog.Errorf("Failed to inspect image %s: %v; skipping pod %s container %s", container.Image, err, podFullName, container.Name) glog.Errorf("Failed to inspect image %q: %v; skipping pod %q container %q", container.Image, err, podFullName, container.Name)
continue continue
} }
if api.IsPullAlways(container.ImagePullPolicy) || if api.IsPullAlways(container.ImagePullPolicy) ||
@ -908,13 +908,13 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
if err := kl.dockerPuller.Pull(container.Image); err != nil { if err := kl.dockerPuller.Pull(container.Image); err != nil {
if ref != nil { if ref != nil {
record.Eventf(ref, "failed", "failed", "Failed to pull image %s", container.Image) record.Eventf(ref, "failed", "failed", "Failed to pull image %q", container.Image)
} }
glog.Errorf("Failed to pull image %s: %v; skipping pod %s container %s.", container.Image, err, podFullName, container.Name) glog.Errorf("Failed to pull image %q: %v; skipping pod %q container %q.", container.Image, err, podFullName, container.Name)
continue continue
} }
if ref != nil { if ref != nil {
record.Eventf(ref, "waiting", "pulled", "Successfully pulled image %s", container.Image) record.Eventf(ref, "waiting", "pulled", "Successfully pulled image %q", container.Image)
} }
} }
} }
@ -922,7 +922,7 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
containerID, err := kl.runContainer(pod, &container, podVolumes, "container:"+string(netID)) containerID, err := kl.runContainer(pod, &container, podVolumes, "container:"+string(netID))
if err != nil { if err != nil {
// TODO(bburns) : Perhaps blacklist a container after N failures? // TODO(bburns) : Perhaps blacklist a container after N failures?
glog.Errorf("Error running pod %s container %s: %v", podFullName, container.Name, err) glog.Errorf("Error running pod %q container %q: %v", podFullName, container.Name, err)
continue continue
} }
containersToKeep[containerID] = empty{} containersToKeep[containerID] = empty{}
@ -976,11 +976,11 @@ func (kl *Kubelet) reconcileVolumes(pods []api.BoundPod) error {
if _, ok := desiredVolumes[name]; !ok { if _, ok := desiredVolumes[name]; !ok {
//TODO (jonesdl) We should somehow differentiate between volumes that are supposed //TODO (jonesdl) We should somehow differentiate between volumes that are supposed
//to be deleted and volumes that are leftover after a crash. //to be deleted and volumes that are leftover after a crash.
glog.Warningf("Orphaned volume %s found, tearing down volume", name) glog.Warningf("Orphaned volume %q found, tearing down volume", name)
//TODO (jonesdl) This should not block other kubelet synchronization procedures //TODO (jonesdl) This should not block other kubelet synchronization procedures
err := vol.TearDown() err := vol.TearDown()
if err != nil { if err != nil {
glog.Errorf("Could not tear down volume %s: %v", name, err) glog.Errorf("Could not tear down volume %q: %v", name, err)
} }
} }
} }
@ -1064,10 +1064,10 @@ func updateBoundPods(changed []api.BoundPod, current []api.BoundPod) []api.Bound
pod := &current[i] pod := &current[i]
if m[pod.UID] != nil { if m[pod.UID] != nil {
updated = append(updated, *m[pod.UID]) updated = append(updated, *m[pod.UID])
glog.V(4).Infof("pod with UID: %s has a new spec %+v", pod.UID, *m[pod.UID]) glog.V(4).Infof("pod with UID: %q has a new spec %+v", pod.UID, *m[pod.UID])
} else { } else {
updated = append(updated, *pod) updated = append(updated, *pod)
glog.V(4).Infof("pod with UID: %s stay with the same spec %+v", pod.UID, *pod) glog.V(4).Infof("pod with UID: %q stay with the same spec %+v", pod.UID, *pod)
} }
} }
@ -1082,7 +1082,7 @@ func filterHostPortConflicts(pods []api.BoundPod) []api.BoundPod {
for i := range pods { for i := range pods {
pod := &pods[i] pod := &pods[i]
if errs := validation.AccumulateUniquePorts(pod.Spec.Containers, ports, extract); len(errs) != 0 { if errs := validation.AccumulateUniquePorts(pod.Spec.Containers, ports, extract); len(errs) != 0 {
glog.Warningf("Pod %s: HostPort is already allocated, ignoring: %v", GetPodFullName(pod), errs) glog.Warningf("Pod %q: HostPort is already allocated, ignoring: %v", GetPodFullName(pod), errs)
continue continue
} }
filtered = append(filtered, *pod) filtered = append(filtered, *pod)
@ -1132,7 +1132,7 @@ func (kl *Kubelet) syncLoop(updates <-chan PodUpdate, handler SyncHandler) {
func (kl *Kubelet) GetKubeletContainerLogs(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error { func (kl *Kubelet) GetKubeletContainerLogs(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error {
_, err := kl.GetPodInfo(podFullName, "") _, err := kl.GetPodInfo(podFullName, "")
if err == dockertools.ErrNoContainersInPod { if err == dockertools.ErrNoContainersInPod {
return fmt.Errorf("pod not found (%s)\n", podFullName) return fmt.Errorf("pod not found (%q)\n", podFullName)
} }
dockerContainers, err := dockertools.GetKubeletDockerContainers(kl.dockerClient, true) dockerContainers, err := dockertools.GetKubeletDockerContainers(kl.dockerClient, true)
if err != nil { if err != nil {
@ -1140,7 +1140,7 @@ func (kl *Kubelet) GetKubeletContainerLogs(podFullName, containerName, tail stri
} }
dockerContainer, found, _ := dockerContainers.FindPodContainer(podFullName, "", containerName) dockerContainer, found, _ := dockerContainers.FindPodContainer(podFullName, "", containerName)
if !found { if !found {
return fmt.Errorf("container not found (%s)\n", containerName) return fmt.Errorf("container not found (%q)\n", containerName)
} }
return dockertools.GetKubeletDockerContainerLogs(kl.dockerClient, dockerContainer.ID, tail, follow, stdout, stderr) return dockertools.GetKubeletDockerContainerLogs(kl.dockerClient, dockerContainer.ID, tail, follow, stdout, stderr)
} }
@ -1193,7 +1193,7 @@ func (kl *Kubelet) RunInContainer(podFullName, uuid, container string, cmd []str
} }
dockerContainer, found, _ := dockerContainers.FindPodContainer(podFullName, uuid, container) dockerContainer, found, _ := dockerContainers.FindPodContainer(podFullName, uuid, container)
if !found { if !found {
return nil, fmt.Errorf("container not found (%s)", container) return nil, fmt.Errorf("container not found (%q)", container)
} }
return kl.runner.RunInContainer(dockerContainer.ID, cmd) return kl.runner.RunInContainer(dockerContainer.ID, cmd)
} }