From 57c0e4b830608e4864466a20e60faf32645c1fe2 Mon Sep 17 00:00:00 2001 From: Jimmi Dyson Date: Fri, 9 Oct 2015 13:36:00 +0100 Subject: [PATCH] Fix raw container stats retrieval from kubelet over https --- sources/datasource/kubelet.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sources/datasource/kubelet.go b/sources/datasource/kubelet.go index 08c8c5a833..49fa39d158 100644 --- a/sources/datasource/kubelet.go +++ b/sources/datasource/kubelet.go @@ -101,14 +101,12 @@ func (self *kubeletSource) getContainer(url string, start, end time.Time) (*api. } func (self *kubeletSource) GetContainer(host Host, start, end time.Time) (container *api.Container, err error) { - var schema string + scheme := "http" if self.config != nil && self.config.EnableHttps { - schema = "https" - } else { - schema = "http" + scheme = "https" } - url := fmt.Sprintf("%s://%s:%d/%s", schema, host.IP, host.Port, host.Resource) + url := fmt.Sprintf("%s://%s:%d/%s", scheme, host.IP, host.Port, host.Resource) glog.V(3).Infof("about to query kubelet using url: %q", url) return self.getContainer(url, start, end) @@ -140,7 +138,12 @@ type statsRequest struct { // Get stats for all non-Kubernetes containers. func (self *kubeletSource) GetAllRawContainers(host Host, start, end time.Time) ([]api.Container, error) { - url := fmt.Sprintf("http://%s:%d/stats/container/", host.IP, host.Port) + scheme := "http" + if self.config != nil && self.config.EnableHttps { + scheme = "https" + } + + url := fmt.Sprintf("%s://%s:%d/stats/container/", scheme, host.IP, host.Port) return self.getAllContainers(url, start, end) }