mirror of
https://github.com/minio/minio.git
synced 2025-01-23 12:43:16 -05:00
batch: validate versioning on src/tgt buckets (#16955)
This commit is contained in:
parent
5fa3665074
commit
699a24f7e5
@ -1116,16 +1116,18 @@ func (r *BatchJobReplicateV1) Validate(ctx context.Context, job BatchJobRequest,
|
|||||||
if r.Source.Bucket == "" {
|
if r.Source.Bucket == "" {
|
||||||
return errInvalidArgument
|
return errInvalidArgument
|
||||||
}
|
}
|
||||||
|
var isRemoteToLocal bool
|
||||||
localBkt := r.Source.Bucket
|
localBkt := r.Source.Bucket
|
||||||
if r.Source.Endpoint != "" {
|
if r.Source.Endpoint != "" {
|
||||||
localBkt = r.Target.Bucket
|
localBkt = r.Target.Bucket
|
||||||
|
isRemoteToLocal = true
|
||||||
}
|
}
|
||||||
info, err := o.GetBucketInfo(ctx, localBkt, BucketOptions{})
|
info, err := o.GetBucketInfo(ctx, localBkt, BucketOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if isErrBucketNotFound(err) {
|
if isErrBucketNotFound(err) {
|
||||||
return batchReplicationJobError{
|
return batchReplicationJobError{
|
||||||
Code: "NoSuchSourceBucket",
|
Code: "NoSuchSourceBucket",
|
||||||
Description: "The specified source bucket does not exist",
|
Description: fmt.Sprintf("The specified bucket %s does not exist", localBkt),
|
||||||
HTTPStatusCode: http.StatusNotFound,
|
HTTPStatusCode: http.StatusNotFound,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1222,8 +1224,8 @@ func (r *BatchJobReplicateV1) Validate(ctx context.Context, job BatchJobRequest,
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// If source has versioning enabled, target must have versioning enabled
|
||||||
if info.Versioning && !vcfg.Enabled() {
|
if (info.Versioning && !vcfg.Enabled() && !isRemoteToLocal) || (!info.Versioning && vcfg.Enabled() && isRemoteToLocal) {
|
||||||
return batchReplicationJobError{
|
return batchReplicationJobError{
|
||||||
Code: "InvalidBucketState",
|
Code: "InvalidBucketState",
|
||||||
Description: fmt.Sprintf("The source '%s' has versioning enabled, target '%s' must have versioning enabled",
|
Description: fmt.Sprintf("The source '%s' has versioning enabled, target '%s' must have versioning enabled",
|
||||||
|
@ -998,7 +998,7 @@ func (er erasureObjects) putObject(ctx context.Context, bucket string, object st
|
|||||||
|
|
||||||
if opts.CheckPrecondFn != nil {
|
if opts.CheckPrecondFn != nil {
|
||||||
obj, err := er.getObjectInfo(ctx, bucket, object, opts)
|
obj, err := er.getObjectInfo(ctx, bucket, object, opts)
|
||||||
if err != nil && !isErrVersionNotFound(err) {
|
if err != nil && !isErrVersionNotFound(err) && !isErrObjectNotFound(err) {
|
||||||
return objInfo, err
|
return objInfo, err
|
||||||
}
|
}
|
||||||
if opts.CheckPrecondFn(obj) {
|
if opts.CheckPrecondFn(obj) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user