Add flag for replica sync to mc replicate command (#3722)
Signed-off-by: Poorna Krishnamoorthy <poorna@minio.io>
This commit is contained in:
@@ -62,7 +62,7 @@ var replicateAddFlags = []cli.Flag{
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "replicate",
|
||||
Usage: "comma separated list to enable replication of delete markers, and/or deletion of versioned objects.Valid options are \"delete-marker\", \"delete\" and \"\"",
|
||||
Usage: "comma separated list to enable replication of delete markers, deletion of versioned objects and replica metadata sync(in the case of active-active replication).Valid options are \"delete-marker\", \"delete\" ,\"replica-metadata-sync\" and \"\"",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -162,6 +162,7 @@ func mainReplicateAdd(cliCtx *cli.Context) error {
|
||||
}
|
||||
dmReplicateStatus := disableStatus
|
||||
deleteReplicationStatus := disableStatus
|
||||
replicaSync := enableStatus
|
||||
if cliCtx.IsSet("replicate") {
|
||||
replSlice := strings.Split(cliCtx.String("replicate"), ",")
|
||||
for _, opt := range replSlice {
|
||||
@@ -170,12 +171,13 @@ func mainReplicateAdd(cliCtx *cli.Context) error {
|
||||
dmReplicateStatus = enableStatus
|
||||
case "delete":
|
||||
deleteReplicationStatus = enableStatus
|
||||
case "replica-metadata-sync":
|
||||
replicaSync = enableStatus
|
||||
default:
|
||||
fatalIf(probe.NewError(fmt.Errorf("invalid value for --replicate flag %s", cliCtx.String("replicate"))), "--replicate flag takes one or more comma separated string with values \"delete, delete-marker\" or \"\" to disable delete marker replication")
|
||||
fatalIf(probe.NewError(fmt.Errorf("invalid value for --replicate flag %s", cliCtx.String("replicate"))), "--replicate flag takes one or more comma separated string with values \"delete, delete-marker, replica-metadata-sync\" or \"\" to disable these settings")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
opts := replication.Options{
|
||||
TagString: cliCtx.String("tags"),
|
||||
RoleArn: cliCtx.String("arn"),
|
||||
@@ -187,6 +189,7 @@ func mainReplicateAdd(cliCtx *cli.Context) error {
|
||||
Op: replication.AddOption,
|
||||
ReplicateDeleteMarkers: dmReplicateStatus,
|
||||
ReplicateDeletes: deleteReplicationStatus,
|
||||
ReplicaSync: replicaSync,
|
||||
}
|
||||
fatalIf(client.SetReplication(ctx, &rcfg, opts), "Could not add replication rule")
|
||||
printMsg(replicateAddMessage{
|
||||
|
||||
+12
-3
@@ -58,7 +58,7 @@ var replicateEditFlags = []cli.Flag{
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "replicate",
|
||||
Usage: "comma separated list to enable replication of delete markers, and/or deletion of versioned objects.Valid options are \"delete-marker\", \"delete\" and \"\"",
|
||||
Usage: "comma separated list to enable replication of delete markers, deletion of versioned objects and syncing replica metadata modifications.Valid options are \"delete-marker\", \"delete\",\"replica-metadata-sync\" and \"\"",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -97,6 +97,8 @@ EXAMPLES:
|
||||
6. Disable delete marker and versioned delete replication on a replication configuration rule with ID "kxYD.491" on a target myminio/bucket.
|
||||
{{.Prompt}} {{.HelpName}} myminio/mybucket --id "kxYD.491" --replicate ""
|
||||
|
||||
7. Enable replica metadata sync ,delete marker and versioned delete replication on a replication configuration rule with ID "kxYD.491" on a target myminio/bucket.
|
||||
{{.Prompt}} {{.HelpName}} myminio/mybucket --id "kxYD.491" --replicate "delete,delete-marker,replica-metadata-sync"
|
||||
`,
|
||||
}
|
||||
|
||||
@@ -155,24 +157,29 @@ func mainReplicateEdit(cliCtx *cli.Context) error {
|
||||
fatalIf(err.Trace(args...), "--state can be either `enable` or `disable`")
|
||||
}
|
||||
}
|
||||
var vDeleteReplicate, dmReplicate string
|
||||
var vDeleteReplicate, dmReplicate, replicasync string
|
||||
if cliCtx.IsSet("replicate") {
|
||||
replSlice := strings.Split(cliCtx.String("replicate"), ",")
|
||||
vDeleteReplicate = disableStatus
|
||||
dmReplicate = disableStatus
|
||||
replicasync = disableStatus
|
||||
for _, opt := range replSlice {
|
||||
switch strings.TrimSpace(strings.ToLower(opt)) {
|
||||
case "delete-marker":
|
||||
dmReplicate = enableStatus
|
||||
case "delete":
|
||||
vDeleteReplicate = enableStatus
|
||||
case "replica-metadata-sync":
|
||||
replicasync = enableStatus
|
||||
|
||||
default:
|
||||
if opt != "" {
|
||||
fatalIf(probe.NewError(fmt.Errorf("invalid value for --replicate flag %s", cliCtx.String("replicate"))), "--replicate flag takes one or more comma separated string with values \"delete, delete-marker\"")
|
||||
fatalIf(probe.NewError(fmt.Errorf("invalid value for --replicate flag %s", cliCtx.String("replicate"))), "--replicate flag takes one or more comma separated string with values \"delete, delete-marker, replica-metadata-sync\" or \"\"")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
opts := replication.Options{
|
||||
TagString: cliCtx.String("tags"),
|
||||
RoleArn: cliCtx.String("arn"),
|
||||
@@ -184,12 +191,14 @@ func mainReplicateEdit(cliCtx *cli.Context) error {
|
||||
IsSCSet: cliCtx.IsSet("storage-class"),
|
||||
IsTagSet: cliCtx.IsSet("tags"),
|
||||
}
|
||||
|
||||
if cliCtx.IsSet("priority") {
|
||||
opts.Priority = strconv.Itoa(cliCtx.Int("priority"))
|
||||
}
|
||||
if cliCtx.IsSet("replicate") {
|
||||
opts.ReplicateDeletes = vDeleteReplicate
|
||||
opts.ReplicateDeleteMarkers = dmReplicate
|
||||
opts.ReplicaSync = replicasync
|
||||
}
|
||||
fatalIf(client.SetReplication(ctx, &rcfg, opts), "Could not modify replication rule")
|
||||
printMsg(replicateEditMessage{
|
||||
|
||||
@@ -17,7 +17,7 @@ require (
|
||||
github.com/minio/filepath v1.0.0 // indirect
|
||||
github.com/minio/madmin-go v1.0.2
|
||||
github.com/minio/minio v0.0.0-20210422165109-3455f786faf0
|
||||
github.com/minio/minio-go/v7 v7.0.11-0.20210511181606-0263c8eee163
|
||||
github.com/minio/minio-go/v7 v7.0.11-0.20210517200026-f0518ca447d6
|
||||
github.com/minio/sha256-simd v1.0.0
|
||||
github.com/mitchellh/go-homedir v1.1.0
|
||||
github.com/pkg/profile v1.3.0
|
||||
|
||||
@@ -335,6 +335,8 @@ github.com/minio/minio-go/v7 v7.0.11-0.20210407221404-ba867dba7ee1 h1:x0jnjGGnb0
|
||||
github.com/minio/minio-go/v7 v7.0.11-0.20210407221404-ba867dba7ee1/go.mod h1:mTh2uJuAbEqdhMVl6CMIIZLUeiMiWtJR4JB8/5g2skw=
|
||||
github.com/minio/minio-go/v7 v7.0.11-0.20210511181606-0263c8eee163 h1:kRHruZzRnERrnkv6EQvrQMIPdwW5rU77ekqlb7wZTjw=
|
||||
github.com/minio/minio-go/v7 v7.0.11-0.20210511181606-0263c8eee163/go.mod h1:td4gW1ldOsj1PbSNS+WYK43j+P1XVhX/8W8awaYlBFo=
|
||||
github.com/minio/minio-go/v7 v7.0.11-0.20210517200026-f0518ca447d6 h1:GVR+UTvfe2r2YTYHWrA/yRF5nouMjJh3kwxNTZ8npso=
|
||||
github.com/minio/minio-go/v7 v7.0.11-0.20210517200026-f0518ca447d6/go.mod h1:td4gW1ldOsj1PbSNS+WYK43j+P1XVhX/8W8awaYlBFo=
|
||||
github.com/minio/selfupdate v0.3.1/go.mod h1:b8ThJzzH7u2MkF6PcIra7KaXO9Khf6alWPvMSyTDCFM=
|
||||
github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
|
||||
github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g=
|
||||
|
||||
Reference in New Issue
Block a user