Add logging, fix crash

Crash was in kublet_server when fake docker client gives it nil pointer.
This commit is contained in:
Daniel Smith 2014-07-01 17:24:17 -07:00
parent bf3b34c2e9
commit 969586a214
3 changed files with 12 additions and 2 deletions

View File

@ -173,7 +173,7 @@ func main() {
if len(createdPods) != 7 {
glog.Fatalf("Unexpected list of created pods:\n\n%#v\n\n%#v\n\n%#v\n\n", createdPods.List(), fakeDocker1.Created, fakeDocker2.Created)
}
glog.Infof("OK")
glog.Infof("OK - found created pods: %#v", createdPods.List())
}
// Serve a file for kubelet to read.

View File

@ -801,7 +801,12 @@ func (kl *Kubelet) GetPodInfo(podID string) (api.PodInfo, error) {
if err != nil {
return nil, err
}
info[containerName] = *inspectResult
if inspectResult == nil {
// Why did we not get an error?
info[containerName] = docker.Container{}
} else {
info[containerName] = *inspectResult
}
}
return info, nil
}

View File

@ -24,6 +24,7 @@ import (
"net/url"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
"gopkg.in/v1/yaml"
)
@ -45,6 +46,10 @@ func (s *KubeletServer) error(w http.ResponseWriter, err error) {
}
func (s *KubeletServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
logger := apiserver.MakeLogged(req, w)
w = logger
defer logger.Log()
u, err := url.ParseRequestURI(req.RequestURI)
if err != nil {
s.error(w, err)