From 01ee49045e81452a5afb19b4067fea30c877ba6f Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 18 Mar 2022 18:21:09 -0700 Subject: [PATCH] fix: handle race in server setup global CI/CD variable (#14579) --- cmd/common-main.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/common-main.go b/cmd/common-main.go index 68f76bc96..243af20ee 100644 --- a/cmd/common-main.go +++ b/cmd/common-main.go @@ -100,12 +100,16 @@ func init() { PersistOnFailure: false, } + globalIsCICD = env.Get("MINIO_CI_CD", "") != "" || env.Get("CI", "") != "" + + containers := IsKubernetes() || IsDocker() || IsBOSH() || IsDCOS() || IsPCFTile() + // Call to refresh will refresh names in cache. If you pass true, it will also // remove cached names not looked up since the last call to Refresh. It is a good idea // to call this method on a regular interval. go func() { var t *time.Ticker - if IsKubernetes() || IsDocker() || IsBOSH() || IsDCOS() || IsPCFTile() { + if containers { t = time.NewTicker(1 * time.Minute) } else { t = time.NewTicker(10 * time.Minute) @@ -664,8 +668,6 @@ func handleCommonEnvVars() { globalRootDiskThreshold = size } - globalIsCICD = env.Get("MINIO_CI_CD", "") != "" || env.Get("CI", "") != "" - domains := env.Get(config.EnvDomain, "") if len(domains) != 0 { for _, domainName := range strings.Split(domains, config.ValueSeparator) {