Merge pull request #84275 from liggitt/beta-gate-runtimeclass-informers

Feature-gate RuntimeClass informer starts
This commit is contained in:
Kubernetes Prow Robot 2019-10-28 17:48:42 -07:00 committed by GitHub
commit 0c88c4893f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View File

@ -55,8 +55,6 @@ import (
"k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle"
mutatingwebhook "k8s.io/apiserver/pkg/admission/plugin/webhook/mutating"
validatingwebhook "k8s.io/apiserver/pkg/admission/plugin/webhook/validating"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/kubernetes/pkg/features"
)
// AllOrderedPlugins is the list of all the plugins in order.
@ -143,11 +141,8 @@ func DefaultOffAdmissionPlugins() sets.String {
storageobjectinuseprotection.PluginName, //StorageObjectInUseProtection
podpriority.PluginName, //PodPriority
nodetaint.PluginName, //TaintNodesByCondition
runtimeclass.PluginName, //RuntimeClass, gates internally on the feature
)
if utilfeature.DefaultFeatureGate.Enabled(features.RuntimeClass) {
defaultOnPlugins.Insert(runtimeclass.PluginName) //RuntimeClass
}
return sets.NewString(AllOrderedPlugins...).Difference(defaultOnPlugins)
}

View File

@ -67,6 +67,9 @@ var _ genericadmissioninitailizer.WantsExternalKubeInformerFactory = &RuntimeCla
// SetExternalKubeInformerFactory implements the WantsExternalKubeInformerFactory interface.
func (r *RuntimeClass) SetExternalKubeInformerFactory(f informers.SharedInformerFactory) {
if !utilfeature.DefaultFeatureGate.Enabled(features.RuntimeClass) {
return
}
runtimeClassInformer := f.Node().V1beta1().RuntimeClasses()
r.SetReadyFunc(runtimeClassInformer.Informer().HasSynced)
r.runtimeClassLister = runtimeClassInformer.Lister()
@ -74,6 +77,9 @@ func (r *RuntimeClass) SetExternalKubeInformerFactory(f informers.SharedInformer
// ValidateInitialization implements the WantsExternalKubeInformerFactory interface.
func (r *RuntimeClass) ValidateInitialization() error {
if !utilfeature.DefaultFeatureGate.Enabled(features.RuntimeClass) {
return nil
}
if r.runtimeClassLister == nil {
return fmt.Errorf("missing RuntimeClass lister")
}
@ -110,6 +116,10 @@ func (r *RuntimeClass) Admit(ctx context.Context, attributes admission.Attribute
// Validate makes sure that pod adhere's to RuntimeClass's definition
func (r *RuntimeClass) Validate(ctx context.Context, attributes admission.Attributes, o admission.ObjectInterfaces) error {
if !utilfeature.DefaultFeatureGate.Enabled(features.RuntimeClass) {
return nil
}
// Ignore all calls to subresources or resources other than pods.
if shouldIgnore(attributes) {
return nil