Skip to content

Commit

Permalink
fix resync to find peers by deployment ID instead of site names (#4884)
Browse files Browse the repository at this point in the history
The site names may vary if configured on UI. The Deployment ID
is immutable and can be used instead in replicate resync commands.
  • Loading branch information
Praveenrajmani committed Mar 25, 2024
1 parent 9043bbf commit 7bac47f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
7 changes: 6 additions & 1 deletion cmd/admin-replicate-resync-cancel.go
Expand Up @@ -92,9 +92,14 @@ func mainAdminReplicateResyncCancel(ctx *cli.Context) error {
fatalIf(err, "Unable to initialize admin connection.")
info, e := client.SiteReplicationInfo(globalContext)
fatalIf(probe.NewError(e), "Unable to fetch site replication info.")

peerClient := getClient(args.Get(1))
peerAdmInfo, e := peerClient.ServerInfo(globalContext)
fatalIf(probe.NewError(e), "Unable to fetch server info of the peer.")

var peer madmin.PeerInfo
for _, site := range info.Sites {
if args[1] == site.Name {
if peerAdmInfo.DeploymentID == site.DeploymentID {
peer = site
}
}
Expand Down
11 changes: 8 additions & 3 deletions cmd/admin-replicate-resync-start.go
Expand Up @@ -87,15 +87,20 @@ func mainAdminReplicateResyncStart(ctx *cli.Context) error {

// Get the alias parameter from cli
args := ctx.Args()
aliasedURL := args.Get(0)

// Create a new MinIO Admin Client
client, err := newAdminClient(aliasedURL)
client, err := newAdminClient(args.Get(0))
fatalIf(err, "Unable to initialize admin connection.")
info, e := client.SiteReplicationInfo(globalContext)
fatalIf(probe.NewError(e), "Unable to fetch site replication info.")

peerClient := getClient(args.Get(1))
peerAdmInfo, e := peerClient.ServerInfo(globalContext)
fatalIf(probe.NewError(e), "Unable to fetch server info of the peer.")

var peer madmin.PeerInfo
for _, site := range info.Sites {
if args[1] == site.Name {
if peerAdmInfo.DeploymentID == site.DeploymentID {
peer = site
}
}
Expand Down
7 changes: 6 additions & 1 deletion cmd/admin-replicate-resync-status.go
Expand Up @@ -86,9 +86,14 @@ func mainAdminReplicationResyncStatus(ctx *cli.Context) error {
console.Colorize("ResyncMessage", "SiteReplication is not enabled")
return nil
}

peerClient := getClient(args.Get(1))
peerAdmInfo, e := peerClient.ServerInfo(globalContext)
fatalIf(probe.NewError(e), "Unable to fetch server info of the peer.")

var peer madmin.PeerInfo
for _, site := range info.Sites {
if args[1] == site.Name {
if peerAdmInfo.DeploymentID == site.DeploymentID {
peer = site
}
}
Expand Down

0 comments on commit 7bac47f

Please sign in to comment.