Merge pull request #112306 from tkashem/v1beta3
add v1beta3 for Priority And Fairness
This commit is contained in:
@@ -31,7 +31,7 @@ import (
|
||||
"github.com/prometheus/common/expfmt"
|
||||
"github.com/prometheus/common/model"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/apiserver/pkg/util/apihelpers"
|
||||
@@ -256,8 +256,8 @@ var _ = SIGDescribe("API priority and fairness", func() {
|
||||
|
||||
// createPriorityLevel creates a priority level with the provided assured
|
||||
// concurrency share.
|
||||
func createPriorityLevel(f *framework.Framework, priorityLevelName string, assuredConcurrencyShares int32) (*flowcontrol.PriorityLevelConfiguration, func()) {
|
||||
createdPriorityLevel, err := f.ClientSet.FlowcontrolV1beta2().PriorityLevelConfigurations().Create(
|
||||
func createPriorityLevel(f *framework.Framework, priorityLevelName string, nominalConcurrencyShares int32) (*flowcontrol.PriorityLevelConfiguration, func()) {
|
||||
createdPriorityLevel, err := f.ClientSet.FlowcontrolV1beta3().PriorityLevelConfigurations().Create(
|
||||
context.TODO(),
|
||||
&flowcontrol.PriorityLevelConfiguration{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
@@ -266,7 +266,7 @@ func createPriorityLevel(f *framework.Framework, priorityLevelName string, assur
|
||||
Spec: flowcontrol.PriorityLevelConfigurationSpec{
|
||||
Type: flowcontrol.PriorityLevelEnablementLimited,
|
||||
Limited: &flowcontrol.LimitedPriorityLevelConfiguration{
|
||||
AssuredConcurrencyShares: assuredConcurrencyShares,
|
||||
NominalConcurrencyShares: nominalConcurrencyShares,
|
||||
LimitResponse: flowcontrol.LimitResponse{
|
||||
Type: flowcontrol.LimitResponseTypeReject,
|
||||
},
|
||||
@@ -276,7 +276,7 @@ func createPriorityLevel(f *framework.Framework, priorityLevelName string, assur
|
||||
metav1.CreateOptions{})
|
||||
framework.ExpectNoError(err)
|
||||
return createdPriorityLevel, func() {
|
||||
framework.ExpectNoError(f.ClientSet.FlowcontrolV1beta2().PriorityLevelConfigurations().Delete(context.TODO(), priorityLevelName, metav1.DeleteOptions{}))
|
||||
framework.ExpectNoError(f.ClientSet.FlowcontrolV1beta3().PriorityLevelConfigurations().Delete(context.TODO(), priorityLevelName, metav1.DeleteOptions{}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ func createFlowSchema(f *framework.Framework, flowSchemaName string, matchingPre
|
||||
})
|
||||
}
|
||||
|
||||
createdFlowSchema, err := f.ClientSet.FlowcontrolV1beta2().FlowSchemas().Create(
|
||||
createdFlowSchema, err := f.ClientSet.FlowcontrolV1beta3().FlowSchemas().Create(
|
||||
context.TODO(),
|
||||
&flowcontrol.FlowSchema{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
@@ -354,7 +354,7 @@ func createFlowSchema(f *framework.Framework, flowSchemaName string, matchingPre
|
||||
metav1.CreateOptions{})
|
||||
framework.ExpectNoError(err)
|
||||
return createdFlowSchema, func() {
|
||||
framework.ExpectNoError(f.ClientSet.FlowcontrolV1beta2().FlowSchemas().Delete(context.TODO(), flowSchemaName, metav1.DeleteOptions{}))
|
||||
framework.ExpectNoError(f.ClientSet.FlowcontrolV1beta3().FlowSchemas().Delete(context.TODO(), flowSchemaName, metav1.DeleteOptions{}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ func createFlowSchema(f *framework.Framework, flowSchemaName string, matchingPre
|
||||
// schema status, and (2) metrics. The function times out after 30 seconds.
|
||||
func waitForSteadyState(f *framework.Framework, flowSchemaName string, priorityLevelName string) {
|
||||
framework.ExpectNoError(wait.Poll(time.Second, 30*time.Second, func() (bool, error) {
|
||||
fs, err := f.ClientSet.FlowcontrolV1beta2().FlowSchemas().Get(context.TODO(), flowSchemaName, metav1.GetOptions{})
|
||||
fs, err := f.ClientSet.FlowcontrolV1beta3().FlowSchemas().Get(context.TODO(), flowSchemaName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@@ -124,9 +124,11 @@ var resetFieldsSpecData = map[schema.GroupVersionResource]string{
|
||||
gvr("flowcontrol.apiserver.k8s.io", "v1alpha1", "flowschemas"): `{"metadata": {"labels":{"a":"c"}}, "spec": {"priorityLevelConfiguration": {"name": "name2"}}}`,
|
||||
gvr("flowcontrol.apiserver.k8s.io", "v1beta1", "flowschemas"): `{"metadata": {"labels":{"a":"c"}}, "spec": {"priorityLevelConfiguration": {"name": "name2"}}}`,
|
||||
gvr("flowcontrol.apiserver.k8s.io", "v1beta2", "flowschemas"): `{"metadata": {"labels":{"a":"c"}}, "spec": {"priorityLevelConfiguration": {"name": "name2"}}}`,
|
||||
gvr("flowcontrol.apiserver.k8s.io", "v1beta3", "flowschemas"): `{"metadata": {"labels":{"a":"c"}}, "spec": {"priorityLevelConfiguration": {"name": "name2"}}}`,
|
||||
gvr("flowcontrol.apiserver.k8s.io", "v1alpha1", "prioritylevelconfigurations"): `{"metadata": {"labels":{"a":"c"}}, "spec": {"limited": {"assuredConcurrencyShares": 23}}}`,
|
||||
gvr("flowcontrol.apiserver.k8s.io", "v1beta1", "prioritylevelconfigurations"): `{"metadata": {"labels":{"a":"c"}}, "spec": {"limited": {"assuredConcurrencyShares": 23}}}`,
|
||||
gvr("flowcontrol.apiserver.k8s.io", "v1beta2", "prioritylevelconfigurations"): `{"metadata": {"labels":{"a":"c"}}, "spec": {"limited": {"assuredConcurrencyShares": 23}}}`,
|
||||
gvr("flowcontrol.apiserver.k8s.io", "v1beta3", "prioritylevelconfigurations"): `{"metadata": {"labels":{"a":"c"}}, "spec": {"limited": {"nominalConcurrencyShares": 23}}}`,
|
||||
gvr("extensions", "v1beta1", "ingresses"): `{"spec": {"backend": {"serviceName": "service2"}}}`,
|
||||
gvr("networking.k8s.io", "v1beta1", "ingresses"): `{"spec": {"backend": {"serviceName": "service2"}}}`,
|
||||
gvr("networking.k8s.io", "v1", "ingresses"): `{"spec": {"defaultBackend": {"service": {"name": "service2"}}}}`,
|
||||
|
@@ -28,7 +28,7 @@ import (
|
||||
"github.com/prometheus/common/expfmt"
|
||||
"github.com/prometheus/common/model"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
genericfeatures "k8s.io/apiserver/pkg/features"
|
||||
@@ -230,14 +230,14 @@ func getRequestCountOfPriorityLevel(c clientset.Interface) (map[string]int, map[
|
||||
}
|
||||
|
||||
func createPriorityLevelAndBindingFlowSchemaForUser(c clientset.Interface, username string, concurrencyShares, queuelength int) (*flowcontrol.PriorityLevelConfiguration, *flowcontrol.FlowSchema, error) {
|
||||
pl, err := c.FlowcontrolV1beta2().PriorityLevelConfigurations().Create(context.Background(), &flowcontrol.PriorityLevelConfiguration{
|
||||
pl, err := c.FlowcontrolV1beta3().PriorityLevelConfigurations().Create(context.Background(), &flowcontrol.PriorityLevelConfiguration{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: username,
|
||||
},
|
||||
Spec: flowcontrol.PriorityLevelConfigurationSpec{
|
||||
Type: flowcontrol.PriorityLevelEnablementLimited,
|
||||
Limited: &flowcontrol.LimitedPriorityLevelConfiguration{
|
||||
AssuredConcurrencyShares: int32(concurrencyShares),
|
||||
NominalConcurrencyShares: int32(concurrencyShares),
|
||||
LimitResponse: flowcontrol.LimitResponse{
|
||||
Type: flowcontrol.LimitResponseTypeQueue,
|
||||
Queuing: &flowcontrol.QueuingConfiguration{
|
||||
@@ -252,7 +252,7 @@ func createPriorityLevelAndBindingFlowSchemaForUser(c clientset.Interface, usern
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
fs, err := c.FlowcontrolV1beta2().FlowSchemas().Create(context.TODO(), &flowcontrol.FlowSchema{
|
||||
fs, err := c.FlowcontrolV1beta3().FlowSchemas().Create(context.TODO(), &flowcontrol.FlowSchema{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: username,
|
||||
},
|
||||
@@ -292,7 +292,7 @@ func createPriorityLevelAndBindingFlowSchemaForUser(c clientset.Interface, usern
|
||||
}
|
||||
|
||||
return pl, fs, wait.Poll(time.Second, timeout, func() (bool, error) {
|
||||
fs, err := c.FlowcontrolV1beta2().FlowSchemas().Get(context.TODO(), username, metav1.GetOptions{})
|
||||
fs, err := c.FlowcontrolV1beta3().FlowSchemas().Get(context.TODO(), username, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
genericfeatures "k8s.io/apiserver/pkg/features"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
utilfc "k8s.io/apiserver/pkg/util/flowcontrol"
|
||||
@@ -98,7 +98,7 @@ func (ft *fightTest) createMainInformer() {
|
||||
myConfig = rest.AddUserAgent(myConfig, "audience")
|
||||
myClientset := clientset.NewForConfigOrDie(myConfig)
|
||||
informerFactory := informers.NewSharedInformerFactory(myClientset, 0)
|
||||
inf := informerFactory.Flowcontrol().V1beta2().FlowSchemas().Informer()
|
||||
inf := informerFactory.Flowcontrol().V1beta3().FlowSchemas().Informer()
|
||||
inf.AddEventHandler(cache.ResourceEventHandlerFuncs{
|
||||
AddFunc: func(obj interface{}) {
|
||||
fs := obj.(*flowcontrol.FlowSchema)
|
||||
@@ -126,7 +126,7 @@ func (ft *fightTest) createController(invert bool, i int) {
|
||||
myConfig := rest.CopyConfig(ft.loopbackConfig)
|
||||
myConfig = rest.AddUserAgent(myConfig, fieldMgr)
|
||||
myClientset := clientset.NewForConfigOrDie(myConfig)
|
||||
fcIfc := myClientset.FlowcontrolV1beta2()
|
||||
fcIfc := myClientset.FlowcontrolV1beta3()
|
||||
informerFactory := informers.NewSharedInformerFactory(myClientset, 0)
|
||||
foundToDangling := func(found bool) bool { return !found }
|
||||
if invert {
|
||||
|
@@ -22,14 +22,14 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
machinerytypes "k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
fcboot "k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
|
||||
genericfeatures "k8s.io/apiserver/pkg/features"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
flowcontrolapply "k8s.io/client-go/applyconfigurations/flowcontrol/v1beta2"
|
||||
flowcontrolapply "k8s.io/client-go/applyconfigurations/flowcontrol/v1beta3"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||
"k8s.io/klog/v2"
|
||||
@@ -49,7 +49,7 @@ func TestConditionIsolation(t *testing.T) {
|
||||
|
||||
fsOrig := fcboot.SuggestedFlowSchemas[0]
|
||||
t.Logf("Testing Status Condition isolation in FlowSchema %q", fsOrig.Name)
|
||||
fsClient := loopbackClient.FlowcontrolV1beta2().FlowSchemas()
|
||||
fsClient := loopbackClient.FlowcontrolV1beta3().FlowSchemas()
|
||||
var dangleOrig *flowcontrol.FlowSchemaCondition
|
||||
|
||||
wait.PollUntil(time.Second, func() (bool, error) {
|
||||
|
@@ -136,6 +136,7 @@ func TestServerSidePrint(t *testing.T) {
|
||||
{Group: "flowcontrol.apiserver.k8s.io", Version: "v1alpha1"},
|
||||
{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta1"},
|
||||
{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta2"},
|
||||
{Group: "flowcontrol.apiserver.k8s.io", Version: "v1beta3"},
|
||||
{Group: "internal.apiserver.k8s.io", Version: "v1alpha1"},
|
||||
},
|
||||
[]schema.GroupVersionResource{},
|
||||
|
@@ -272,7 +272,7 @@ func GetEtcdStorageDataForNamespace(namespace string) map[schema.GroupVersionRes
|
||||
gvr("flowcontrol.apiserver.k8s.io", "v1alpha1", "flowschemas"): {
|
||||
Stub: `{"metadata": {"name": "va1"}, "spec": {"priorityLevelConfiguration": {"name": "name1"}}}`,
|
||||
ExpectedEtcdPath: "/registry/flowschemas/va1",
|
||||
ExpectedGVK: gvkP("flowcontrol.apiserver.k8s.io", "v1beta1", "FlowSchema"),
|
||||
ExpectedGVK: gvkP("flowcontrol.apiserver.k8s.io", "v1beta2", "FlowSchema"),
|
||||
},
|
||||
// --
|
||||
|
||||
@@ -280,7 +280,7 @@ func GetEtcdStorageDataForNamespace(namespace string) map[schema.GroupVersionRes
|
||||
gvr("flowcontrol.apiserver.k8s.io", "v1alpha1", "prioritylevelconfigurations"): {
|
||||
Stub: `{"metadata": {"name": "conf1"}, "spec": {"type": "Limited", "limited": {"assuredConcurrencyShares":3, "limitResponse": {"type": "Reject"}}}}`,
|
||||
ExpectedEtcdPath: "/registry/prioritylevelconfigurations/conf1",
|
||||
ExpectedGVK: gvkP("flowcontrol.apiserver.k8s.io", "v1beta1", "PriorityLevelConfiguration"),
|
||||
ExpectedGVK: gvkP("flowcontrol.apiserver.k8s.io", "v1beta2", "PriorityLevelConfiguration"),
|
||||
},
|
||||
// --
|
||||
|
||||
@@ -288,6 +288,7 @@ func GetEtcdStorageDataForNamespace(namespace string) map[schema.GroupVersionRes
|
||||
gvr("flowcontrol.apiserver.k8s.io", "v1beta1", "flowschemas"): {
|
||||
Stub: `{"metadata": {"name": "va2"}, "spec": {"priorityLevelConfiguration": {"name": "name1"}}}`,
|
||||
ExpectedEtcdPath: "/registry/flowschemas/va2",
|
||||
ExpectedGVK: gvkP("flowcontrol.apiserver.k8s.io", "v1beta2", "FlowSchema"),
|
||||
},
|
||||
// --
|
||||
|
||||
@@ -295,6 +296,7 @@ func GetEtcdStorageDataForNamespace(namespace string) map[schema.GroupVersionRes
|
||||
gvr("flowcontrol.apiserver.k8s.io", "v1beta1", "prioritylevelconfigurations"): {
|
||||
Stub: `{"metadata": {"name": "conf2"}, "spec": {"type": "Limited", "limited": {"assuredConcurrencyShares":3, "limitResponse": {"type": "Reject"}}}}`,
|
||||
ExpectedEtcdPath: "/registry/prioritylevelconfigurations/conf2",
|
||||
ExpectedGVK: gvkP("flowcontrol.apiserver.k8s.io", "v1beta2", "PriorityLevelConfiguration"),
|
||||
},
|
||||
// --
|
||||
|
||||
@@ -302,7 +304,6 @@ func GetEtcdStorageDataForNamespace(namespace string) map[schema.GroupVersionRes
|
||||
gvr("flowcontrol.apiserver.k8s.io", "v1beta2", "flowschemas"): {
|
||||
Stub: `{"metadata": {"name": "fs-1"}, "spec": {"priorityLevelConfiguration": {"name": "name1"}}}`,
|
||||
ExpectedEtcdPath: "/registry/flowschemas/fs-1",
|
||||
ExpectedGVK: gvkP("flowcontrol.apiserver.k8s.io", "v1beta1", "FlowSchema"),
|
||||
},
|
||||
// --
|
||||
|
||||
@@ -310,7 +311,22 @@ func GetEtcdStorageDataForNamespace(namespace string) map[schema.GroupVersionRes
|
||||
gvr("flowcontrol.apiserver.k8s.io", "v1beta2", "prioritylevelconfigurations"): {
|
||||
Stub: `{"metadata": {"name": "conf3"}, "spec": {"type": "Limited", "limited": {"assuredConcurrencyShares":3, "limitResponse": {"type": "Reject"}}}}`,
|
||||
ExpectedEtcdPath: "/registry/prioritylevelconfigurations/conf3",
|
||||
ExpectedGVK: gvkP("flowcontrol.apiserver.k8s.io", "v1beta1", "PriorityLevelConfiguration"),
|
||||
},
|
||||
// --
|
||||
|
||||
// k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta3
|
||||
gvr("flowcontrol.apiserver.k8s.io", "v1beta3", "flowschemas"): {
|
||||
Stub: `{"metadata": {"name": "fs-2"}, "spec": {"priorityLevelConfiguration": {"name": "name1"}}}`,
|
||||
ExpectedEtcdPath: "/registry/flowschemas/fs-2",
|
||||
ExpectedGVK: gvkP("flowcontrol.apiserver.k8s.io", "v1beta2", "FlowSchema"),
|
||||
},
|
||||
// --
|
||||
|
||||
// k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta3
|
||||
gvr("flowcontrol.apiserver.k8s.io", "v1beta3", "prioritylevelconfigurations"): {
|
||||
Stub: `{"metadata": {"name": "conf4"}, "spec": {"type": "Limited", "limited": {"nominalConcurrencyShares":3, "limitResponse": {"type": "Reject"}}}}`,
|
||||
ExpectedEtcdPath: "/registry/prioritylevelconfigurations/conf4",
|
||||
ExpectedGVK: gvkP("flowcontrol.apiserver.k8s.io", "v1beta2", "PriorityLevelConfiguration"),
|
||||
},
|
||||
// --
|
||||
|
||||
|
Reference in New Issue
Block a user