mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
double-fix crash on my cluster
This commit is contained in:
parent
88e0b04916
commit
6606f9c9f5
@ -111,7 +111,7 @@ func (c *HTTPKubeletClient) GetPodStatus(host, podNamespace, podID string) (api.
|
|||||||
status := api.PodStatusResult{}
|
status := api.PodStatusResult{}
|
||||||
query := url.Values{"podID": {podID}, "podNamespace": {podNamespace}}
|
query := url.Values{"podID": {podID}, "podNamespace": {podNamespace}}
|
||||||
response, err := c.getEntity(host, "/api/v1beta1/podInfo", query.Encode(), &status)
|
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, ErrPodInfoNotAvailable
|
||||||
}
|
}
|
||||||
return status, err
|
return status, err
|
||||||
@ -124,6 +124,7 @@ func (c *HTTPKubeletClient) GetNodeInfo(host string) (api.NodeInfo, error) {
|
|||||||
return info, err
|
return info, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getEntity might return a nil response.
|
||||||
func (c *HTTPKubeletClient) getEntity(host, path, query string, entity runtime.Object) (*http.Response, error) {
|
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)
|
request, err := http.NewRequest("GET", c.url(host, path, query), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/pod"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/pod"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
@ -264,6 +265,7 @@ func (p *PodCache) UpdateAllContainers() {
|
|||||||
pod := &pods.Items[i]
|
pod := &pods.Items[i]
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
|
defer util.HandleCrash()
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
err := p.updatePodStatus(pod)
|
err := p.updatePodStatus(pod)
|
||||||
if err != nil && err != client.ErrPodInfoNotAvailable {
|
if err != nil && err != client.ErrPodInfoNotAvailable {
|
||||||
|
Loading…
Reference in New Issue
Block a user