Repository: minio/minio (language: go)

Issue:
Site replication broken in RELEASE.2023-06-23T20-26-00Z
## NOTE
If this case is urgent, please subscribe to [Subnet](https://min.io/pricing) so that our 24/7 support team may help you faster.

<!--- Provide a general summary of the issue in the Title above -->

## Expected Behavior
Site replication should work

## Current Behavior
Site replication throws error 'XMinioAdminRemoteIdenticalToSource'
The remote target cannot be identical to source (remote target endpoint http://192.168.0.10:9000 is self referential)"
*This happens when using two completely physically separate machines

## Possible Solution
Rolled back to RELEASE.2023-06-19T19-52-50Z and it works as intended

## Steps to Reproduce (for bugs)
Download fresh copy of RELEASE.2023-06-23T20-26-00Z and enable site replication between two sites

Buckets are replicated but files are not, error is XMinioAdminRemoteIdenticalToSource

## Context
<!--- How has this issue affected you? What are you trying to accomplish? -->
I upgraded to latest and needed to enable replication but does not work on latest, spent hours double checking configuration but it turns out its just a version issue in the latest 


Discussion / hints:
@alexv305 did you upgrade both sites to same version? 
and are your IPs same? for both clusters?
Hello @harshavardhana, yes both are running latest version.
IPs are different for each site, 192.168.0.5 is the current deployment that I wish to enable replication, 192.168.0.10 is the remote

I tested using the docker version as well and had the same issue with 2 different docker network IPs, when I rolled back to previous version it worked fine with no errors in the log.
It looks like a recent change in checkEndpoint() to look for self referential endpoints
Can you share outputs for curl -v on the /minio/health/ready endpoint?
`$ curl -v http://192.168.0.10:9000/minio/health/ready
*   Trying 192.168.0.10:9000...
* Connected to 192.168.0.10 (192.168.0.10) port 9000 (#0)
> GET /minio/health/ready HTTP/1.1
> Host: 192.168.0.10:9000
> User-Agent: curl/7.74.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Content-Length: 0
< Content-Security-Policy: block-all-mixed-content
< Server: MinIO
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< Vary: Origin
< X-Amz-Id-2: dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8
< X-Amz-Request-Id: 176C578FEAAE5710
< X-Content-Type-Options: nosniff
< X-Xss-Protection: 1; mode=block
< Date: Mon, 26 Jun 2023 22:57:15 GMT
<
* Connection #0 to host 192.168.0.10 left intact`
For both sites @alexv305 
Sorry, heres the second site:

`$ curl -v http://192.168.0.5:9000/minio/health/ready
*   Trying 192.168.0.5:9000...
* Connected to 192.168.0.5 (192.168.0.5) port 9000 (#0)
> GET /minio/health/ready HTTP/1.1
> Host: 192.168.0.5:9000
> User-Agent: curl/7.74.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Content-Length: 0
< Content-Security-Policy: block-all-mixed-content
< Server: MinIO
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< Vary: Origin
< X-Amz-Id-2: dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8
< X-Amz-Request-Id: 176C585981A9F827
< X-Content-Type-Options: nosniff
< X-Xss-Protection: 1; mode=block
< Date: Mon, 26 Jun 2023 23:11:41 GMT
<
* Connection #0 to host 192.168.0.5 left intact`
yeah this is the issue

> < X-Amz-Id-2: dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8

> < X-Amz-Id-2: dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8



can you show me how it is setup? i.e `minio` command line etc?

Fix patch:
diff --git a/cmd/globals.go b/cmd/globals.go
index fff57c5127cf2..d3b0d002f38f9 100644
--- a/cmd/globals.go
+++ b/cmd/globals.go
@@ -232,7 +232,7 @@ var (
 	// The name of this local node, fetched from arguments
 	globalLocalNodeName    string
 	globalLocalNodeNameHex string
-	globalNodeNamesHex     map[string]struct{}
+	globalNodeNamesHex     = make(map[string]struct{})
 
 	// The global subnet config
 	globalSubnetConfig subnet.Config
diff --git a/cmd/server-main.go b/cmd/server-main.go
index b8fdd0c73f03b..39aadde32dd71 100644
--- a/cmd/server-main.go
+++ b/cmd/server-main.go
@@ -251,15 +251,6 @@ func serverHandleCmdArgs(ctx *cli.Context) {
 	globalLocalNodeName = GetLocalPeer(globalEndpoints, globalMinioHost, globalMinioPort)
 	nodeNameSum := sha256.Sum256([]byte(globalLocalNodeName))
 	globalLocalNodeNameHex = hex.EncodeToString(nodeNameSum[:])
-	globalNodeNamesHex = make(map[string]struct{})
-	for _, n := range globalNodes {
-		nodeName := n.Host
-		if n.IsLocal {
-			nodeName = globalLocalNodeName
-		}
-		nodeNameSum := sha256.Sum256([]byte(nodeName))
-		globalNodeNamesHex[hex.EncodeToString(nodeNameSum[:])] = struct{}{}
-	}
 
 	// allow transport to be HTTP/1.1 for proxying.
 	globalProxyTransport = NewCustomHTTPProxyTransport()()
@@ -641,6 +632,15 @@ func serverMain(ctx *cli.Context) {
 	xhttp.SetDeploymentID(globalDeploymentID)
 	xhttp.SetMinIOVersion(Version)
 
+	for _, n := range globalNodes {
+		nodeName := n.Host
+		if n.IsLocal {
+			nodeName = globalLocalNodeName
+		}
+		nodeNameSum := sha256.Sum256([]byte(nodeName + globalDeploymentID))
+		globalNodeNamesHex[hex.EncodeToString(nodeNameSum[:])] = struct{}{}
+	}
+
 	bootstrapTrace("newSharedLock")
 	globalLeaderLock = newSharedLock(GlobalContext, newObject, "leader.lock")
 


Test patch: