mirror of https://github.com/k3s-io/k3s
commit
7c694d2cad
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
|
|
@ -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()}
|
||||
|
||||
|
|
Loading…
Reference in New Issue