From ed47bc15968a80d4d91980cd8a2804e8ece0b478 Mon Sep 17 00:00:00 2001 From: Angira Kekteeva Date: Mon, 4 Apr 2022 15:38:27 +0400 Subject: [PATCH] Fixed deletes for failed tests test_multi_object_delete test_multi_objectv2_delete Signed-off-by: Angira Kekteeva --- api/handler/delete.go | 33 ++++++++++++++++----------------- api/layer/layer.go | 1 - 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/api/handler/delete.go b/api/handler/delete.go index ac75c1fc..683e6be1 100644 --- a/api/handler/delete.go +++ b/api/handler/delete.go @@ -213,19 +213,7 @@ func (h *handler) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *http.Re var errs []error for _, obj := range deletedObjects { - if obj.Error == nil { - deletedObj := DeletedObject{ - ObjectIdentifier: ObjectIdentifier{ - ObjectName: obj.Name, - VersionID: obj.VersionID, - }, - DeleteMarkerVersionID: obj.DeleteMarkVersion, - } - if deletedObj.DeleteMarkerVersionID != "" { - deletedObj.DeleteMarker = true - } - response.DeletedObjects = append(response.DeletedObjects, deletedObj) - } else if !requested.Quiet { + if obj.Error != nil { code := "BadRequest" if s3err, ok := obj.Error.(errors.Error); ok { code = s3err.Code @@ -237,15 +225,26 @@ func (h *handler) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *http.Re VersionID: obj.VersionID, }) errs = append(errs, obj.Error) + } else if !requested.Quiet { + deletedObj := DeletedObject{ + ObjectIdentifier: ObjectIdentifier{ + ObjectName: obj.Name, + VersionID: obj.VersionID, + }, + DeleteMarkerVersionID: obj.DeleteMarkVersion, + } + if deletedObj.DeleteMarkerVersionID != "" { + deletedObj.DeleteMarker = true + } + response.DeletedObjects = append(response.DeletedObjects, deletedObj) } } - - if !requested.Quiet && len(errs) != 0 { - additional := []zap.Field{ + if len(errs) != 0 { + fields := []zap.Field{ zap.Array("objects", marshaler), zap.Errors("errors", errs), } - h.logAndSendError(w, "could not delete objects", reqInfo, nil, additional...) + h.log.Error("couldn't delete objects", fields...) } if err := api.EncodeToResponse(w, response); err != nil { diff --git a/api/layer/layer.go b/api/layer/layer.go index f3b30740..0a1be3a4 100644 --- a/api/layer/layer.go +++ b/api/layer/layer.go @@ -568,7 +568,6 @@ func (n *layer) deleteObject(ctx context.Context, bkt *data.BucketInfo, settings } last := versions.getLast(FromUnversioned()) if last == nil { - obj.Error = errors.GetAPIError(errors.ErrInvalidVersion) return obj } p.Header[VersionsDeleteMarkAttr] = last.Version()