diff --git a/api/admin_remote_buckets.go b/api/admin_remote_buckets.go index d0fba7306..f05ec7368 100644 --- a/api/admin_remote_buckets.go +++ b/api/admin_remote_buckets.go @@ -292,7 +292,7 @@ func addRemoteBucket(ctx context.Context, client MinioAdmin, params models.Creat return bucketARN, err } -func addBucketReplicationItem(ctx context.Context, session *models.Principal, minClient minioClient, bucketName, prefix, destinationARN string, repDelMark, repDels, repMeta bool, tags string, priority int32, storageClass string) error { +func addBucketReplicationItem(ctx context.Context, session *models.Principal, minClient minioClient, bucketName, prefix, destinationARN string, repExistingObj, repDelMark, repDels, repMeta bool, tags string, priority int32, storageClass string) error { // we will tolerate this call failing cfg, err := minClient.getBucketReplication(ctx, bucketName) if err != nil { @@ -337,13 +337,18 @@ func addBucketReplicationItem(ctx context.Context, session *models.Principal, mi repMetaStatus = "enable" } + existingRepStatus := "disable" + if repExistingObj { + existingRepStatus = "enable" + } + opts := replication.Options{ Priority: fmt.Sprintf("%d", maxPrio), RuleStatus: "enable", DestBucket: destinationARN, Op: replication.AddOption, TagString: tags, - ExistingObjectReplicate: "enable", // enabled by default + ExistingObjectReplicate: existingRepStatus, ReplicateDeleteMarkers: repDelMarkStatus, ReplicateDeletes: repDelsStatus, ReplicaSync: repMetaStatus, @@ -459,6 +464,7 @@ func setMultiBucketReplication(ctx context.Context, session *models.Principal, c sourceBucket, params.Body.Prefix, arn, + params.Body.ReplicateExistingObjects, params.Body.ReplicateDeleteMarkers, params.Body.ReplicateDeletes, params.Body.ReplicateMetadata, diff --git a/api/embedded_spec.go b/api/embedded_spec.go index 245a943ca..0f74a1ecf 100644 --- a/api/embedded_spec.go +++ b/api/embedded_spec.go @@ -7230,6 +7230,9 @@ func init() { "replicateDeletes": { "type": "boolean" }, + "replicateExistingObjects": { + "type": "boolean" + }, "replicateMetadata": { "type": "boolean" }, @@ -16636,6 +16639,9 @@ func init() { "replicateDeletes": { "type": "boolean" }, + "replicateExistingObjects": { + "type": "boolean" + }, "replicateMetadata": { "type": "boolean" }, diff --git a/models/multi_bucket_replication.go b/models/multi_bucket_replication.go index 2b39153d0..728e66b61 100644 --- a/models/multi_bucket_replication.go +++ b/models/multi_bucket_replication.go @@ -68,6 +68,9 @@ type MultiBucketReplication struct { // replicate deletes ReplicateDeletes bool `json:"replicateDeletes,omitempty"` + // replicate existing objects + ReplicateExistingObjects bool `json:"replicateExistingObjects,omitempty"` + // replicate metadata ReplicateMetadata bool `json:"replicateMetadata,omitempty"` diff --git a/swagger.yml b/swagger.yml index f217a1e26..11182ef53 100644 --- a/swagger.yml +++ b/swagger.yml @@ -4222,6 +4222,8 @@ definitions: type: string tags: type: string + replicateExistingObjects: + type: boolean replicateDeleteMarkers: type: boolean replicateDeletes: diff --git a/web-app/src/api/consoleApi.ts b/web-app/src/api/consoleApi.ts index b1f705e6f..49f733874 100644 --- a/web-app/src/api/consoleApi.ts +++ b/web-app/src/api/consoleApi.ts @@ -385,6 +385,7 @@ export interface MultiBucketReplication { healthCheckPeriod?: number; prefix?: string; tags?: string; + replicateExistingObjects?: boolean; replicateDeleteMarkers?: boolean; replicateDeletes?: boolean; replicateMetadata?: boolean; diff --git a/web-app/src/screens/Console/Buckets/BucketDetails/AddBucketReplication.tsx b/web-app/src/screens/Console/Buckets/BucketDetails/AddBucketReplication.tsx index 4753ba5de..12ca08541 100644 --- a/web-app/src/screens/Console/Buckets/BucketDetails/AddBucketReplication.tsx +++ b/web-app/src/screens/Console/Buckets/BucketDetails/AddBucketReplication.tsx @@ -60,7 +60,7 @@ const AddBucketReplication = () => { const [repDeleteMarker, setRepDeleteMarker] = useState(true); const [repDelete, setRepDelete] = useState(true); const [metadataSync, setMetadataSync] = useState(true); - const [repExisting, setRepExisting] = useState(false); + const [repExisting, setRepExisting] = useState(true); const [tags, setTags] = useState(""); const [replicationMode, setReplicationMode] = useState<"async" | "sync">( "async", @@ -124,8 +124,8 @@ const AddBucketReplication = () => { if (itemVal.errorString && itemVal.errorString !== "") { dispatch( setErrorSnackMessage({ - errorMessage: itemVal.errorString, - detailedError: "There was an error", + errorMessage: "There was an error", + detailedError: itemVal.errorString, }), ); // navigate(backLink); @@ -201,11 +201,10 @@ const AddBucketReplication = () => { MinIO supports automatically replicating existing objects in - a bucket, however it does not enable existing object - replication by default. Objects created before replication - was configured or while replication is disabled are not - synchronized to the target deployment unless replication of - existing objects is enabled. + a bucket; this setting is enabled by default. Please note + that objects created before replication was configured or + while replication is disabled are not synchronized to the + target deployment in case this setting is not enabled. MinIO supports replicating delete operations, where MinIO