mirror of
https://github.com/openfaas/faas.git
synced 2025-06-24 15:53:26 +00:00
Fix a bug that caused the services list to keep growing
This patch changes the code which looks up service and appends them to the Exporter's list. It previously would create an endless list and cause a memory leak. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
committed by
Alex Ellis
parent
7de17fdf9d
commit
9bbb25e3c7
@ -92,8 +92,11 @@ func (e *Exporter) StartServiceWatcher(endpointURL url.URL, metricsOptions Metri
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
services := []types.FunctionStatus{}
|
||||
|
||||
// Providers like Docker Swarm for instance have no namespaces.
|
||||
if len(namespaces) == 0 {
|
||||
services, err := e.getFunctions(endpointURL, e.FunctionNamespace)
|
||||
services, err = e.getFunctions(endpointURL, e.FunctionNamespace)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
continue
|
||||
@ -101,15 +104,17 @@ func (e *Exporter) StartServiceWatcher(endpointURL url.URL, metricsOptions Metri
|
||||
e.services = services
|
||||
} else {
|
||||
for _, namespace := range namespaces {
|
||||
services, err := e.getFunctions(endpointURL, namespace)
|
||||
nsServices, err := e.getFunctions(endpointURL, namespace)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
continue
|
||||
}
|
||||
e.services = append(e.services, services...)
|
||||
services = append(services, nsServices...)
|
||||
}
|
||||
}
|
||||
|
||||
e.services = services
|
||||
|
||||
break
|
||||
case <-quit:
|
||||
return
|
||||
|
Reference in New Issue
Block a user