Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handling of unbound pods. #1596

Merged
merged 1 commit into from
Oct 6, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion pkg/kubecfg/resource_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,17 @@ func makeImageList(manifest api.ContainerManifest) string {
return strings.Join(images, ",")
}

func podHostString(host, ip string) string {
if host == "" && ip == "" {
return "<unassigned>"
}
return host + "/" + ip
}

func printPod(pod *api.Pod, w io.Writer) error {
_, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n",
pod.ID, makeImageList(pod.DesiredState.Manifest),
pod.CurrentState.Host+"/"+pod.CurrentState.HostIP,
podHostString(pod.CurrentState.Host, pod.CurrentState.HostIP),
labels.Set(pod.Labels), pod.CurrentState.Status)
return err
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/master/pod_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ func (p *PodCache) UpdateAllContainers() {
return
}
for _, pod := range pods.Items {
if pod.CurrentState.Host == "" {
continue
}
err := p.updatePodInfo(pod.CurrentState.Host, pod.ID)
if err != nil && err != client.ErrPodInfoNotAvailable {
glog.Errorf("Error synchronizing container: %v", err)
Expand Down
10 changes: 7 additions & 3 deletions pkg/registry/pod/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) {
}
pod.CurrentState.Status = status
}
pod.CurrentState.HostIP = rs.getInstanceIP(pod.CurrentState.Host)
if pod.CurrentState.Host != "" {
pod.CurrentState.HostIP = rs.getInstanceIP(pod.CurrentState.Host)
}
return pod, err
}

Expand Down Expand Up @@ -165,7 +167,9 @@ func (rs *REST) List(ctx api.Context, label, field labels.Selector) (runtime.Obj
return pod, err
}
pod.CurrentState.Status = status
pod.CurrentState.HostIP = rs.getInstanceIP(pod.CurrentState.Host)
if pod.CurrentState.Host != "" {
pod.CurrentState.HostIP = rs.getInstanceIP(pod.CurrentState.Host)
}
}
}
return pods, err
Expand Down Expand Up @@ -258,7 +262,7 @@ func getInstanceIPFromCloud(cloud cloudprovider.Interface, host string) string {
}
addr, err := instances.IPAddress(host)
if err != nil {
glog.Errorf("Error getting instance IP: %#v", err)
glog.Errorf("Error getting instance IP for %q: %#v", host, err)
return ""
}
return addr.String()
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/pod/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ func TestGetPod(t *testing.T) {
func TestGetPodCloud(t *testing.T) {
fakeCloud := &fake_cloud.FakeCloud{}
podRegistry := registrytest.NewPodRegistry(nil)
podRegistry.Pod = &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
podRegistry.Pod = &api.Pod{JSONBase: api.JSONBase{ID: "foo"}, CurrentState: api.PodState{Host: "machine"}}

clock := &fakeClock{t: time.Now()}

Expand Down