mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-04 08:35:10 +00:00
Fix data race on config.clientConfig
config.clientConfig can have an unlocked read and a locked write Kubernetes-commit: 609da52afaf6395d738f529c78daadc05e619f68
This commit is contained in:
committed by
Kubernetes Publisher
parent
3ab27431ef
commit
afa880fea1
@@ -60,27 +60,22 @@ func NewInteractiveDeferredLoadingClientConfig(loader ClientConfigLoader, overri
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (config *DeferredLoadingClientConfig) createClientConfig() (ClientConfig, error) {
|
func (config *DeferredLoadingClientConfig) createClientConfig() (ClientConfig, error) {
|
||||||
if config.clientConfig == nil {
|
config.loadingLock.Lock()
|
||||||
config.loadingLock.Lock()
|
defer config.loadingLock.Unlock()
|
||||||
defer config.loadingLock.Unlock()
|
|
||||||
|
|
||||||
if config.clientConfig == nil {
|
if config.clientConfig != nil {
|
||||||
mergedConfig, err := config.loader.Load()
|
return config.clientConfig, nil
|
||||||
if err != nil {
|
}
|
||||||
return nil, err
|
mergedConfig, err := config.loader.Load()
|
||||||
}
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
var mergedClientConfig ClientConfig
|
|
||||||
if config.fallbackReader != nil {
|
|
||||||
mergedClientConfig = NewInteractiveClientConfig(*mergedConfig, config.overrides.CurrentContext, config.overrides, config.fallbackReader, config.loader)
|
|
||||||
} else {
|
|
||||||
mergedClientConfig = NewNonInteractiveClientConfig(*mergedConfig, config.overrides.CurrentContext, config.overrides, config.loader)
|
|
||||||
}
|
|
||||||
|
|
||||||
config.clientConfig = mergedClientConfig
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.fallbackReader != nil {
|
||||||
|
config.clientConfig = NewInteractiveClientConfig(*mergedConfig, config.overrides.CurrentContext, config.overrides, config.fallbackReader, config.loader)
|
||||||
|
} else {
|
||||||
|
config.clientConfig = NewNonInteractiveClientConfig(*mergedConfig, config.overrides.CurrentContext, config.overrides, config.loader)
|
||||||
|
}
|
||||||
return config.clientConfig, nil
|
return config.clientConfig, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user