Addressed comments.

This commit is contained in:
Dawn Chen 2014-10-06 11:54:51 -07:00
parent a86d496f9a
commit 4fdfeaa30e
4 changed files with 31 additions and 15 deletions

View File

@ -329,7 +329,7 @@ type ContainerStatus struct {
// TODO(dchen1107): Deprecated this soon once we pull entire PodStatus from node, // TODO(dchen1107): Deprecated this soon once we pull entire PodStatus from node,
// not just PodInfo. Now we need this to remove docker.Container from API // not just PodInfo. Now we need this to remove docker.Container from API
PodIP string `json:"podIP,omitempty" yaml:"podIP,omitempty"` PodIP string `json:"podIP,omitempty" yaml:"podIP,omitempty"`
// TODO(dchen1107): Need to decide how to reprensent this in v1beta3 // TODO(dchen1107): Need to decide how to represent this in v1beta3
Image string `yaml:"image" json:"image"` Image string `yaml:"image" json:"image"`
// TODO(dchen1107): Once we have done with integration with cadvisor, resource // TODO(dchen1107): Once we have done with integration with cadvisor, resource
// usage should be included. // usage should be included.

View File

@ -275,7 +275,7 @@ var (
ErrNoContainersInPod = errors.New("no containers exist for this pod") ErrNoContainersInPod = errors.New("no containers exist for this pod")
// ErrNoNetworkContainerInPod is returned when there is no network container for a given pod // ErrNoNetworkContainerInPod is returned when there is no network container for a given pod
ErrNoNetworkContainerInPod = errors.New("No network container exist for this pod") ErrNoNetworkContainerInPod = errors.New("No network container exists for this pod")
// ErrContainerCannotRun is returned when a container is created, but cannot run properly // ErrContainerCannotRun is returned when a container is created, but cannot run properly
ErrContainerCannotRun = errors.New("Container cannot run") ErrContainerCannotRun = errors.New("Container cannot run")
@ -292,8 +292,9 @@ func inspectContainer(client DockerInterface, dockerID, containerName string) (*
} }
glog.V(3).Infof("Container: %s [%s] inspect result %+v", *inspectResult) glog.V(3).Infof("Container: %s [%s] inspect result %+v", *inspectResult)
var containerStatus api.ContainerStatus containerStatus := api.ContainerStatus{
containerStatus.Image = inspectResult.Config.Image Image: inspectResult.Config.Image,
}
waiting := true waiting := true
if inspectResult.State.Running { if inspectResult.State.Running {
@ -377,19 +378,23 @@ func GetDockerPodInfo(client DockerInterface, manifest api.ContainerManifest, po
} }
image := container.Image image := container.Image
containerStatus.State.Waiting = &api.ContainerStateWaiting{}
// Check image is ready on the node or not // Check image is ready on the node or not
// TODO(dchen1107): docker/docker/issues/8365 to figure out if the image exists // TODO(dchen1107): docker/docker/issues/8365 to figure out if the image exists
_, err := client.InspectImage(image) _, err := client.InspectImage(image)
if err != nil && err == docker.ErrNoSuchImage { if err == nil {
if err == docker.ErrNoSuchImage { containerStatus.State.Waiting = &api.ContainerStateWaiting{
containerStatus.State.Waiting.Reason = fmt.Sprintf("Image: %s is not ready on the node", image) Reason: fmt.Sprintf("Image: %s is ready, container is creating", image),
} else { }
containerStatus.State.Waiting.Reason = err.Error() } else if err == docker.ErrNoSuchImage {
containerStatus.State.Waiting = &api.ContainerStateWaiting{
Reason: fmt.Sprintf("Image: %s is not ready on the node", image),
} }
} else { } else {
containerStatus.State.Waiting.Reason = fmt.Sprintf("Image: %s is ready, container is creating", image) containerStatus.State.Waiting = &api.ContainerStateWaiting{
Reason: err.Error(),
} }
}
info[container.Name] = containerStatus info[container.Name] = containerStatus
} }
} }

View File

@ -771,8 +771,7 @@ func (kl *Kubelet) GetKubeletContainerLogs(podFullName, containerName, tail stri
func (kl *Kubelet) GetPodInfo(podFullName, uuid string) (api.PodInfo, error) { func (kl *Kubelet) GetPodInfo(podFullName, uuid string) (api.PodInfo, error) {
var manifest api.ContainerManifest var manifest api.ContainerManifest
for _, pod := range kl.pods { for _, pod := range kl.pods {
fullName := fmt.Sprintf("%s.%s", pod.Name, pod.Namespace) if GetPodFullName(&pod) == podFullName {
if fullName == podFullName {
manifest = pod.Manifest manifest = pod.Manifest
break break
} }

View File

@ -85,8 +85,20 @@ func TestRunOnce(t *testing.T) {
}}, }},
}, },
inspectContainersResults: []inspectContainersResult{ inspectContainersResults: []inspectContainersResult{
{label: "syncPod", container: docker.Container{State: docker.State{Running: true}}}, {
{label: "syncPod", container: docker.Container{State: docker.State{Running: true}}}, label: "syncPod",
container: docker.Container{
Config: &docker.Config{Image: "someimage"},
State: docker.State{Running: true},
},
},
{
label: "syncPod",
container: docker.Container{
Config: &docker.Config{Image: "someimage"},
State: docker.State{Running: true},
},
},
}, },
t: t, t: t,
} }