mirror of
https://github.com/minio/minio.git
synced 2025-04-18 09:50:02 -04:00
remove replicate set fallback behavior (#12865)
replica set deployment style is an incorrect style of distributed MinIO deployment, since statefulsets have been around for many releases in k8s now.
This commit is contained in:
parent
c13cbc64d1
commit
4d8f81a992
@ -71,7 +71,7 @@ func init() {
|
|||||||
logger.Init(GOPATH, GOROOT)
|
logger.Init(GOPATH, GOROOT)
|
||||||
logger.RegisterError(config.FmtError)
|
logger.RegisterError(config.FmtError)
|
||||||
|
|
||||||
if IsKubernetes() || IsDocker() || IsBOSH() || IsDCOS() || IsKubernetesReplicaSet() || IsPCFTile() {
|
if IsKubernetes() || IsDocker() || IsBOSH() || IsDCOS() || IsPCFTile() {
|
||||||
// 30 seconds matches the orchestrator DNS TTLs, have
|
// 30 seconds matches the orchestrator DNS TTLs, have
|
||||||
// a 5 second timeout to lookup from DNS servers.
|
// a 5 second timeout to lookup from DNS servers.
|
||||||
globalDNSCache = xhttp.NewDNSCache(30*time.Second, 5*time.Second, logger.LogOnceIf)
|
globalDNSCache = xhttp.NewDNSCache(30*time.Second, 5*time.Second, logger.LogOnceIf)
|
||||||
|
@ -377,27 +377,6 @@ func (endpoints Endpoints) GetAllStrings() (all []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func hostResolveToLocalhost(endpoint Endpoint) bool {
|
|
||||||
hostIPs, err := getHostIP(endpoint.Hostname())
|
|
||||||
if err != nil {
|
|
||||||
// Log the message to console about the host resolving
|
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags(
|
|
||||||
"host",
|
|
||||||
endpoint.Hostname(),
|
|
||||||
)
|
|
||||||
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
|
||||||
logger.LogIf(ctx, err, logger.Application)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
var loopback int
|
|
||||||
for _, hostIP := range hostIPs.ToSlice() {
|
|
||||||
if net.ParseIP(hostIP).IsLoopback() {
|
|
||||||
loopback++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return loopback == len(hostIPs)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (endpoints Endpoints) atleastOneEndpointLocal() bool {
|
func (endpoints Endpoints) atleastOneEndpointLocal() bool {
|
||||||
for _, endpoint := range endpoints {
|
for _, endpoint := range endpoints {
|
||||||
if endpoint.IsLocal {
|
if endpoint.IsLocal {
|
||||||
@ -410,7 +389,6 @@ func (endpoints Endpoints) atleastOneEndpointLocal() bool {
|
|||||||
// UpdateIsLocal - resolves the host and discovers the local host.
|
// UpdateIsLocal - resolves the host and discovers the local host.
|
||||||
func (endpoints Endpoints) UpdateIsLocal(foundPrevLocal bool) error {
|
func (endpoints Endpoints) UpdateIsLocal(foundPrevLocal bool) error {
|
||||||
orchestrated := IsDocker() || IsKubernetes()
|
orchestrated := IsDocker() || IsKubernetes()
|
||||||
k8sReplicaSet := IsKubernetesReplicaSet()
|
|
||||||
|
|
||||||
var epsResolved int
|
var epsResolved int
|
||||||
var foundLocal bool
|
var foundLocal bool
|
||||||
@ -443,24 +421,6 @@ func (endpoints Endpoints) UpdateIsLocal(foundPrevLocal bool) error {
|
|||||||
endpoints[i].Hostname(),
|
endpoints[i].Hostname(),
|
||||||
)
|
)
|
||||||
|
|
||||||
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
|
|
||||||
if timeElapsed > time.Second {
|
|
||||||
reqInfo.AppendTags("elapsedTime",
|
|
||||||
humanize.RelTime(startTime,
|
|
||||||
startTime.Add(timeElapsed),
|
|
||||||
"elapsed",
|
|
||||||
""))
|
|
||||||
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
|
||||||
logger.LogIf(ctx, err, logger.Application)
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// return err if not Docker or Kubernetes
|
// return err if not Docker or Kubernetes
|
||||||
// We use IsDocker() to check for Docker environment
|
// We use IsDocker() to check for Docker environment
|
||||||
// We use IsKubernetes() to check for Kubernetes environment
|
// We use IsKubernetes() to check for Kubernetes environment
|
||||||
@ -489,36 +449,6 @@ func (endpoints Endpoints) UpdateIsLocal(foundPrevLocal bool) error {
|
|||||||
} else {
|
} else {
|
||||||
resolvedList[i] = true
|
resolvedList[i] = true
|
||||||
endpoints[i].IsLocal = isLocal
|
endpoints[i].IsLocal = isLocal
|
||||||
if k8sReplicaSet && !endpoints.atleastOneEndpointLocal() && !foundPrevLocal {
|
|
||||||
// In replicated set in k8s deployment, IPs might
|
|
||||||
// get resolved for older IPs, add this code
|
|
||||||
// to ensure that we wait for this server to
|
|
||||||
// participate atleast one disk and be local.
|
|
||||||
//
|
|
||||||
// In special cases for replica set with expanded
|
|
||||||
// pool setups we need to make sure to provide
|
|
||||||
// value of foundPrevLocal from pool1 if we already
|
|
||||||
// found a local setup. Only if we haven't found
|
|
||||||
// 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(GlobalContext,
|
|
||||||
reqInfo)
|
|
||||||
logger.LogIf(ctx, err, logger.Application)
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
epsResolved++
|
epsResolved++
|
||||||
if !foundLocal {
|
if !foundLocal {
|
||||||
foundLocal = isLocal
|
foundLocal = isLocal
|
||||||
|
@ -150,11 +150,6 @@ func IsDCOS() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsKubernetesReplicaSet returns true if minio is running in kubernetes replica set.
|
|
||||||
func IsKubernetesReplicaSet() bool {
|
|
||||||
return IsKubernetes() && (env.Get("KUBERNETES_REPLICA_SET", "") != "")
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsKubernetes returns true if minio is running in kubernetes.
|
// IsKubernetes returns true if minio is running in kubernetes.
|
||||||
func IsKubernetes() bool {
|
func IsKubernetes() bool {
|
||||||
if env.Get("MINIO_CI_CD", "") == "" {
|
if env.Get("MINIO_CI_CD", "") == "" {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user