From 6606f9c9f550e9bb7d98fb6defcd5e974eb716e0 Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Wed, 11 Mar 2015 09:48:01 -0700 Subject: [PATCH] double-fix crash on my cluster --- pkg/client/kubelet.go | 3 ++- pkg/master/pod_cache.go | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/client/kubelet.go b/pkg/client/kubelet.go index ec3d0efd462..16f433cf223 100644 --- a/pkg/client/kubelet.go +++ b/pkg/client/kubelet.go @@ -111,7 +111,7 @@ func (c *HTTPKubeletClient) GetPodStatus(host, podNamespace, podID string) (api. status := api.PodStatusResult{} query := url.Values{"podID": {podID}, "podNamespace": {podNamespace}} response, err := c.getEntity(host, "/api/v1beta1/podInfo", query.Encode(), &status) - if response.StatusCode == http.StatusNotFound { + if response != nil && response.StatusCode == http.StatusNotFound { return status, ErrPodInfoNotAvailable } return status, err @@ -124,6 +124,7 @@ func (c *HTTPKubeletClient) GetNodeInfo(host string) (api.NodeInfo, error) { return info, err } +// getEntity might return a nil response. func (c *HTTPKubeletClient) getEntity(host, path, query string, entity runtime.Object) (*http.Response, error) { request, err := http.NewRequest("GET", c.url(host, path, query), nil) if err != nil { diff --git a/pkg/master/pod_cache.go b/pkg/master/pod_cache.go index b835bb12099..a146e0ddf78 100644 --- a/pkg/master/pod_cache.go +++ b/pkg/master/pod_cache.go @@ -23,6 +23,7 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/registry/pod" + "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/golang/glog" ) @@ -264,6 +265,7 @@ func (p *PodCache) UpdateAllContainers() { pod := &pods.Items[i] wg.Add(1) go func() { + defer util.HandleCrash() defer wg.Done() err := p.updatePodStatus(pod) if err != nil && err != client.ErrPodInfoNotAvailable {