From 4518d50bb5053f45fcb4888b0fddf07ad467a023 Mon Sep 17 00:00:00 2001 From: qizhicheng Date: Wed, 21 Oct 2020 17:59:50 +0800 Subject: [PATCH] retry for certain time during s3.Move Signed-off-by: Qi Zhicheng --- registry/storage/driver/s3-aws/s3.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/registry/storage/driver/s3-aws/s3.go b/registry/storage/driver/s3-aws/s3.go index e010359bb..adf5cabba 100644 --- a/registry/storage/driver/s3-aws/s3.go +++ b/registry/storage/driver/s3-aws/s3.go @@ -695,7 +695,19 @@ func (d *driver) Move(ctx context.Context, sourcePath string, destPath string) e if err := d.copy(ctx, sourcePath, destPath); err != nil { return err } - return d.Delete(ctx, sourcePath) + attempt := 30 + attemptRelay := 1000 // relay 500ms before next attempt + var err error + for i := 0; i < attempt; i++ { + err = d.Delete(ctx, sourcePath) + if err != nil { + time.Sleep(time.Duration(attemptRelay)) + continue + } else { + break + } + } + return err } // copy copies an object stored at sourcePath to destPath.