diff --git a/api/handler/delete.go b/api/handler/delete.go index 326b7ad5..8b51e78b 100644 --- a/api/handler/delete.go +++ b/api/handler/delete.go @@ -16,7 +16,6 @@ import ( oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/session" "go.uber.org/zap" - "go.uber.org/zap/zapcore" ) // limitation of AWS https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html @@ -216,21 +215,14 @@ func (h *handler) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *http.Re return } - marshaler := zapcore.ArrayMarshalerFunc(func(encoder zapcore.ArrayEncoder) error { - for _, obj := range toRemove { - encoder.AppendString(obj.String()) - } - return nil - }) - p := &layer.DeleteObjectParams{ - BktInfo: bktInfo, - Objects: toRemove, - Settings: bktSettings, + BktInfo: bktInfo, + Objects: toRemove, + Settings: bktSettings, + IsMultiple: true, } deletedObjects := h.obj.DeleteObjects(ctx, p) - var errs []error for _, obj := range deletedObjects { if obj.Error != nil { code := "BadRequest" @@ -243,7 +235,6 @@ func (h *handler) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *http.Re Key: obj.Name, VersionID: obj.VersionID, }) - errs = append(errs, obj.Error) } else if !requested.Quiet { deletedObj := DeletedObject{ ObjectIdentifier: ObjectIdentifier{ @@ -258,16 +249,9 @@ func (h *handler) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *http.Re response.DeletedObjects = append(response.DeletedObjects, deletedObj) } } - if len(errs) != 0 { - fields := []zap.Field{ - zap.Array("objects", marshaler), - zap.Errors("errors", errs), - } - h.reqLogger(ctx).Error(logs.CouldntDeleteObjects, fields...) - } if err = middleware.EncodeToResponse(w, response); err != nil { - h.logAndSendError(w, "could not write response", reqInfo, err, zap.Array("objects", marshaler)) + h.logAndSendError(w, "could not write response", reqInfo, err) return } } diff --git a/api/layer/layer.go b/api/layer/layer.go index 205ff8ee..2b986276 100644 --- a/api/layer/layer.go +++ b/api/layer/layer.go @@ -136,9 +136,10 @@ type ( } DeleteObjectParams struct { - BktInfo *data.BucketInfo - Objects []*VersionedObject - Settings *data.BucketSettings + BktInfo *data.BucketInfo + Objects []*VersionedObject + Settings *data.BucketSettings + IsMultiple bool } // PutSettingsParams stores object copy request parameters. @@ -764,6 +765,9 @@ func (n *layer) removeOldVersion(ctx context.Context, bkt *data.BucketInfo, node func (n *layer) DeleteObjects(ctx context.Context, p *DeleteObjectParams) []*VersionedObject { for i, obj := range p.Objects { p.Objects[i] = n.deleteObject(ctx, p.BktInfo, p.Settings, obj) + if p.IsMultiple && p.Objects[i].Error != nil { + n.reqLogger(ctx).Error(logs.CouldntDeleteObject, zap.String("object", obj.String()), zap.Error(p.Objects[i].Error)) + } } return p.Objects diff --git a/internal/logs/logs.go b/internal/logs/logs.go index b542963a..42b9cda7 100644 --- a/internal/logs/logs.go +++ b/internal/logs/logs.go @@ -64,7 +64,7 @@ const ( GetBucketInfo = "get bucket info" // Warn in ../../api/handler/cors.go GetBucketCors = "get bucket cors" // Warn in ../../api/handler/cors.go SomeACLNotFullyMapped = "some acl not fully mapped" // Warn in ../../api/handler/acl.go - CouldntDeleteObjects = "couldn't delete objects" // Error in ../../api/handler/delete.go + CouldntDeleteObject = "couldn't delete object" // Error in ../../api/layer/layer.go NotificatorIsDisabledS3WontProduceNotificationEvents = "notificator is disabled, s3 won't produce notification events" // Warn in ../../api/handler/api.go CouldntGetBucketVersioning = "couldn't get bucket versioning" // Warn in ../../api/handler/put.go BucketIsCreated = "bucket is created" // Info in ../../api/handler/put.go