mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
fix: initialize config once per startup (#9851)
This commit is contained in:
parent
3ba4804d6c
commit
f5e1b3d09e
@ -311,8 +311,6 @@ func validateConfig(s config.Config) error {
|
||||
globalNotificationSys.ConfiguredTargetIDs())
|
||||
}
|
||||
|
||||
var syncEtcdOnce sync.Once
|
||||
|
||||
func lookupConfigs(s config.Config) {
|
||||
ctx := GlobalContext
|
||||
|
||||
@ -335,7 +333,6 @@ func lookupConfigs(s config.Config) {
|
||||
}
|
||||
|
||||
if etcdCfg.Enabled {
|
||||
syncEtcdOnce.Do(func() {
|
||||
globalEtcdClient, err = etcd.New(etcdCfg)
|
||||
if err != nil {
|
||||
if globalIsGateway {
|
||||
@ -344,16 +341,6 @@ func lookupConfigs(s config.Config) {
|
||||
logger.LogIf(ctx, fmt.Errorf("Unable to initialize etcd config: %w", err))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Bucket federation is 'true' only when IAM assets are not namespaced
|
||||
// per tenant and all tenants interested in globally available users
|
||||
// if namespace was requested such as specifying etcdPathPrefix then
|
||||
// we assume that users are interested in global bucket support
|
||||
// but not federation.
|
||||
globalBucketFederation = etcdCfg.PathPrefix == "" && etcdCfg.Enabled
|
||||
|
||||
if len(globalDomainNames) != 0 && !globalDomainIPs.IsEmpty() && globalEtcdClient != nil {
|
||||
globalDNSConfig, err = dns.NewCoreDNS(etcdCfg.Config,
|
||||
dns.DomainNames(globalDomainNames),
|
||||
@ -362,10 +349,22 @@ func lookupConfigs(s config.Config) {
|
||||
dns.CoreDNSPath(etcdCfg.CoreDNSPath),
|
||||
)
|
||||
if err != nil {
|
||||
if globalIsGateway {
|
||||
logger.FatalIf(err, "Unable to initialize DNS config")
|
||||
} else {
|
||||
logger.LogIf(ctx, fmt.Errorf("Unable to initialize DNS config for %s: %w",
|
||||
globalDomainNames, err))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bucket federation is 'true' only when IAM assets are not namespaced
|
||||
// per tenant and all tenants interested in globally available users
|
||||
// if namespace was requested such as specifying etcdPathPrefix then
|
||||
// we assume that users are interested in global bucket support
|
||||
// but not federation.
|
||||
globalBucketFederation = etcdCfg.PathPrefix == "" && etcdCfg.Enabled
|
||||
|
||||
globalServerRegion, err = config.LookupRegion(s[config.RegionSubSys][config.Default])
|
||||
if err != nil {
|
||||
@ -571,6 +570,8 @@ func newServerConfig() config.Config {
|
||||
return config.New()
|
||||
}
|
||||
|
||||
var lookupConfigOnce sync.Once
|
||||
|
||||
// newSrvConfig - initialize a new server config, saves env parameters if
|
||||
// found, otherwise use default parameters
|
||||
func newSrvConfig(objAPI ObjectLayer) error {
|
||||
@ -578,7 +579,9 @@ func newSrvConfig(objAPI ObjectLayer) error {
|
||||
srvCfg := newServerConfig()
|
||||
|
||||
// Override any values from ENVs.
|
||||
lookupConfigOnce.Do(func() {
|
||||
lookupConfigs(srvCfg)
|
||||
})
|
||||
|
||||
// hold the mutex lock before a new config is assigned.
|
||||
globalServerConfigMu.Lock()
|
||||
@ -602,7 +605,9 @@ func loadConfig(objAPI ObjectLayer) error {
|
||||
}
|
||||
|
||||
// Override any values from ENVs.
|
||||
lookupConfigOnce.Do(func() {
|
||||
lookupConfigs(srvCfg)
|
||||
})
|
||||
|
||||
// hold the mutex lock before a new config is assigned.
|
||||
globalServerConfigMu.Lock()
|
||||
|
@ -162,7 +162,9 @@ func StartGateway(ctx *cli.Context, gw Gateway) {
|
||||
srvCfg := newServerConfig()
|
||||
|
||||
// Override any values from ENVs.
|
||||
lookupConfigOnce.Do(func() {
|
||||
lookupConfigs(srvCfg)
|
||||
})
|
||||
|
||||
// hold the mutex lock before a new config is assigned.
|
||||
globalServerConfigMu.Lock()
|
||||
|
Loading…
Reference in New Issue
Block a user