Change replica set detection for localhost on single endpoint (#8692)

master
Harshavardhana 5 years ago committed by kannappanr
parent f68a7005c0
commit 54431b3953
  1. 4
      buildscripts/gateway-tests.sh
  2. 57
      cmd/endpoint.go
  3. 1
      cmd/main.go
  4. 2
      cmd/storage-rest-common.go

@ -46,9 +46,7 @@ function main()
gw_pid="$(start_minio_gateway_s3)" gw_pid="$(start_minio_gateway_s3)"
SERVER_ENDPOINT=127.0.0.1:24240 ENABLE_HTTPS=0 ACCESS_KEY=minio \ 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 \ SECRET_KEY=minio123 MINT_MODE="full" /mint/entrypoint.sh
aws-sdk-java aws-sdk-php aws-sdk-ruby awscli healthcheck minio-dotnet \
minio-go minio-java minio-js minio-py
rv=$? rv=$?
kill "$sr_pid" kill "$sr_pid"

@ -18,7 +18,6 @@ package cmd
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"net" "net"
"net/url" "net/url"
@ -230,23 +229,25 @@ func (endpoints Endpoints) GetString(i int) string {
return endpoints[i].String() return endpoints[i].String()
} }
func (endpoints Endpoints) doAnyHostsResolveToLocalhost() bool { func hostResolveToLocalhost(endpoint Endpoint) bool {
for _, endpoint := range endpoints { hostIPs, err := getHostIP(endpoint.Hostname())
hostIPs, err := getHostIP(endpoint.Hostname()) if err != nil {
if err != nil { // Log the message to console about the host resolving
continue reqInfo := (&logger.ReqInfo{}).AppendTags(
} "host",
var loopback int endpoint.Hostname(),
for _, hostIP := range hostIPs.ToSlice() { )
if net.ParseIP(hostIP).IsLoopback() { ctx := logger.SetReqInfo(context.Background(), reqInfo)
loopback++ logger.LogIf(ctx, err, logger.Application)
} return false
} }
if loopback == len(hostIPs) { var loopback int
return true for _, hostIP := range hostIPs.ToSlice() {
} if net.ParseIP(hostIP).IsLoopback() {
} loopback++
return false }
}
return loopback == len(hostIPs)
} }
func (endpoints Endpoints) atleastOneEndpointLocal() bool { func (endpoints Endpoints) atleastOneEndpointLocal() bool {
@ -294,8 +295,9 @@ func (endpoints Endpoints) UpdateIsLocal(foundPrevLocal bool) error {
endpoints[i].Hostname(), endpoints[i].Hostname(),
) )
if k8sReplicaSet && endpoints.doAnyHostsResolveToLocalhost() { if k8sReplicaSet && hostResolveToLocalhost(endpoints[i]) {
err := errors.New("host found resolves to 127.*, DNS incorrectly configured retrying") err := fmt.Errorf("host %s resolves to 127.*, DNS incorrectly configured retrying",
endpoints[i])
// time elapsed // time elapsed
timeElapsed := time.Since(startTime) timeElapsed := time.Since(startTime)
// log error only if more than 1s elapsed // 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 // previous local we continue to wait to look for
// atleast one local. // atleast one local.
resolvedList[i] = false 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 continue
} }
epsResolved++ epsResolved++

@ -130,7 +130,6 @@ func newApp(name string) *cli.App {
app.Usage = "High Performance Object Storage" app.Usage = "High Performance Object Storage"
app.Description = `Build high performance data infrastructure for machine learning, analytics and application data workloads with MinIO` app.Description = `Build high performance data infrastructure for machine learning, analytics and application data workloads with MinIO`
app.Flags = GlobalFlags 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.HideHelpCommand = true // Hide `help, h` command, we already have `minio --help`.
app.Commands = commands app.Commands = commands
app.CustomAppHelpTemplate = minioHelpTemplate app.CustomAppHelpTemplate = minioHelpTemplate

@ -17,7 +17,7 @@
package cmd package cmd
const ( const (
storageRESTVersion = "v11" storageRESTVersion = "v12"
storageRESTVersionPrefix = SlashSeparator + storageRESTVersion storageRESTVersionPrefix = SlashSeparator + storageRESTVersion
storageRESTPrefix = minioReservedBucketPath + "/storage" storageRESTPrefix = minioReservedBucketPath + "/storage"
) )

Loading…
Cancel
Save