disallow bucket replication setup with site replication (#17189)

This commit is contained in:
Poorna 2023-05-11 15:48:40 -07:00 committed by GitHub
parent 3637aad36e
commit ef7177ebbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 14 deletions

View File

@ -210,6 +210,11 @@ func (a adminAPIHandlers) SetRemoteTargetHandler(w http.ResponseWriter, r *http.
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErrWithErr(ErrAdminConfigBadJSON, err), r.URL) writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErrWithErr(ErrAdminConfigBadJSON, err), r.URL)
return return
} }
if globalSiteReplicationSys.isEnabled() && !update {
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErrWithErr(ErrRemoteTargetDenyAddError, err), r.URL)
return
}
if update { if update {
// overlay the updates on existing target // overlay the updates on existing target
tgt := globalBucketTargetSys.GetRemoteBucketTargetByArn(ctx, bucket, target.Arn) tgt := globalBucketTargetSys.GetRemoteBucketTargetByArn(ctx, bucket, target.Arn)
@ -220,14 +225,14 @@ func (a adminAPIHandlers) SetRemoteTargetHandler(w http.ResponseWriter, r *http.
for _, op := range ops { for _, op := range ops {
switch op { switch op {
case madmin.CredentialsUpdateType: case madmin.CredentialsUpdateType:
if globalSiteReplicationSys.isEnabled() { if !globalSiteReplicationSys.isEnabled() {
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErrWithErr(ErrRemoteTargetDenyEditError, err), r.URL) // credentials update is possible only in bucket replication. User will never
return // know the site replicator creds.
}
tgt.Credentials = target.Credentials tgt.Credentials = target.Credentials
tgt.TargetBucket = target.TargetBucket tgt.TargetBucket = target.TargetBucket
tgt.Secure = target.Secure tgt.Secure = target.Secure
tgt.Endpoint = target.Endpoint tgt.Endpoint = target.Endpoint
}
case madmin.SyncUpdateType: case madmin.SyncUpdateType:
tgt.ReplicationSync = target.ReplicationSync tgt.ReplicationSync = target.ReplicationSync
case madmin.ProxyUpdateType: case madmin.ProxyUpdateType:

View File

@ -135,7 +135,7 @@ const (
ErrReplicationNeedsVersioningError ErrReplicationNeedsVersioningError
ErrReplicationBucketNeedsVersioningError ErrReplicationBucketNeedsVersioningError
ErrReplicationDenyEditError ErrReplicationDenyEditError
ErrRemoteTargetDenyEditError ErrRemoteTargetDenyAddError
ErrReplicationNoExistingObjects ErrReplicationNoExistingObjects
ErrObjectRestoreAlreadyInProgress ErrObjectRestoreAlreadyInProgress
ErrNoSuchKey ErrNoSuchKey
@ -934,9 +934,9 @@ var errorCodes = errorCodeMap{
Description: "No matching ExistingsObjects rule enabled", Description: "No matching ExistingsObjects rule enabled",
HTTPStatusCode: http.StatusBadRequest, HTTPStatusCode: http.StatusBadRequest,
}, },
ErrRemoteTargetDenyEditError: { ErrRemoteTargetDenyAddError: {
Code: "XMinioAdminRemoteTargetDenyEdit", Code: "XMinioAdminRemoteTargetDenyAdd",
Description: "Cannot alter remote target endpoint since this server is in a cluster replication setup. use `mc admin replicate update`", Description: "Cannot add remote target endpoint since this server is in a cluster replication setup",
HTTPStatusCode: http.StatusBadRequest, HTTPStatusCode: http.StatusBadRequest,
}, },
ErrReplicationDenyEditError: { ErrReplicationDenyEditError: {

File diff suppressed because one or more lines are too long