From fe0d1d6fae93400c650f3b751933be395748cefb Mon Sep 17 00:00:00 2001 From: xiekeyang Date: Mon, 6 Aug 2018 19:32:03 +0800 Subject: [PATCH] close response body The IO buffer Body of HTTP response should be closed when exiting the function. --- pkg/fnenv/fission/runtime.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/fnenv/fission/runtime.go b/pkg/fnenv/fission/runtime.go index e8e532ac..bc66a639 100644 --- a/pkg/fnenv/fission/runtime.go +++ b/pkg/fnenv/fission/runtime.go @@ -75,10 +75,13 @@ func (fe *FunctionEnv) Invoke(spec *types.TaskInvocationSpec) (*types.TaskInvoca fnenv.FnActive.WithLabelValues(Name).Inc() defer fnenv.FnExecTime.WithLabelValues(Name).Observe(float64(time.Since(timeStart))) ctxLog.Infof("Invoking Fission function: '%v'.", req.URL) + resp, err := http.DefaultClient.Do(req) if err != nil { return nil, fmt.Errorf("error for reqUrl '%v': %v", url, err) } + defer resp.Body.Close() + fnenv.FnActive.WithLabelValues(Name).Dec() fnenv.FnActive.WithLabelValues(Name).Inc()