From eb6e6d5582460cb16f00bf3a44ea761bb88fb75b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Wed, 4 Jul 2018 12:46:14 -0500 Subject: [PATCH] backup-operator: close s3 reader after saving snapshot After uploading the snapshot, the backup operator performs a get to ensure that the snapshot was actually saved. The problem is that the resulting get request body is not closed. This causes a leak of http connections. fixes #1965 --- pkg/backup/writer/s3_writer.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/backup/writer/s3_writer.go b/pkg/backup/writer/s3_writer.go index 69494d4b4..9ffe37f42 100644 --- a/pkg/backup/writer/s3_writer.go +++ b/pkg/backup/writer/s3_writer.go @@ -59,6 +59,9 @@ func (s3w *s3Writer) Write(ctx context.Context, path string, r io.Reader) (int64 if err != nil { return 0, err } + if resp.Body != nil { + defer resp.Body.Close() + } if resp.ContentLength == nil { return 0, fmt.Errorf("failed to compute s3 object size") }