Avoid extra GetObjectInfo call in DeleteObject API (#17599)
Optimize DeleteObject API to avoid extra GetObjectInfo call on the replicating side. For receiving side, it is just a regular DeleteObject call. Bonus: Fix a corner case where version purged is absent on target (either due to replication not yet complete or target version already deleted in a one-way replication or when replication was disabled). In such cases, mark version purge complete.
This commit is contained in:
@@ -35,8 +35,11 @@ import (
|
||||
// CheckPreconditionFn returns true if precondition check failed.
|
||||
type CheckPreconditionFn func(o ObjectInfo) bool
|
||||
|
||||
// EvalMetadataFn validates input objInfo and returns an updated metadata
|
||||
type EvalMetadataFn func(o *ObjectInfo) error
|
||||
// EvalMetadataFn validates input objInfo and GetObjectInfo error and returns an updated metadata and replication decision if any
|
||||
type EvalMetadataFn func(o *ObjectInfo, gerr error) (ReplicateDecision, error)
|
||||
|
||||
// EvalRetentionBypassFn validates input objInfo and GetObjectInfo error and returns an error if retention bypass is not allowed.
|
||||
type EvalRetentionBypassFn func(o ObjectInfo, gerr error) error
|
||||
|
||||
// GetObjectInfoFn is the signature of GetObjectInfo function.
|
||||
type GetObjectInfoFn func(ctx context.Context, bucket, object string, opts ObjectOptions) (ObjectInfo, error)
|
||||
@@ -100,7 +103,8 @@ type ObjectOptions struct {
|
||||
|
||||
InclFreeVersions bool
|
||||
|
||||
MetadataChg bool // is true if it is a metadata update operation.
|
||||
MetadataChg bool // is true if it is a metadata update operation.
|
||||
EvalRetentionBypassFn EvalRetentionBypassFn // only set for enforcing retention bypass on DeleteObject.
|
||||
}
|
||||
|
||||
// ExpirationOptions represents object options for object expiration at objectLayer.
|
||||
@@ -182,6 +186,16 @@ func (o *ObjectOptions) PutReplicationState() (r ReplicationState) {
|
||||
return
|
||||
}
|
||||
|
||||
// SetEvalMetadataFn sets the metadata evaluation function
|
||||
func (o *ObjectOptions) SetEvalMetadataFn(f EvalMetadataFn) {
|
||||
o.EvalMetadataFn = f
|
||||
}
|
||||
|
||||
// SetEvalRetentionBypassFn sets the retention bypass function
|
||||
func (o *ObjectOptions) SetEvalRetentionBypassFn(f EvalRetentionBypassFn) {
|
||||
o.EvalRetentionBypassFn = f
|
||||
}
|
||||
|
||||
// ObjectLayer implements primitives for object API layer.
|
||||
type ObjectLayer interface {
|
||||
// Locking operations on object.
|
||||
|
||||
Reference in New Issue
Block a user