From ba9551e122b6a54ad7621ffc7eb1b46d69d8ab8e Mon Sep 17 00:00:00 2001 From: Gareth Watts Date: Fri, 29 May 2020 16:26:42 +0000 Subject: [PATCH] service/s3/s3crypto Fix request retries Closing and removing the temp file after send causes retry requests to fail with an error such as: filestore: SerializationError: failed to prepare body for retry caused by: SerializationError: failed to reset request body caused by: SerializationError: failed to get next request body reader caused by: seek /tmp/213721967: file already closed I believe the Complete handler is guaranteed to be called finally after retries attempts have succeeded or been exhausted. --- service/s3/s3crypto/helper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/s3/s3crypto/helper.go b/service/s3/s3crypto/helper.go index be40fc90319..949286923a7 100644 --- a/service/s3/s3crypto/helper.go +++ b/service/s3/s3crypto/helper.go @@ -19,7 +19,7 @@ func getWriterStore(req *request.Request, path string, useTempFile bool) (io.Rea return nil, err } - req.Handlers.Send.PushBack(func(r *request.Request) { + req.Handlers.Complete.PushBack(func(r *request.Request) { // Close the temp file and cleanup f.Close() os.Remove(f.Name())