Add flag to admin replicate update to toggle synchronous replication (#4514)
This commit is contained in:
@@ -70,16 +70,21 @@ func (i srInfo) String() string {
|
||||
Field{"Deployment ID", 36},
|
||||
|
||||
Field{"Name", 15},
|
||||
Field{"Endpoint", 50},
|
||||
).buildRow("Deployment ID", "Site Name", "Endpoint"))
|
||||
Field{"Endpoint", 46},
|
||||
Field{"Sync", 4},
|
||||
).buildRow("Deployment ID", "Site Name", "Endpoint", "Sync"))
|
||||
messages = append(messages, r)
|
||||
for _, peer := range info.Sites {
|
||||
var chk string
|
||||
if peer.SyncState == madmin.SyncEnabled {
|
||||
chk = check
|
||||
}
|
||||
r := console.Colorize("TDetail", newPrettyTable(" | ",
|
||||
Field{"Deployment ID", 36},
|
||||
|
||||
Field{"Name", 15},
|
||||
Field{"Endpoint", 50},
|
||||
).buildRow(peer.DeploymentID, peer.Name, peer.Endpoint))
|
||||
Field{"Endpoint", 46},
|
||||
Field{"Sync", 4},
|
||||
).buildRow(peer.DeploymentID, peer.Name, peer.Endpoint, chk))
|
||||
messages = append(messages, r)
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -38,6 +38,11 @@ var adminReplicateUpdateFlags = []cli.Flag{
|
||||
Name: "endpoint",
|
||||
Usage: "endpoint for the site",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "sync",
|
||||
Usage: "enable synchronous replication for this target, valid values are ['enable', 'disable'].",
|
||||
Value: "disable",
|
||||
},
|
||||
}
|
||||
|
||||
var adminReplicateUpdateCmd = cli.Command{
|
||||
@@ -110,17 +115,31 @@ func mainAdminReplicateUpdate(ctx *cli.Context) error {
|
||||
if !ctx.IsSet("deployment-id") {
|
||||
fatalIf(errInvalidArgument(), "--deployment-id is a required flag")
|
||||
}
|
||||
if !ctx.IsSet("endpoint") {
|
||||
fatalIf(errInvalidArgument(), "--endpoint is a required flag")
|
||||
if !ctx.IsSet("endpoint") && !ctx.IsSet("sync") {
|
||||
fatalIf(errInvalidArgument(), "--endpoint or --sync is a required flag")
|
||||
}
|
||||
parsedURL := ctx.String("endpoint")
|
||||
u, e := url.Parse(parsedURL)
|
||||
if e != nil {
|
||||
fatalIf(errInvalidArgument().Trace(parsedURL), "Unsupported URL format %v", e)
|
||||
var syncState string
|
||||
if ctx.IsSet("sync") {
|
||||
syncState = strings.ToLower(ctx.String("sync"))
|
||||
switch syncState {
|
||||
case "enable", "disable":
|
||||
default:
|
||||
fatalIf(errInvalidArgument().Trace(args...), "--sync can be either [enable|disable]")
|
||||
}
|
||||
}
|
||||
var ep string
|
||||
if ctx.IsSet("endpoint") {
|
||||
parsedURL := ctx.String("endpoint")
|
||||
u, e := url.Parse(parsedURL)
|
||||
if e != nil {
|
||||
fatalIf(errInvalidArgument().Trace(parsedURL), "Unsupported URL format %v", e)
|
||||
}
|
||||
ep = u.String()
|
||||
}
|
||||
res, e := client.SiteReplicationEdit(globalContext, madmin.PeerInfo{
|
||||
DeploymentID: ctx.String("deployment-id"),
|
||||
Endpoint: u.String(),
|
||||
Endpoint: ep,
|
||||
SyncState: madmin.SyncStatus(syncState),
|
||||
})
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to edit cluster replication site endpoint")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user