mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Fix data race on config.clientConfig
config.clientConfig can have an unlocked read and a locked write
This commit is contained in:
parent
1fa20301a0
commit
609da52afa
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user