mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Merge pull request #84275 from liggitt/beta-gate-runtimeclass-informers
Feature-gate RuntimeClass informer starts
This commit is contained in:
		@@ -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)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user