aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarren Hodgkinson <warren.hodgkinson@gmail.com>2024-12-20 02:00:08 +0000
committerGitHub <noreply@github.com>2024-12-19 18:00:08 -0800
commita1a76ccb8c3316baf269aa856ba268d53e0943ba (patch)
treeabd421b59554b7babe5e574bc03f76f078ecd217
parent4d91ec359b3a04bce43c422e8ed1bdc397398d20 (diff)
downloadseaweedfs-a1a76ccb8c3316baf269aa856ba268d53e0943ba.tar.xz
seaweedfs-a1a76ccb8c3316baf269aa856ba268d53e0943ba.zip
Fix for DeleteMultipleObjectsHandler wrongly deleting parent folders (#6380)
What problem are we solving? Fix: #6379 How are we solving the problem? We check for the AllowEmptyFolders option prior to cascade deleting parent folders in S3 DeleteMultipleObjectsHandler. How is the PR tested? We ran SeaweedFS in a Kubernetes Cluster with a joint Filer and S3 server in one container, with leveldb2 as the filer storage, and AllowEmptyFolders set to true. When using the Distribution Registry as the S3 client, it calls the DeleteMultipleObjectsHandler as part of the artifact upload process (uploads to a temp location, then performs a copy and delete). Without this fix, the deletion cascade deleted parent folder until the entire contents of the bucket were gone. With this fix, the existing content of the bucket remained, and the newly uploaded content was added. Checks [ ] I have added unit tests if possible. [ ] I will add related wiki document changes and link to this PR after merging. Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
-rw-r--r--weed/s3api/s3api_object_handlers_delete.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/weed/s3api/s3api_object_handlers_delete.go b/weed/s3api/s3api_object_handlers_delete.go
index 7656b9d38..506e7609b 100644
--- a/weed/s3api/s3api_object_handlers_delete.go
+++ b/weed/s3api/s3api_object_handlers_delete.go
@@ -3,12 +3,13 @@ package s3api
import (
"encoding/xml"
"fmt"
- "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants"
- "golang.org/x/exp/slices"
"io"
"net/http"
"strings"
+ "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants"
+ "golang.org/x/exp/slices"
+
"github.com/seaweedfs/seaweedfs/weed/filer"
"github.com/seaweedfs/seaweedfs/weed/s3api/s3err"
@@ -157,6 +158,10 @@ func (s3a *S3ApiServer) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *h
}
}
+ if s3a.option.AllowEmptyFolder {
+ return nil
+ }
+
// purge empty folders, only checking folders with deletions
for len(directoriesWithDeletion) > 0 {
directoriesWithDeletion = s3a.doDeleteEmptyDirectories(client, directoriesWithDeletion)