mirror of
				https://github.com/minio/minio.git
				synced 2025-10-29 15:55:00 -04:00 
			
		
		
		
	Change replica set detection for localhost on single endpoint (#8692)
This commit is contained in:
		
							parent
							
								
									f68a7005c0
								
							
						
					
					
						commit
						54431b3953
					
				| @ -46,9 +46,7 @@ function main() | ||||
|     gw_pid="$(start_minio_gateway_s3)" | ||||
| 
 | ||||
|     SERVER_ENDPOINT=127.0.0.1:24240 ENABLE_HTTPS=0 ACCESS_KEY=minio \ | ||||
|                    SECRET_KEY=minio123 MINT_MODE="full" /mint/entrypoint.sh aws-sdk-go \ | ||||
|                    aws-sdk-java aws-sdk-php aws-sdk-ruby awscli healthcheck minio-dotnet \ | ||||
|                    minio-go minio-java minio-js minio-py | ||||
|                    SECRET_KEY=minio123 MINT_MODE="full" /mint/entrypoint.sh | ||||
|     rv=$? | ||||
| 
 | ||||
|     kill "$sr_pid" | ||||
|  | ||||
| @ -18,7 +18,6 @@ package cmd | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"net" | ||||
| 	"net/url" | ||||
| @ -230,11 +229,17 @@ func (endpoints Endpoints) GetString(i int) string { | ||||
| 	return endpoints[i].String() | ||||
| } | ||||
| 
 | ||||
| func (endpoints Endpoints) doAnyHostsResolveToLocalhost() bool { | ||||
| 	for _, endpoint := range endpoints { | ||||
| func hostResolveToLocalhost(endpoint Endpoint) bool { | ||||
| 	hostIPs, err := getHostIP(endpoint.Hostname()) | ||||
| 	if err != nil { | ||||
| 			continue | ||||
| 		// Log the message to console about the host resolving | ||||
| 		reqInfo := (&logger.ReqInfo{}).AppendTags( | ||||
| 			"host", | ||||
| 			endpoint.Hostname(), | ||||
| 		) | ||||
| 		ctx := logger.SetReqInfo(context.Background(), reqInfo) | ||||
| 		logger.LogIf(ctx, err, logger.Application) | ||||
| 		return false | ||||
| 	} | ||||
| 	var loopback int | ||||
| 	for _, hostIP := range hostIPs.ToSlice() { | ||||
| @ -242,11 +247,7 @@ func (endpoints Endpoints) doAnyHostsResolveToLocalhost() bool { | ||||
| 			loopback++ | ||||
| 		} | ||||
| 	} | ||||
| 		if loopback == len(hostIPs) { | ||||
| 			return true | ||||
| 		} | ||||
| 	} | ||||
| 	return false | ||||
| 	return loopback == len(hostIPs) | ||||
| } | ||||
| 
 | ||||
| func (endpoints Endpoints) atleastOneEndpointLocal() bool { | ||||
| @ -294,8 +295,9 @@ func (endpoints Endpoints) UpdateIsLocal(foundPrevLocal bool) error { | ||||
| 					endpoints[i].Hostname(), | ||||
| 				) | ||||
| 
 | ||||
| 				if k8sReplicaSet && endpoints.doAnyHostsResolveToLocalhost() { | ||||
| 					err := errors.New("host found resolves to 127.*, DNS incorrectly configured retrying") | ||||
| 				if k8sReplicaSet && hostResolveToLocalhost(endpoints[i]) { | ||||
| 					err := fmt.Errorf("host %s resolves to 127.*, DNS incorrectly configured retrying", | ||||
| 						endpoints[i]) | ||||
| 					// time elapsed | ||||
| 					timeElapsed := time.Since(startTime) | ||||
| 					// log error only if more than 1s elapsed | ||||
| @ -352,6 +354,21 @@ func (endpoints Endpoints) UpdateIsLocal(foundPrevLocal bool) error { | ||||
| 						// previous local we continue to wait to look for | ||||
| 						// atleast one local. | ||||
| 						resolvedList[i] = false | ||||
| 						// time elapsed | ||||
| 						err := fmt.Errorf("no endpoint is local to this host: %s", endpoints[i]) | ||||
| 						timeElapsed := time.Since(startTime) | ||||
| 						// log error only if more than 1s elapsed | ||||
| 						if timeElapsed > time.Second { | ||||
| 							reqInfo.AppendTags("elapsedTime", | ||||
| 								humanize.RelTime(startTime, | ||||
| 									startTime.Add(timeElapsed), | ||||
| 									"elapsed", | ||||
| 									"", | ||||
| 								)) | ||||
| 							ctx := logger.SetReqInfo(context.Background(), | ||||
| 								reqInfo) | ||||
| 							logger.LogIf(ctx, err, logger.Application) | ||||
| 						} | ||||
| 						continue | ||||
| 					} | ||||
| 					epsResolved++ | ||||
|  | ||||
| @ -130,7 +130,6 @@ func newApp(name string) *cli.App { | ||||
| 	app.Usage = "High Performance Object Storage" | ||||
| 	app.Description = `Build high performance data infrastructure for machine learning, analytics and application data workloads with MinIO` | ||||
| 	app.Flags = GlobalFlags | ||||
| 	app.HideVersion = true     // Hide `--version` flag, we already have `minio version`. | ||||
| 	app.HideHelpCommand = true // Hide `help, h` command, we already have `minio --help`. | ||||
| 	app.Commands = commands | ||||
| 	app.CustomAppHelpTemplate = minioHelpTemplate | ||||
|  | ||||
| @ -17,7 +17,7 @@ | ||||
| package cmd | ||||
| 
 | ||||
| const ( | ||||
| 	storageRESTVersion       = "v11" | ||||
| 	storageRESTVersion       = "v12" | ||||
| 	storageRESTVersionPrefix = SlashSeparator + storageRESTVersion | ||||
| 	storageRESTPrefix        = minioReservedBucketPath + "/storage" | ||||
| ) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user