apiserver: enable apf v1 API
This commit is contained in:
		| @@ -297,6 +297,7 @@ var apiVersionPriorities = map[schema.GroupVersion]priority{ | ||||
| 	{Group: "node.k8s.io", Version: "v1beta1"}:                   {group: 16300, version: 9}, | ||||
| 	{Group: "discovery.k8s.io", Version: "v1"}:                   {group: 16200, version: 15}, | ||||
| 	{Group: "discovery.k8s.io", Version: "v1beta1"}:              {group: 16200, version: 12}, | ||||
| 	{Group: "flowcontrol.apiserver.k8s.io", Version: "v1"}:       {group: 16100, version: 21}, | ||||
| 	{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta3"}:  {group: 16100, version: 18}, | ||||
| 	{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta2"}:  {group: 16100, version: 15}, | ||||
| 	{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta1"}:  {group: 16100, version: 12}, | ||||
|   | ||||
| @@ -115,6 +115,7 @@ scheduling.k8s.io/v1 \ | ||||
| storage.k8s.io/v1beta1 \ | ||||
| storage.k8s.io/v1 \ | ||||
| storage.k8s.io/v1alpha1 \ | ||||
| flowcontrol.apiserver.k8s.io/v1 \ | ||||
| flowcontrol.apiserver.k8s.io/v1beta1 \ | ||||
| flowcontrol.apiserver.k8s.io/v1beta2 \ | ||||
| flowcontrol.apiserver.k8s.io/v1beta3 \ | ||||
|   | ||||
| @@ -23,6 +23,7 @@ import ( | ||||
| 	utilruntime "k8s.io/apimachinery/pkg/util/runtime" | ||||
| 	"k8s.io/kubernetes/pkg/api/legacyscheme" | ||||
| 	"k8s.io/kubernetes/pkg/apis/flowcontrol" | ||||
| 	flowcontrolv1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1" | ||||
| 	flowcontrolv1beta1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta1" | ||||
| 	flowcontrolv1beta2 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta2" | ||||
| 	flowcontrolv1beta3 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta3" | ||||
| @@ -38,6 +39,11 @@ func Install(scheme *runtime.Scheme) { | ||||
| 	utilruntime.Must(flowcontrolv1beta1.AddToScheme(scheme)) | ||||
| 	utilruntime.Must(flowcontrolv1beta2.AddToScheme(scheme)) | ||||
| 	utilruntime.Must(flowcontrolv1beta3.AddToScheme(scheme)) | ||||
| 	utilruntime.Must(scheme.SetVersionPriority(flowcontrolv1beta3.SchemeGroupVersion, flowcontrolv1beta2.SchemeGroupVersion, | ||||
| 		flowcontrolv1beta1.SchemeGroupVersion)) | ||||
| 	utilruntime.Must(flowcontrolv1.AddToScheme(scheme)) | ||||
|  | ||||
| 	// TODO(#121119): This controls serialization order, for 1.29, we continue | ||||
| 	//  to use v1beta3 as the serialization version because vN-1 understands that | ||||
| 	//  level. In 1.30, we should set the serialization version to v1. | ||||
| 	utilruntime.Must(scheme.SetVersionPriority(flowcontrolv1beta3.SchemeGroupVersion, flowcontrolv1.SchemeGroupVersion, | ||||
| 		flowcontrolv1beta2.SchemeGroupVersion, flowcontrolv1beta1.SchemeGroupVersion)) | ||||
| } | ||||
|   | ||||
| @@ -54,9 +54,9 @@ func validateAPIPriorityAndFairness(options *Options) []error { | ||||
| 	if utilfeature.DefaultFeatureGate.Enabled(genericfeatures.APIPriorityAndFairness) && options.Features.EnablePriorityAndFairness { | ||||
| 		// If none of the following runtime config options are specified, | ||||
| 		// APF is assumed to be turned on. The internal APF controller uses | ||||
| 		// v1beta3 so it should be enabled. | ||||
| 		// v1 so it should be enabled. | ||||
| 		enabledAPIString := options.APIEnablement.RuntimeConfig.String() | ||||
| 		testConfigs := []string{"flowcontrol.apiserver.k8s.io/v1beta3", "api/beta", "api/all"} // in the order of precedence | ||||
| 		testConfigs := []string{"flowcontrol.apiserver.k8s.io/v1", "api/all"} // in the order of precedence | ||||
| 		for _, testConfig := range testConfigs { | ||||
| 			if strings.Contains(enabledAPIString, fmt.Sprintf("%s=false", testConfig)) { | ||||
| 				return []error{fmt.Errorf("--runtime-config=%s=false conflicts with --enable-priority-and-fairness=true and --feature-gates=APIPriorityAndFairness=true", testConfig)} | ||||
|   | ||||
| @@ -44,7 +44,7 @@ func TestValidateAPIPriorityAndFairness(t *testing.T) { | ||||
| 		}, | ||||
| 		{ | ||||
| 			runtimeConfig:    "api/beta=false", | ||||
| 			errShouldContain: conflict, | ||||
| 			errShouldContain: "", | ||||
| 		}, | ||||
| 		{ | ||||
| 			runtimeConfig:    "flowcontrol.apiserver.k8s.io/v1beta1=false", | ||||
| @@ -56,12 +56,20 @@ func TestValidateAPIPriorityAndFairness(t *testing.T) { | ||||
| 		}, | ||||
| 		{ | ||||
| 			runtimeConfig:    "flowcontrol.apiserver.k8s.io/v1beta3=false", | ||||
| 			errShouldContain: conflict, | ||||
| 			errShouldContain: "", | ||||
| 		}, | ||||
| 		{ | ||||
| 			runtimeConfig:    "flowcontrol.apiserver.k8s.io/v1beta3=true", | ||||
| 			errShouldContain: "", | ||||
| 		}, | ||||
| 		{ | ||||
| 			runtimeConfig:    "flowcontrol.apiserver.k8s.io/v1=true", | ||||
| 			errShouldContain: "", | ||||
| 		}, | ||||
| 		{ | ||||
| 			runtimeConfig:    "flowcontrol.apiserver.k8s.io/v1=false", | ||||
| 			errShouldContain: conflict, | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	for _, test := range tests { | ||||
|   | ||||
| @@ -75,6 +75,7 @@ import ( | ||||
| 	"k8s.io/component-helpers/apimachinery/lease" | ||||
| 	"k8s.io/klog/v2" | ||||
| 	api "k8s.io/kubernetes/pkg/apis/core" | ||||
| 	flowcontrolv1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1" | ||||
| 	flowcontrolv1beta1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta1" | ||||
| 	flowcontrolv1beta2 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta2" | ||||
| 	flowcontrolv1beta3 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta3" | ||||
| @@ -735,6 +736,7 @@ var ( | ||||
| 		rbacv1.SchemeGroupVersion, | ||||
| 		storageapiv1.SchemeGroupVersion, | ||||
| 		schedulingapiv1.SchemeGroupVersion, | ||||
| 		flowcontrolv1.SchemeGroupVersion, | ||||
| 	} | ||||
|  | ||||
| 	// legacyBetaEnabledByDefaultResources is the list of beta resources we enable.  You may only add to this list | ||||
|   | ||||
| @@ -37,7 +37,7 @@ import ( | ||||
| 	apiv1 "k8s.io/api/core/v1" | ||||
| 	discoveryv1beta1 "k8s.io/api/discovery/v1beta1" | ||||
| 	extensionsv1beta1 "k8s.io/api/extensions/v1beta1" | ||||
| 	flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" | ||||
| 	flowcontrolv1 "k8s.io/api/flowcontrol/v1" | ||||
| 	networkingv1alpha1 "k8s.io/api/networking/v1alpha1" | ||||
| 	rbacv1beta1 "k8s.io/api/rbac/v1beta1" | ||||
| 	resourcev1alpha2 "k8s.io/api/resource/v1alpha2" | ||||
| @@ -569,9 +569,9 @@ func AddHandlers(h printers.PrintHandler) { | ||||
|  | ||||
| 	flowSchemaColumnDefinitions := []metav1.TableColumnDefinition{ | ||||
| 		{Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]}, | ||||
| 		{Name: "PriorityLevel", Type: "string", Description: flowcontrolv1beta3.PriorityLevelConfigurationReference{}.SwaggerDoc()["name"]}, | ||||
| 		{Name: "MatchingPrecedence", Type: "string", Description: flowcontrolv1beta3.FlowSchemaSpec{}.SwaggerDoc()["matchingPrecedence"]}, | ||||
| 		{Name: "DistinguisherMethod", Type: "string", Description: flowcontrolv1beta3.FlowSchemaSpec{}.SwaggerDoc()["distinguisherMethod"]}, | ||||
| 		{Name: "PriorityLevel", Type: "string", Description: flowcontrolv1.PriorityLevelConfigurationReference{}.SwaggerDoc()["name"]}, | ||||
| 		{Name: "MatchingPrecedence", Type: "string", Description: flowcontrolv1.FlowSchemaSpec{}.SwaggerDoc()["matchingPrecedence"]}, | ||||
| 		{Name: "DistinguisherMethod", Type: "string", Description: flowcontrolv1.FlowSchemaSpec{}.SwaggerDoc()["distinguisherMethod"]}, | ||||
| 		{Name: "Age", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["creationTimestamp"]}, | ||||
| 		{Name: "MissingPL", Type: "string", Description: "references a broken or non-existent PriorityLevelConfiguration"}, | ||||
| 	} | ||||
| @@ -580,11 +580,11 @@ func AddHandlers(h printers.PrintHandler) { | ||||
|  | ||||
| 	priorityLevelColumnDefinitions := []metav1.TableColumnDefinition{ | ||||
| 		{Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]}, | ||||
| 		{Name: "Type", Type: "string", Description: flowcontrolv1beta3.PriorityLevelConfigurationSpec{}.SwaggerDoc()["type"]}, | ||||
| 		{Name: "NominalConcurrencyShares", Type: "string", Description: flowcontrolv1beta3.LimitedPriorityLevelConfiguration{}.SwaggerDoc()["nominalConcurrencyShares"]}, | ||||
| 		{Name: "Queues", Type: "string", Description: flowcontrolv1beta3.QueuingConfiguration{}.SwaggerDoc()["queues"]}, | ||||
| 		{Name: "HandSize", Type: "string", Description: flowcontrolv1beta3.QueuingConfiguration{}.SwaggerDoc()["handSize"]}, | ||||
| 		{Name: "QueueLengthLimit", Type: "string", Description: flowcontrolv1beta3.QueuingConfiguration{}.SwaggerDoc()["queueLengthLimit"]}, | ||||
| 		{Name: "Type", Type: "string", Description: flowcontrolv1.PriorityLevelConfigurationSpec{}.SwaggerDoc()["type"]}, | ||||
| 		{Name: "NominalConcurrencyShares", Type: "string", Description: flowcontrolv1.LimitedPriorityLevelConfiguration{}.SwaggerDoc()["nominalConcurrencyShares"]}, | ||||
| 		{Name: "Queues", Type: "string", Description: flowcontrolv1.QueuingConfiguration{}.SwaggerDoc()["queues"]}, | ||||
| 		{Name: "HandSize", Type: "string", Description: flowcontrolv1.QueuingConfiguration{}.SwaggerDoc()["handSize"]}, | ||||
| 		{Name: "QueueLengthLimit", Type: "string", Description: flowcontrolv1.QueuingConfiguration{}.SwaggerDoc()["queueLengthLimit"]}, | ||||
| 		{Name: "Age", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["creationTimestamp"]}, | ||||
| 	} | ||||
| 	_ = h.TableHandler(priorityLevelColumnDefinitions, printPriorityLevelConfiguration) | ||||
|   | ||||
| @@ -56,6 +56,9 @@ func (flowSchemaStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.S | ||||
| 		"flowcontrol.apiserver.k8s.io/v1beta3": fieldpath.NewSet( | ||||
| 			fieldpath.MakePathOrDie("status"), | ||||
| 		), | ||||
| 		"flowcontrol.apiserver.k8s.io/v1": fieldpath.NewSet( | ||||
| 			fieldpath.MakePathOrDie("status"), | ||||
| 		), | ||||
| 	} | ||||
|  | ||||
| 	return fields | ||||
| @@ -136,6 +139,10 @@ func (flowSchemaStatusStrategy) GetResetFields() map[fieldpath.APIVersion]*field | ||||
| 			fieldpath.MakePathOrDie("metadata"), | ||||
| 			fieldpath.MakePathOrDie("spec"), | ||||
| 		), | ||||
| 		"flowcontrol.apiserver.k8s.io/v1": fieldpath.NewSet( | ||||
| 			fieldpath.MakePathOrDie("metadata"), | ||||
| 			fieldpath.MakePathOrDie("spec"), | ||||
| 		), | ||||
| 	} | ||||
|  | ||||
| 	return fields | ||||
|   | ||||
| @@ -58,6 +58,9 @@ func (priorityLevelConfigurationStrategy) GetResetFields() map[fieldpath.APIVers | ||||
| 		"flowcontrol.apiserver.k8s.io/v1beta3": fieldpath.NewSet( | ||||
| 			fieldpath.MakePathOrDie("status"), | ||||
| 		), | ||||
| 		"flowcontrol.apiserver.k8s.io/v1": fieldpath.NewSet( | ||||
| 			fieldpath.MakePathOrDie("status"), | ||||
| 		), | ||||
| 	} | ||||
|  | ||||
| 	return fields | ||||
| @@ -138,6 +141,10 @@ func (priorityLevelConfigurationStatusStrategy) GetResetFields() map[fieldpath.A | ||||
| 			fieldpath.MakePathOrDie("spec"), | ||||
| 			fieldpath.MakePathOrDie("metadata"), | ||||
| 		), | ||||
| 		"flowcontrol.apiserver.k8s.io/v1": fieldpath.NewSet( | ||||
| 			fieldpath.MakePathOrDie("spec"), | ||||
| 			fieldpath.MakePathOrDie("metadata"), | ||||
| 		), | ||||
| 	} | ||||
|  | ||||
| 	return fields | ||||
|   | ||||
| @@ -36,6 +36,7 @@ import ( | ||||
| 	"k8s.io/klog/v2" | ||||
| 	"k8s.io/kubernetes/pkg/api/legacyscheme" | ||||
| 	"k8s.io/kubernetes/pkg/apis/flowcontrol" | ||||
| 	flowcontrolapisv1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1" | ||||
| 	flowcontrolapisv1beta1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta1" | ||||
| 	flowcontrolapisv1beta2 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta2" | ||||
| 	flowcontrolapisv1beta3 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta3" | ||||
| @@ -76,6 +77,12 @@ func (p RESTStorageProvider) NewRESTStorage(apiResourceConfigSource serverstorag | ||||
| 		apiGroupInfo.VersionedResourcesStorageMap[flowcontrolapisv1beta3.SchemeGroupVersion.Version] = storageMap | ||||
| 	} | ||||
|  | ||||
| 	if storageMap, err := p.storage(apiResourceConfigSource, restOptionsGetter, flowcontrolapisv1.SchemeGroupVersion); err != nil { | ||||
| 		return genericapiserver.APIGroupInfo{}, err | ||||
| 	} else if len(storageMap) > 0 { | ||||
| 		apiGroupInfo.VersionedResourcesStorageMap[flowcontrolapisv1.SchemeGroupVersion.Version] = storageMap | ||||
| 	} | ||||
|  | ||||
| 	return apiGroupInfo, nil | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -137,6 +137,7 @@ func TestServerSidePrint(t *testing.T) { | ||||
| 			{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta1"}, | ||||
| 			{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta2"}, | ||||
| 			{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta3"}, | ||||
| 			{Group: "flowcontrol.apiserver.k8s.io", Version: "v1"}, | ||||
| 			{Group: "internal.apiserver.k8s.io", Version: "v1alpha1"}, | ||||
| 		}, | ||||
| 		[]schema.GroupVersionResource{}, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Abu Kashem
					Abu Kashem