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:
Lukasz Szaszkiewicz
2024-01-10 17:15:01 +01:00
committed by Kubernetes Publisher
parent ca4f3a73f7
commit e8a81a3a43
3 changed files with 35 additions and 0 deletions

View File

@@ -146,3 +146,11 @@ func TestEnvVarFeatureGatesEnabledPanic(t *testing.T) {
target := newEnvVarFeatureGates(nil)
require.PanicsWithError(t, fmt.Errorf("feature %q is not registered in FeatureGates %q", "UnknownFeature", target.callSiteName).Error(), func() { target.Enabled("UnknownFeature") })
}
func TestHasAlreadyReadEnvVar(t *testing.T) {
target := newEnvVarFeatureGates(nil)
require.False(t, target.hasAlreadyReadEnvVar())
_ = target.getEnabledMapFromEnvVar()
require.True(t, target.hasAlreadyReadEnvVar())
}