Browse Source

Merge pull request #1072 from fabric8io/kubernetes-discovery

Clean up kubernetes http response bodies
pull/1076/head
Julius Volz 9 years ago
parent
commit
e7c1db42f3
  1. 6
      retrieval/discovery/kubernetes/discovery.go

6
retrieval/discovery/kubernetes/discovery.go

@ -115,6 +115,7 @@ func (kd *Discovery) Sources() []string {
log.Errorf("Unable to list Kubernetes nodes: %s", err) log.Errorf("Unable to list Kubernetes nodes: %s", err)
return []string{} return []string{}
} }
defer res.Body.Close()
if res.StatusCode != http.StatusOK { if res.StatusCode != http.StatusOK {
log.Errorf("Unable to list Kubernetes nodes. Unexpected response: %d %s", res.StatusCode, res.Status) log.Errorf("Unable to list Kubernetes nodes. Unexpected response: %d %s", res.StatusCode, res.Status)
return []string{} return []string{}
@ -143,6 +144,7 @@ func (kd *Discovery) Sources() []string {
log.Errorf("Unable to list Kubernetes services: %s", err) log.Errorf("Unable to list Kubernetes services: %s", err)
return []string{} return []string{}
} }
defer res.Body.Close()
if res.StatusCode != http.StatusOK { if res.StatusCode != http.StatusOK {
log.Errorf("Unable to list Kubernetes services. Unexpected response: %d %s", res.StatusCode, res.Status) log.Errorf("Unable to list Kubernetes services. Unexpected response: %d %s", res.StatusCode, res.Status)
return []string{} return []string{}
@ -351,6 +353,7 @@ func (kd *Discovery) watchNodes(events chan interface{}, done <-chan struct{}, r
log.Errorf("Failed to watch nodes: %s", err) log.Errorf("Failed to watch nodes: %s", err)
return return
} }
defer res.Body.Close()
if res.StatusCode != http.StatusOK { if res.StatusCode != http.StatusOK {
log.Errorf("Failed to watch nodes: %d", res.StatusCode) log.Errorf("Failed to watch nodes: %d", res.StatusCode)
return return
@ -392,6 +395,7 @@ func (kd *Discovery) watchServices(events chan interface{}, done <-chan struct{}
log.Errorf("Failed to watch services: %s", err) log.Errorf("Failed to watch services: %s", err)
return return
} }
defer res.Body.Close()
if res.StatusCode != http.StatusOK { if res.StatusCode != http.StatusOK {
log.Errorf("Failed to watch services: %d", res.StatusCode) log.Errorf("Failed to watch services: %d", res.StatusCode)
return return
@ -462,6 +466,7 @@ func (kd *Discovery) addService(service *Service) *config.TargetGroup {
log.Errorf("Error getting service endpoints: %s", err) log.Errorf("Error getting service endpoints: %s", err)
return nil return nil
} }
defer res.Body.Close()
if res.StatusCode != http.StatusOK { if res.StatusCode != http.StatusOK {
log.Errorf("Failed to get service endpoints: %d", res.StatusCode) log.Errorf("Failed to get service endpoints: %d", res.StatusCode)
return nil return nil
@ -534,6 +539,7 @@ func (kd *Discovery) watchServiceEndpoints(events chan interface{}, done <-chan
log.Errorf("Failed to watch service endpoints: %s", err) log.Errorf("Failed to watch service endpoints: %s", err)
return return
} }
defer res.Body.Close()
if res.StatusCode != http.StatusOK { if res.StatusCode != http.StatusOK {
log.Errorf("Failed to watch service endpoints: %d", res.StatusCode) log.Errorf("Failed to watch service endpoints: %d", res.StatusCode)
return return

Loading…
Cancel
Save