Merge pull request #129933 from serathius/deprecate-namespace-index

Disable StorageNamespaceIndex feature gate when BtreeWatchCache enabled and deprecate it
This commit is contained in:
Kubernetes Prow Robot 2025-02-11 06:29:59 -08:00 committed by GitHub
commit 7a8a4c201a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 2 deletions

View File

@ -664,6 +664,7 @@ const (
// owner: @ahutsunshine
//
// Allows namespace indexer for namespace scope resources in apiserver cache to accelerate list operations.
// Superseded by BtreeWatchCache.
StorageNamespaceIndex featuregate.Feature = "StorageNamespaceIndex"
// owner: @nilekhc

View File

@ -678,6 +678,7 @@ var defaultVersionedKubernetesFeatureGates = map[featuregate.Feature]featuregate
StorageNamespaceIndex: {
{Version: version.MustParse("1.30"), Default: true, PreRelease: featuregate.Beta},
{Version: version.MustParse("1.33"), Default: true, PreRelease: featuregate.Deprecated},
},
ServiceAccountNodeAudienceRestriction: {

View File

@ -40,6 +40,7 @@ import (
utilnet "k8s.io/apimachinery/pkg/util/net"
utilvalidation "k8s.io/apimachinery/pkg/util/validation"
"k8s.io/apimachinery/pkg/util/validation/field"
apiserverfeatures "k8s.io/apiserver/pkg/features"
"k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/storage"
"k8s.io/apiserver/pkg/storage/names"
@ -379,7 +380,7 @@ func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
// MatchPod returns a generic matcher for a given label and field selector.
func MatchPod(label labels.Selector, field fields.Selector) storage.SelectionPredicate {
var indexFields = []string{"spec.nodeName"}
if utilfeature.DefaultFeatureGate.Enabled(features.StorageNamespaceIndex) {
if utilfeature.DefaultFeatureGate.Enabled(features.StorageNamespaceIndex) && !utilfeature.DefaultFeatureGate.Enabled(apiserverfeatures.BtreeWatchCache) {
indexFields = append(indexFields, "metadata.namespace")
}
return storage.SelectionPredicate{
@ -418,7 +419,7 @@ func Indexers() *cache.Indexers {
var indexers = cache.Indexers{
storage.FieldIndex("spec.nodeName"): NodeNameIndexFunc,
}
if utilfeature.DefaultFeatureGate.Enabled(features.StorageNamespaceIndex) {
if utilfeature.DefaultFeatureGate.Enabled(features.StorageNamespaceIndex) && !utilfeature.DefaultFeatureGate.Enabled(apiserverfeatures.BtreeWatchCache) {
indexers[storage.FieldIndex("metadata.namespace")] = NamespaceIndexFunc
}
return &indexers

View File

@ -1302,6 +1302,10 @@
lockToDefault: false
preRelease: Beta
version: "1.30"
- default: true
lockToDefault: false
preRelease: Deprecated
version: "1.33"
- name: StorageVersionAPI
versionedSpecs:
- default: false