mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-08 10:29:25 +00:00
client-go/features: warn when ordering initialization issue
ReplaceFeatureGates logs a warning when the default env var implementation has been already used. Such a situation indicates a potential ordering issue and usually is unwanted. Kubernetes-commit: 04bbd3481f70825eea54b4b154a04d2496dcf652
This commit is contained in:
committed by
Kubernetes Publisher
parent
ca4f3a73f7
commit
e8a81a3a43
@@ -77,6 +77,10 @@ type envVarFeatureGates struct {
|
||||
// enabled holds a map[Feature]bool
|
||||
// with values explicitly set via env var
|
||||
enabled atomic.Value
|
||||
|
||||
// readEnvVars holds the boolean value which
|
||||
// indicates whether readEnvVarsOnce has been called.
|
||||
readEnvVars atomic.Bool
|
||||
}
|
||||
|
||||
// Enabled returns true if the key is enabled. If the key is not known, this call will panic.
|
||||
@@ -116,6 +120,7 @@ func (f *envVarFeatureGates) getEnabledMapFromEnvVar() map[Feature]bool {
|
||||
}
|
||||
}
|
||||
f.enabled.Store(featureGatesState)
|
||||
f.readEnvVars.Store(true)
|
||||
|
||||
for feature, featureSpec := range f.known {
|
||||
if featureState, ok := featureGatesState[feature]; ok {
|
||||
@@ -127,3 +132,7 @@ func (f *envVarFeatureGates) getEnabledMapFromEnvVar() map[Feature]bool {
|
||||
})
|
||||
return f.enabled.Load().(map[Feature]bool)
|
||||
}
|
||||
|
||||
func (f *envVarFeatureGates) hasAlreadyReadEnvVar() bool {
|
||||
return f.readEnvVars.Load()
|
||||
}
|
||||
|
Reference in New Issue
Block a user