From 7bac47fe04a4a26faa0e8515036f7ff2dfc48c75 Mon Sep 17 00:00:00 2001 From: Praveen raj Mani Date: Mon, 25 Mar 2024 22:11:14 +0530 Subject: [PATCH] fix resync to find peers by deployment ID instead of site names (#4884) The site names may vary if configured on UI. The Deployment ID is immutable and can be used instead in replicate resync commands. --- cmd/admin-replicate-resync-cancel.go | 7 ++++++- cmd/admin-replicate-resync-start.go | 11 ++++++++--- cmd/admin-replicate-resync-status.go | 7 ++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/cmd/admin-replicate-resync-cancel.go b/cmd/admin-replicate-resync-cancel.go index d653a385..24f15ddf 100644 --- a/cmd/admin-replicate-resync-cancel.go +++ b/cmd/admin-replicate-resync-cancel.go @@ -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 } } diff --git a/cmd/admin-replicate-resync-start.go b/cmd/admin-replicate-resync-start.go index 60316d69..90dcb175 100644 --- a/cmd/admin-replicate-resync-start.go +++ b/cmd/admin-replicate-resync-start.go @@ -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 } } diff --git a/cmd/admin-replicate-resync-status.go b/cmd/admin-replicate-resync-status.go index f01abe5c..780c977b 100644 --- a/cmd/admin-replicate-resync-status.go +++ b/cmd/admin-replicate-resync-status.go @@ -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 } }