updated vendor

This commit is contained in:
2026-06-16 08:02:19 +02:00
parent 2f7f99d3f0
commit 77299d0c64
1283 changed files with 67302 additions and 208958 deletions
+29 -6
View File
@@ -121,12 +121,28 @@ func (f *envVarFeatureGates) Enabled(key Feature) bool {
// Features set via this method take precedence over
// the features set via environment variables.
func (f *envVarFeatureGates) Set(featureName Feature, featureValue bool) error {
return f.set(featureName, featureValue, false)
}
// SetForTesting sets the given feature to the given value. This method
// bypasses the check for locked features and should only be used for
// testing purposes.
//
// Features set via this method take precedence over
// the features set via environment variables.
func (f *envVarFeatureGates) SetForTesting(featureName Feature, featureValue bool) error {
return f.set(featureName, featureValue, true)
}
func (f *envVarFeatureGates) set(featureName Feature, featureValue bool, allowChangingLockedFeatures bool) error {
feature, ok := f.known[featureName]
if !ok {
return fmt.Errorf("feature %q is not registered in FeatureGates %q", featureName, f.callSiteName)
}
if feature.LockToDefault && feature.Default != featureValue {
return fmt.Errorf("cannot set feature gate %q to %v, feature is locked to %v", featureName, featureValue, feature.Default)
if !allowChangingLockedFeatures {
if feature.LockToDefault && feature.Default != featureValue {
return fmt.Errorf("cannot set feature gate %q to %v, feature is locked to %v", featureName, featureValue, feature.Default)
}
}
f.lockEnabledViaSetMethod.Lock()
@@ -141,6 +157,13 @@ func (f *envVarFeatureGates) Set(featureName Feature, featureValue bool) error {
// read from the corresponding environmental variable.
func (f *envVarFeatureGates) getEnabledMapFromEnvVar() map[Feature]bool {
f.readEnvVarsOnce.Do(func() {
// This code does not really support contextual logging. Making it do so has huge
// implications for several call chains because the Enabled call then needs
// a `*WithLogger` variant. This does not matter in Kubernetes itself because
// all Kubernetes components replace the feature gate implementation used
// by client-go, but it might matter elsewhere.
logger := klog.Background()
featureGatesState := map[Feature]bool{}
for feature, featureSpec := range f.known {
featureState, featureStateSet := os.LookupEnv(fmt.Sprintf("KUBE_FEATURE_%s", feature))
@@ -150,10 +173,10 @@ func (f *envVarFeatureGates) getEnabledMapFromEnvVar() map[Feature]bool {
boolVal, boolErr := strconv.ParseBool(featureState)
switch {
case boolErr != nil:
utilruntime.HandleError(fmt.Errorf("cannot set feature gate %q to %q, due to %v", feature, featureState, boolErr))
utilruntime.HandleErrorWithLogger(logger, boolErr, "Could not set feature gate", "feature", feature, "desiredState", featureState)
case featureSpec.LockToDefault:
if boolVal != featureSpec.Default {
utilruntime.HandleError(fmt.Errorf("cannot set feature gate %q to %q, feature is locked to %v", feature, featureState, featureSpec.Default))
utilruntime.HandleErrorWithLogger(logger, nil, "Could not set feature gate, feature is locked", "feature", feature, "desiredState", featureState, "lockedState", featureSpec.Default)
break
}
featureGatesState[feature] = featureSpec.Default
@@ -166,10 +189,10 @@ func (f *envVarFeatureGates) getEnabledMapFromEnvVar() map[Feature]bool {
for feature, featureSpec := range f.known {
if featureState, ok := featureGatesState[feature]; ok {
klog.V(1).InfoS("Feature gate updated state", "feature", feature, "enabled", featureState)
logger.V(1).Info("Feature gate updated state", "feature", feature, "enabled", featureState)
continue
}
klog.V(1).InfoS("Feature gate default state", "feature", feature, "enabled", featureSpec.Default)
logger.V(1).Info("Feature gate default state", "feature", feature, "enabled", featureSpec.Default)
}
})
return f.enabledViaEnvVar.Load().(map[Feature]bool)
+4 -2
View File
@@ -17,7 +17,7 @@ limitations under the License.
package features
import (
"errors"
"context"
"sync/atomic"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
@@ -127,7 +127,9 @@ func AddVersionedFeaturesToExistingFeatureGates(registry VersionedRegistry) erro
// clientgofeaturegate.ReplaceFeatureGates(utilfeature.DefaultMutableFeatureGate)
func ReplaceFeatureGates(newFeatureGates Gates) {
if replaceFeatureGatesWithWarningIndicator(newFeatureGates) {
utilruntime.HandleError(errors.New("the default feature gates implementation has already been used and now it's being overwritten. This might lead to unexpected behaviour. Check your initialization order"))
// TODO (?): A new API would be needed where callers pass in a context or logger.
// Probably not worth it.
utilruntime.HandleErrorWithContext(context.TODO(), nil, "The default feature gates implementation has already been used and now it's being overwritten. This might lead to unexpected behaviour. Check your initialization order.")
}
}
+40
View File
@@ -31,6 +31,20 @@ import (
// of code conflicts because changes are more likely to be scattered
// across the file.
const (
// owner: @michaelasp
// beta: v1.36
//
// Allow the client to process events atomically rather than a stream of
// events for items popped off the FIFO.
AtomicFIFO Feature = "AtomicFIFO"
// owner: @yt2985
// beta: 1.36
//
// If enabled, allows clients to gracefully handle Certificate Authority (CA)
// rotations without dropping connections or requiring a restart.
ClientsAllowCARotation Feature = "ClientsAllowCARotation"
// owner: @benluddy
// kep: https://kep.k8s.io/4222
// alpha: 1.32
@@ -41,6 +55,13 @@ const (
// "application/json" or "application/apply-patch+yaml", respectively.
ClientsAllowCBOR Feature = "ClientsAllowCBOR"
// owner: @enj
// beta: v1.36
//
// If enabled, the client-go TLS transport cache uses weak pointers to allow
// garbage collection of unused transports, preventing unbounded cache growth.
ClientsAllowTLSCacheGC Feature = "ClientsAllowTLSCacheGC"
// owner: @benluddy
// kep: https://kep.k8s.io/4222
// alpha: 1.32
@@ -69,6 +90,12 @@ const (
// GA: v1.35
InformerResourceVersion Feature = "InformerResourceVersion"
// owner: @michaelasp
// beta: v1.36
//
// Allow the FIFO to unlock while processing items to allow other goroutines to add items to the queue.
UnlockWhileProcessingFIFO Feature = "UnlockWhileProcessingFIFO"
// owner: @p0lyn0mial
// beta: v1.30
//
@@ -82,14 +109,24 @@ const (
// After registering with the binary, the features are, by default, controllable using environment variables.
// For more details, please see envVarFeatureGates implementation.
var defaultVersionedKubernetesFeatureGates = map[Feature]VersionedSpecs{
AtomicFIFO: {
{Version: version.MustParse("1.36"), Default: true, PreRelease: Beta},
},
ClientsAllowCARotation: {
{Version: version.MustParse("1.36"), Default: true, PreRelease: Beta},
},
ClientsAllowCBOR: {
{Version: version.MustParse("1.32"), Default: false, PreRelease: Alpha},
},
ClientsAllowTLSCacheGC: {
{Version: version.MustParse("1.36"), Default: true, PreRelease: Beta},
},
ClientsPreferCBOR: {
{Version: version.MustParse("1.32"), Default: false, PreRelease: Alpha},
},
InOrderInformers: {
{Version: version.MustParse("1.33"), Default: true, PreRelease: Beta},
{Version: version.MustParse("1.36"), Default: true, PreRelease: GA, LockToDefault: true},
},
InOrderInformersBatchProcess: {
{Version: version.MustParse("1.35"), Default: true, PreRelease: Beta},
@@ -98,6 +135,9 @@ var defaultVersionedKubernetesFeatureGates = map[Feature]VersionedSpecs{
{Version: version.MustParse("1.30"), Default: false, PreRelease: Alpha},
{Version: version.MustParse("1.35"), Default: true, PreRelease: GA},
},
UnlockWhileProcessingFIFO: {
{Version: version.MustParse("1.36"), Default: true, PreRelease: Beta},
},
WatchListClient: {
{Version: version.MustParse("1.30"), Default: false, PreRelease: Beta},
{Version: version.MustParse("1.35"), Default: true, PreRelease: Beta},