From 4d8f81a992e9da89961daca09cf0b020816d1bda Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 4 Aug 2021 15:23:18 -0700 Subject: [PATCH] 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. --- cmd/common-main.go | 2 +- cmd/endpoint.go | 70 ---------------------------------------------- cmd/update.go | 5 ---- 3 files changed, 1 insertion(+), 76 deletions(-) diff --git a/cmd/common-main.go b/cmd/common-main.go index ae1b07560..6cc931c4b 100644 --- a/cmd/common-main.go +++ b/cmd/common-main.go @@ -71,7 +71,7 @@ func init() { logger.Init(GOPATH, GOROOT) 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 // a 5 second timeout to lookup from DNS servers. globalDNSCache = xhttp.NewDNSCache(30*time.Second, 5*time.Second, logger.LogOnceIf) diff --git a/cmd/endpoint.go b/cmd/endpoint.go index 9cc6262dc..8b3f87e7c 100644 --- a/cmd/endpoint.go +++ b/cmd/endpoint.go @@ -377,27 +377,6 @@ func (endpoints Endpoints) GetAllStrings() (all []string) { 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 { for _, endpoint := range endpoints { if endpoint.IsLocal { @@ -410,7 +389,6 @@ func (endpoints Endpoints) atleastOneEndpointLocal() bool { // UpdateIsLocal - resolves the host and discovers the local host. func (endpoints Endpoints) UpdateIsLocal(foundPrevLocal bool) error { orchestrated := IsDocker() || IsKubernetes() - k8sReplicaSet := IsKubernetesReplicaSet() var epsResolved int var foundLocal bool @@ -443,24 +421,6 @@ func (endpoints Endpoints) UpdateIsLocal(foundPrevLocal bool) error { 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 // We use IsDocker() to check for Docker environment // We use IsKubernetes() to check for Kubernetes environment @@ -489,36 +449,6 @@ func (endpoints Endpoints) UpdateIsLocal(foundPrevLocal bool) error { } else { resolvedList[i] = true 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++ if !foundLocal { foundLocal = isLocal diff --git a/cmd/update.go b/cmd/update.go index 354bfd738..dda344aca 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -150,11 +150,6 @@ func IsDCOS() bool { 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. func IsKubernetes() bool { if env.Get("MINIO_CI_CD", "") == "" {