Skip to content

Commit

Permalink
Option to enable diable ILM expiry for site replication
Browse files Browse the repository at this point in the history
Added options `replicate-ilm-expiry` and `disable-ilm-expiry-replication`
for `mc admin replicate add` and `mc admin replicate update` commands
respectively.

Signed-off-by: Shubhendu Ram Tripathi <[email protected]>
  • Loading branch information
shtripat committed Oct 11, 2023
1 parent eca8310 commit cdeb151
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
16 changes: 14 additions & 2 deletions cmd/admin-replicate-add.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,20 @@ import (
"github.com/minio/pkg/v2/console"
)

var adminReplicateAddFlags = []cli.Flag{
cli.BoolFlag{
Name: "replicate-ilm-expiry",
Usage: "replicate ILM expiry rules",
},
}

var adminReplicateAddCmd = cli.Command{
Name: "add",
Usage: "add one or more sites for replication",
Action: mainAdminReplicateAdd,
OnUsageError: onUsageError,
Before: setGlobalsFromContext,
Flags: globalFlags,
Flags: append(globalFlags, adminReplicateAddFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
Expand All @@ -48,6 +55,9 @@ FLAGS:
EXAMPLES:
1. Add a site for cluster-level replication:
{{.Prompt}} {{.HelpName}} minio1 minio2
2. Add a site for cluster-level replication with replication of ILM expiry rules:
{{.Prompt}} {{.HelpName}} minio1 minio2 --replicate-ilm-expiry
`,
}

Expand Down Expand Up @@ -106,7 +116,9 @@ func mainAdminReplicateAdd(ctx *cli.Context) error {
})
}

res, e := client.SiteReplicationAdd(globalContext, ps)
var opts madmin.SRAddOptions
opts.ReplicateILMExpiry = ctx.Bool("replicate-ilm-expiry")
res, e := client.SiteReplicationAdd(globalContext, ps, opts)
fatalIf(probe.NewError(e).Trace(args...), "Unable to add sites for replication")

printMsg(successMessage(res))
Expand Down
15 changes: 12 additions & 3 deletions cmd/admin-replicate-update.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ var adminReplicateUpdateFlags = []cli.Flag{
Hidden: true, // deprecated Jul 2023

},
cli.BoolFlag{
Name: "disable-ilm-expiry-replication",
Usage: "disable ILM expiry rules replication",
},
}

var adminReplicateUpdateCmd = cli.Command{
Expand All @@ -74,6 +78,9 @@ FLAGS:
EXAMPLES:
1. Edit a site endpoint participating in cluster-level replication:
{{.Prompt}} {{.HelpName}} myminio --deployment-id c1758167-4426-454f-9aae-5c3dfdf6df64 --endpoint https://minio2:9000
2. Disable replication of ILM expiry in cluster-level replication:
{{.Prompt}} {{.HelpName}} myminio --deployment-id c1758167-4426-454f-9aae-5c3dfdf6df64 --disable-ilm-expiry-replication
`,
}

Expand Down Expand Up @@ -122,8 +129,8 @@ func mainAdminReplicateUpdate(ctx *cli.Context) error {
if !ctx.IsSet("deployment-id") {
fatalIf(errInvalidArgument(), "--deployment-id is a required flag")
}
if !ctx.IsSet("endpoint") && !ctx.IsSet("mode") && !ctx.IsSet("sync") {
fatalIf(errInvalidArgument(), "--endpoint or --mode is a required flag")
if !ctx.IsSet("endpoint") && !ctx.IsSet("mode") && !ctx.IsSet("sync") && !ctx.IsSet("disable-ilm-expiry-replication") {
fatalIf(errInvalidArgument(), "--endpoint, --mode or disable-ilm-expiry-replication is a required flag")
}
if ctx.IsSet("mode") && ctx.IsSet("sync") {
fatalIf(errInvalidArgument(), "either --sync or --mode flag should be specified")
Expand Down Expand Up @@ -159,11 +166,13 @@ func mainAdminReplicateUpdate(ctx *cli.Context) error {
}
ep = u.String()
}
var opts madmin.SREditOptions
opts.DisableILMExpiryReplication = ctx.Bool("disable-ilm-expiry-replication")
res, e := client.SiteReplicationEdit(globalContext, madmin.PeerInfo{
DeploymentID: ctx.String("deployment-id"),
Endpoint: ep,
SyncState: madmin.SyncStatus(syncState),
})
}, opts)
fatalIf(probe.NewError(e).Trace(args...), "Unable to edit cluster replication site endpoint")

printMsg(updateSuccessMessage(res))
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ require (
github.com/kr/pretty v0.3.1 // indirect
github.com/minio/mux v1.9.0 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/safchain/ethtool v0.3.0 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb // indirect
Expand Down Expand Up @@ -126,3 +127,5 @@ require (
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
)

replace github.com/minio/madmin-go/v3 v3.0.21 => github.com/shtripat/madmin-go/v3 v3.0.0-20231011114400-348fa9994342
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ github.com/minio/colorjson v1.0.6 h1:m7TUvpvt0u7FBmVIEQNIa0T4NBQlxrcMBp4wJKsg2Ik
github.com/minio/colorjson v1.0.6/go.mod h1:LUXwS5ZGNb6Eh9f+t+3uJiowD3XsIWtsvTriUBeqgYs=
github.com/minio/filepath v1.0.0 h1:fvkJu1+6X+ECRA6G3+JJETj4QeAYO9sV43I79H8ubDY=
github.com/minio/filepath v1.0.0/go.mod h1:/nRZA2ldl5z6jT9/KQuvZcQlxZIMQoFFQPvEXx9T/Bw=
github.com/minio/madmin-go/v3 v3.0.21 h1:54LroTtjkn60nvDMBHmCEMGcFQ3k3Yel74RaEu9n2cY=
github.com/minio/madmin-go/v3 v3.0.21/go.mod h1:B2EgtEGrfWx+AkXv+OAcS6IHwoIJcd1p75QfDPSPd6Q=
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
github.com/minio/minio-go/v7 v7.0.63 h1:GbZ2oCvaUdgT5640WJOpyDhhDxvknAJU2/T3yurwcbQ=
Expand Down Expand Up @@ -208,6 +206,8 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/safchain/ethtool v0.3.0 h1:gimQJpsI6sc1yIqP/y8GYgiXn/NjgvpM0RNoWLVVmP0=
github.com/safchain/ethtool v0.3.0/go.mod h1:SA9BwrgyAqNo7M+uaL6IYbxpm5wk3L7Mm6ocLW+CJUs=
github.com/secure-io/sio-go v0.3.1 h1:dNvY9awjabXTYGsTF1PiCySl9Ltofk9GA3VdWlo7rRc=
github.com/secure-io/sio-go v0.3.1/go.mod h1:+xbkjDzPjwh4Axd07pRKSNriS9SCiYksWnZqdnfpQxs=
github.com/shirou/gopsutil/v3 v3.23.8 h1:xnATPiybo6GgdRoC4YoGnxXZFRc3dqQTGi73oLvvBrE=
Expand All @@ -216,6 +216,8 @@ github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFt
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=
github.com/shtripat/madmin-go/v3 v3.0.0-20231011114400-348fa9994342 h1:aBGeFxHJqO030n7rpKUviRD0eLJiKldnmDU5RH8L5DQ=
github.com/shtripat/madmin-go/v3 v3.0.0-20231011114400-348fa9994342/go.mod h1:4QN2NftLSV7MdlT50dkrenOMmNVHluxTvlqJou3hte8=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down

0 comments on commit cdeb151

Please sign in to comment.