diff --git a/cmd/callhome.go b/cmd/callhome.go index 599a83c9f..501b7b671 100644 --- a/cmd/callhome.go +++ b/cmd/callhome.go @@ -157,15 +157,11 @@ func performCallhome(ctx context.Context) { } const ( - healthURL = "https://subnet.min.io/api/health/upload" - healthURLDev = "http://localhost:9000/api/health/upload" + subnetHealthPath = "/api/health/upload" ) func sendHealthInfo(ctx context.Context, healthInfo madmin.HealthInfo) error { - url := healthURL - if globalIsCICD { - url = healthURLDev - } + url := globalSubnetConfig.BaseURL + subnetHealthPath filename := fmt.Sprintf("health_%s.json.gz", UTCNow().Format("20060102150405")) url += "?filename=" + filename diff --git a/cmd/config-current.go b/cmd/config-current.go index c3b9fdc3d..d2c241c8e 100644 --- a/cmd/config-current.go +++ b/cmd/config-current.go @@ -631,7 +631,7 @@ func applyDynamicConfigForSubSys(ctx context.Context, objAPI ObjectLayer, s conf if err != nil { logger.LogIf(ctx, fmt.Errorf("Unable to parse subnet configuration: %w", err)) } else { - globalSubnetConfig.Update(subnetConfig) + globalSubnetConfig.Update(subnetConfig, globalIsCICD) globalSubnetConfig.ApplyEnv() // update environment settings for Console UI } case config.CallhomeSubSys: diff --git a/cmd/license-update.go b/cmd/license-update.go index b97b6c445..a70fbcc5c 100644 --- a/cmd/license-update.go +++ b/cmd/license-update.go @@ -29,8 +29,7 @@ import ( const ( licUpdateCycle = 24 * time.Hour * 30 - licRenewURL = "https://subnet.min.io/api/cluster/renew-license" - licRenewURLDev = "http://localhost:9000/api/cluster/renew-license" + licRenewPath = "/api/cluster/renew-license" ) // initlicenseUpdateJob start the periodic license update job in the background. @@ -82,10 +81,7 @@ func licenceUpdaterLoop(ctx context.Context, objAPI ObjectLayer) { func performLicenseUpdate(ctx context.Context, objectAPI ObjectLayer) { // the subnet license renewal api renews the license only // if required e.g. when it is expiring soon - url := licRenewURL - if globalIsCICD { - url = licRenewURLDev - } + url := globalSubnetConfig.BaseURL + licRenewPath resp, err := globalSubnetConfig.Post(url, nil) if err != nil { diff --git a/internal/config/subnet/config.go b/internal/config/subnet/config.go index 8962fc549..55e0a9bb7 100644 --- a/internal/config/subnet/config.go +++ b/internal/config/subnet/config.go @@ -29,6 +29,11 @@ import ( xnet "github.com/minio/pkg/v2/net" ) +const ( + baseURL = "https://subnet.min.io" + baseURLDev = "http://localhost:9000" +) + // DefaultKVS - default KV config for subnet settings var DefaultKVS = config.KVS{ config.KV{ @@ -58,6 +63,9 @@ type Config struct { // Transport configured with proxy_url if set optionally. transport http.RoundTripper + + // The subnet base URL + BaseURL string } var configLock sync.RWMutex @@ -84,10 +92,11 @@ func (c *Config) ApplyEnv() { if c.Proxy != "" { os.Setenv("CONSOLE_SUBNET_PROXY", c.Proxy) } + os.Setenv("CONSOLE_SUBNET_URL", c.BaseURL) } // Update - in-place update with new license and registration information. -func (c *Config) Update(ncfg Config) { +func (c *Config) Update(ncfg Config, isDevEnv bool) { configLock.Lock() defer configLock.Unlock() @@ -95,6 +104,14 @@ func (c *Config) Update(ncfg Config) { c.APIKey = ncfg.APIKey c.Proxy = ncfg.Proxy c.transport = ncfg.transport + c.BaseURL = baseURL + + if isDevEnv { + c.BaseURL = os.Getenv("_MINIO_SUBNET_URL") + if c.BaseURL == "" { + c.BaseURL = baseURLDev + } + } } // LookupConfig - lookup config and override with valid environment settings if any.