mirror of
https://github.com/minio/minio.git
synced 2025-05-05 16:48:15 -04:00
avoid frequent DNS lookups for baremetal setups (#11972)
bump up the DNS cache for baremetal setups upto 10 minutes
This commit is contained in:
parent
05a9108c24
commit
89d58bec16
@ -59,7 +59,15 @@ func init() {
|
|||||||
config.Logger.Info = logger.Info
|
config.Logger.Info = logger.Info
|
||||||
config.Logger.LogIf = logger.LogIf
|
config.Logger.LogIf = logger.LogIf
|
||||||
|
|
||||||
globalDNSCache = xhttp.NewDNSCache(10*time.Second, 10*time.Second, logger.LogOnceIf)
|
if IsKubernetes() || IsDocker() || IsBOSH() || IsDCOS() || IsKubernetesReplicaSet() || 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)
|
||||||
|
} else {
|
||||||
|
// On bare-metals DNS do not change often, so it is
|
||||||
|
// safe to assume a higher timeout upto 10 minutes.
|
||||||
|
globalDNSCache = xhttp.NewDNSCache(10*time.Minute, 5*time.Second, logger.LogOnceIf)
|
||||||
|
}
|
||||||
|
|
||||||
initGlobalContext()
|
initGlobalContext()
|
||||||
|
|
||||||
|
@ -121,6 +121,8 @@ func NewDNSCache(freq time.Duration, lookupTimeout time.Duration, loggerOnce fun
|
|||||||
doneCh: make(chan struct{}),
|
doneCh: make(chan struct{}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rnd := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||||
|
|
||||||
timer := time.NewTimer(freq)
|
timer := time.NewTimer(freq)
|
||||||
go func() {
|
go func() {
|
||||||
defer timer.Stop()
|
defer timer.Stop()
|
||||||
@ -128,7 +130,10 @@ func NewDNSCache(freq time.Duration, lookupTimeout time.Duration, loggerOnce fun
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
timer.Reset(freq)
|
// Make sure that refreshes on DNS do not be attempted
|
||||||
|
// at the same time, allows for reduced load on the
|
||||||
|
// DNS servers.
|
||||||
|
timer.Reset(time.Duration(rnd.Float64() * float64(freq)))
|
||||||
|
|
||||||
r.Refresh()
|
r.Refresh()
|
||||||
case <-r.doneCh:
|
case <-r.doneCh:
|
||||||
|
@ -221,6 +221,11 @@ func IsSourceBuild() bool {
|
|||||||
return err != nil
|
return err != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsPCFTile returns if server is running in PCF
|
||||||
|
func IsPCFTile() bool {
|
||||||
|
return env.Get("MINIO_PCF_TILE_VERSION", "") != ""
|
||||||
|
}
|
||||||
|
|
||||||
// DO NOT CHANGE USER AGENT STYLE.
|
// DO NOT CHANGE USER AGENT STYLE.
|
||||||
// The style should be
|
// The style should be
|
||||||
//
|
//
|
||||||
@ -286,9 +291,11 @@ func getUserAgent(mode string) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pcfTileVersion := env.Get("MINIO_PCF_TILE_VERSION", "")
|
if IsPCFTile() {
|
||||||
if pcfTileVersion != "" {
|
pcfTileVersion := env.Get("MINIO_PCF_TILE_VERSION", "")
|
||||||
uaAppend(" MinIO/pcf-tile-", pcfTileVersion)
|
if pcfTileVersion != "" {
|
||||||
|
uaAppend(" MinIO/pcf-tile-", pcfTileVersion)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Join(userAgentParts, "")
|
return strings.Join(userAgentParts, "")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user