mirror of
https://github.com/minio/minio.git
synced 2026-02-04 18:00:15 -05:00
Allow server to start if one of local nodes in docker/kubernetes setup is resolved (#7452)
Allow server to start if one of the local nodes in docker/kubernetes setup is successfully resolved - The rule is that we need atleast one local node to work. We dont need to resolve the rest at that point. - In a non-orchestrational setup, we fail if we do not have atleast one local node up and running. - In an orchestrational setup (docker-swarm and kubernetes), We retry with a sleep of 5 seconds until any one local node shows up. Fixes #6995
This commit is contained in:
committed by
kannappanr
parent
d42496cc74
commit
d96584ef58
38
cmd/net.go
38
cmd/net.go
@@ -17,7 +17,6 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
@@ -27,9 +26,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
humanize "github.com/dustin/go-humanize"
|
||||
"github.com/minio/minio-go/pkg/set"
|
||||
"github.com/minio/minio/cmd/logger"
|
||||
)
|
||||
@@ -102,40 +99,7 @@ func getHostIP(host string) (ipList set.StringSet, err error) {
|
||||
var ips []net.IP
|
||||
|
||||
if ips, err = net.LookupIP(host); err != nil {
|
||||
// return err if not Docker or Kubernetes
|
||||
// We use IsDocker() method to check for Docker Swarm environment
|
||||
// as there is no reliable way to clearly identify Swarm from
|
||||
// Docker environment.
|
||||
if !IsDocker() && !IsKubernetes() {
|
||||
return ipList, err
|
||||
}
|
||||
|
||||
// channel to indicate completion of host resolution
|
||||
doneCh := make(chan struct{})
|
||||
// Indicate retry routine to exit cleanly, upon this function return.
|
||||
defer close(doneCh)
|
||||
// Mark the starting time
|
||||
startTime := time.Now()
|
||||
// wait for hosts to resolve in exponentialbackoff manner
|
||||
for range newRetryTimerSimple(doneCh) {
|
||||
// Retry infinitely on Kubernetes and Docker swarm.
|
||||
// This is needed as the remote hosts are sometime
|
||||
// not available immediately.
|
||||
if ips, err = net.LookupIP(host); err == nil {
|
||||
break
|
||||
}
|
||||
// time elapsed
|
||||
timeElapsed := time.Since(startTime)
|
||||
// log error only if more than 1s elapsed
|
||||
if timeElapsed > time.Second {
|
||||
// log the message to console about the host not being
|
||||
// resolveable.
|
||||
reqInfo := (&logger.ReqInfo{}).AppendTags("host", host)
|
||||
reqInfo.AppendTags("elapsedTime", humanize.RelTime(startTime, startTime.Add(timeElapsed), "elapsed", ""))
|
||||
ctx := logger.SetReqInfo(context.Background(), reqInfo)
|
||||
logger.LogIf(ctx, err)
|
||||
}
|
||||
}
|
||||
return ipList, err
|
||||
}
|
||||
|
||||
ipList = set.NewStringSet()
|
||||
|
||||
Reference in New Issue
Block a user