From 17a5ff51ff49a719507439c29966fc1cd737aed3 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 13 Nov 2020 16:56:45 -0800 Subject: [PATCH] fix: move context timeout closer to network for Delete calls (#10897) allowing for disconnects to be limited to the drive themselves instead of disconnecting all drives. --- cmd/erasure-object.go | 9 +-------- cmd/object-api-common.go | 7 +++++++ cmd/storage-rest-client.go | 9 +++++++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/cmd/erasure-object.go b/cmd/erasure-object.go index 628c10caa..a3776c4a5 100644 --- a/cmd/erasure-object.go +++ b/cmd/erasure-object.go @@ -24,7 +24,6 @@ import ( "net/http" "path" "sync" - "time" "github.com/minio/minio-go/v7/pkg/tags" xhttp "github.com/minio/minio/cmd/http" @@ -774,13 +773,7 @@ func (er erasureObjects) deleteObject(ctx context.Context, bucket, object string if disks[index] == nil { return errDiskNotFound } - tctx, cancel := context.WithTimeout(ctx, 5*time.Second) - defer cancel() - err := cleanupDir(tctx, disks[index], minioMetaTmpBucket, tmpObj) - if err != nil && err != errVolumeNotFound { - return err - } - return nil + return cleanupDir(ctx, disks[index], minioMetaTmpBucket, tmpObj) }, index) } diff --git a/cmd/object-api-common.go b/cmd/object-api-common.go index a88b0f957..e278ad3dc 100644 --- a/cmd/object-api-common.go +++ b/cmd/object-api-common.go @@ -137,7 +137,14 @@ func cleanupDir(ctx context.Context, storage StorageAPI, volume, dirPath string) } return nil } + err := delFunc(retainSlash(pathJoin(dirPath))) + if IsErrIgnored(err, []error{ + errVolumeNotFound, + errVolumeAccessDenied, + }...) { + return nil + } return err } diff --git a/cmd/storage-rest-client.go b/cmd/storage-rest-client.go index fad6d5c20..f8cfa6a54 100644 --- a/cmd/storage-rest-client.go +++ b/cmd/storage-rest-client.go @@ -323,7 +323,10 @@ func (client *storageRESTClient) DeleteVersion(ctx context.Context, volume, path return err } - respBody, err := client.call(ctx, storageRESTMethodDeleteVersion, values, &buffer, -1) + tctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + respBody, err := client.call(tctx, storageRESTMethodDeleteVersion, values, &buffer, -1) defer http.DrainBody(respBody) return err } @@ -503,7 +506,9 @@ func (client *storageRESTClient) Delete(ctx context.Context, volume string, path values.Set(storageRESTVolume, volume) values.Set(storageRESTFilePath, path) values.Set(storageRESTRecursive, strconv.FormatBool(recursive)) - respBody, err := client.call(ctx, storageRESTMethodDeleteFile, values, nil, -1) + tctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + respBody, err := client.call(tctx, storageRESTMethodDeleteFile, values, nil, -1) defer http.DrainBody(respBody) return err }