mirror of
				https://github.com/minio/minio.git
				synced 2025-10-30 00:05:02 -04:00 
			
		
		
		
	pick internode interface properly via globalLocalNodeName (#17680)
current code will not pick the right interface name if --address or --interface is not provided.
This commit is contained in:
		
							parent
							
								
									73a056999c
								
							
						
					
					
						commit
						4f257bf1e6
					
				| @ -248,13 +248,13 @@ func serverHandleCmdArgs(ctx *cli.Context) { | ||||
| 	logger.FatalIf(err, "Invalid command line arguments") | ||||
| 	globalNodes = globalEndpoints.GetNodes() | ||||
| 
 | ||||
| 	// Initialize, see which NIC the service is running on, and save it as global | ||||
| 	_ = getGlobalInternodeInterface(ctx.String("interface")) | ||||
| 
 | ||||
| 	globalLocalNodeName = GetLocalPeer(globalEndpoints, globalMinioHost, globalMinioPort) | ||||
| 	nodeNameSum := sha256.Sum256([]byte(globalLocalNodeName)) | ||||
| 	globalLocalNodeNameHex = hex.EncodeToString(nodeNameSum[:]) | ||||
| 
 | ||||
| 	// Initialize, see which NIC the service is running on, and save it as global value | ||||
| 	setGlobalInternodeInterface(ctx.String("interface")) | ||||
| 
 | ||||
| 	// allow transport to be HTTP/1.1 for proxying. | ||||
| 	globalProxyTransport = NewCustomHTTPProxyTransport()() | ||||
| 	globalProxyEndpoints = GetProxyEndpoints(globalEndpoints) | ||||
| @ -464,18 +464,27 @@ func initConfigSubsystem(ctx context.Context, newObject ObjectLayer) error { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func getGlobalInternodeInterface(interfs ...string) string { | ||||
| func setGlobalInternodeInterface(interfaceName string) { | ||||
| 	globalInternodeInterfaceOnce.Do(func() { | ||||
| 		if len(interfs) != 0 && strings.TrimSpace(interfs[0]) != "" { | ||||
| 			globalInternodeInterface = interfs[0] | ||||
| 		if interfaceName != "" { | ||||
| 			globalInternodeInterface = interfaceName | ||||
| 			return | ||||
| 		} | ||||
| 		ip := "127.0.0.1" | ||||
| 		host, _ := mustSplitHostPort(globalMinioAddr) | ||||
| 		host, _ := mustSplitHostPort(globalLocalNodeName) | ||||
| 		if host != "" { | ||||
| 			if net.ParseIP(host) != nil { | ||||
| 				ip = host | ||||
| 			} else { | ||||
| 				ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) | ||||
| 				defer cancel() | ||||
| 
 | ||||
| 				haddrs, err := globalDNSCache.LookupHost(ctx, host) | ||||
| 				if err == nil { | ||||
| 					ip = haddrs[0] | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		globalInternodeInterface = ip | ||||
| 		ifs, _ := net.Interfaces() | ||||
| 		for _, interf := range ifs { | ||||
| 			addrs, err := interf.Addrs() | ||||
| @ -488,7 +497,6 @@ func getGlobalInternodeInterface(interfs ...string) string { | ||||
| 			} | ||||
| 		} | ||||
| 	}) | ||||
| 	return globalInternodeInterface | ||||
| } | ||||
| 
 | ||||
| // Return the list of address that MinIO server needs to listen on: | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user