Don't check object tagging on deletion #411

Merged
alexvanin merged 2 commits from dkirillov/frostfs-s3-gw:bugfix/delete-object_response into master 2024-09-04 19:51:13 +00:00
3 changed files with 24 additions and 4 deletions

View file

@ -150,15 +150,18 @@ func (h *handler) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *http.Re
return return
} }
removed := make(map[string]*layer.VersionedObject) unique := make(map[string]struct{})
toRemove := make([]*layer.VersionedObject, 0, len(requested.Objects)) toRemove := make([]*layer.VersionedObject, 0, len(requested.Objects))
for _, obj := range requested.Objects { for _, obj := range requested.Objects {
versionedObj := &layer.VersionedObject{ versionedObj := &layer.VersionedObject{
Name: obj.ObjectName, Name: obj.ObjectName,
VersionID: obj.VersionID, VersionID: obj.VersionID,
} }
toRemove = append(toRemove, versionedObj) key := versionedObj.String()
removed[versionedObj.String()] = versionedObj if _, ok := unique[key]; !ok {
toRemove = append(toRemove, versionedObj)
unique[key] = struct{}{}
}
} }
response := &DeleteObjectsResponse{ response := &DeleteObjectsResponse{

View file

@ -85,6 +85,19 @@ func TestDeleteBucketOnNotFoundError(t *testing.T) {
deleteBucket(t, hc, bktName, http.StatusNoContent) deleteBucket(t, hc, bktName, http.StatusNoContent)
} }
func TestDeleteMultipleObjectCheckUniqueness(t *testing.T) {
hc := prepareHandlerContext(t)
bktName, objName := "bucket", "object"
createTestBucket(hc, bktName)
putObject(hc, bktName, objName)
resp := deleteObjects(t, hc, bktName, [][2]string{{objName, emptyVersion}, {objName, emptyVersion}})
require.Empty(t, resp.Errors)
require.Len(t, resp.DeletedObjects, 1)
}
func TestDeleteObjectsError(t *testing.T) { func TestDeleteObjectsError(t *testing.T) {
hc := prepareHandlerContext(t) hc := prepareHandlerContext(t)

View file

@ -32,7 +32,9 @@ const (
amzTagging = "x-amz-tagging" amzTagging = "x-amz-tagging"
) )
// At the beginning of these operations resources haven't yet been created. // In these operations we don't check resource tags because
// * they haven't been created yet
// * resource tags shouldn't be checked by AWS spec.
var withoutResourceOps = []string{ var withoutResourceOps = []string{
CreateBucketOperation, CreateBucketOperation,
CreateMultipartUploadOperation, CreateMultipartUploadOperation,
@ -43,6 +45,8 @@ var withoutResourceOps = []string{
ListPartsOperation, ListPartsOperation,
PutObjectOperation, PutObjectOperation,
CopyObjectOperation, CopyObjectOperation,
DeleteObjectOperation,
DeleteMultipleObjectsOperation,
} }
type PolicySettings interface { type PolicySettings interface {