apiserver: apf controller, bootstrap, tests should use flowcontrol v1 API

This commit is contained in:
Abu Kashem 2023-10-11 09:20:41 -04:00
parent 25aebca8d5
commit 17bda3c3e0
No known key found for this signature in database
GPG Key ID: E5ECC1124B5F9C68
28 changed files with 214 additions and 214 deletions

View File

@ -17,7 +17,7 @@ limitations under the License.
package internalbootstrap package internalbootstrap
import ( import (
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" flowcontrolv1 "k8s.io/api/flowcontrol/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap" "k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
"k8s.io/kubernetes/pkg/apis/flowcontrol" "k8s.io/kubernetes/pkg/apis/flowcontrol"
@ -46,7 +46,7 @@ func NewAPFScheme() *runtime.Scheme {
return scheme return scheme
} }
func internalizeFSes(exts []*flowcontrolv1beta3.FlowSchema) map[string]*flowcontrol.FlowSchema { func internalizeFSes(exts []*flowcontrolv1.FlowSchema) map[string]*flowcontrol.FlowSchema {
ans := make(map[string]*flowcontrol.FlowSchema, len(exts)) ans := make(map[string]*flowcontrol.FlowSchema, len(exts))
scheme := NewAPFScheme() scheme := NewAPFScheme()
for _, ext := range exts { for _, ext := range exts {
@ -59,7 +59,7 @@ func internalizeFSes(exts []*flowcontrolv1beta3.FlowSchema) map[string]*flowcont
return ans return ans
} }
func internalizePLs(exts []*flowcontrolv1beta3.PriorityLevelConfiguration) map[string]*flowcontrol.PriorityLevelConfiguration { func internalizePLs(exts []*flowcontrolv1.PriorityLevelConfiguration) map[string]*flowcontrol.PriorityLevelConfiguration {
ans := make(map[string]*flowcontrol.PriorityLevelConfiguration, len(exts)) ans := make(map[string]*flowcontrol.PriorityLevelConfiguration, len(exts))
scheme := NewAPFScheme() scheme := NewAPFScheme()
for _, ext := range exts { for _, ext := range exts {

View File

@ -22,7 +22,7 @@ import (
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
flowcontrol "k8s.io/api/flowcontrol/v1beta3" flowcontrol "k8s.io/api/flowcontrol/v1"
apiequality "k8s.io/apimachinery/pkg/api/equality" apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap" "k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
) )

View File

@ -17,25 +17,25 @@ limitations under the License.
package ensurer package ensurer
import ( import (
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" flowcontrolv1 "k8s.io/api/flowcontrol/v1"
"k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/api/equality"
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3" flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1"
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta3" flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1"
flowcontrolapisv1beta3 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta3" flowcontrolapisv1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1"
) )
func NewFlowSchemaOps(client flowcontrolclient.FlowSchemaInterface, cache flowcontrollisters.FlowSchemaLister) ObjectOps[*flowcontrolv1beta3.FlowSchema] { func NewFlowSchemaOps(client flowcontrolclient.FlowSchemaInterface, cache flowcontrollisters.FlowSchemaLister) ObjectOps[*flowcontrolv1.FlowSchema] {
return NewObjectOps[*flowcontrolv1beta3.FlowSchema](client, cache, (*flowcontrolv1beta3.FlowSchema).DeepCopy, flowSchemaReplaceSpec, flowSchemaSpecEqual) return NewObjectOps[*flowcontrolv1.FlowSchema](client, cache, (*flowcontrolv1.FlowSchema).DeepCopy, flowSchemaReplaceSpec, flowSchemaSpecEqual)
} }
func flowSchemaReplaceSpec(into, from *flowcontrolv1beta3.FlowSchema) *flowcontrolv1beta3.FlowSchema { func flowSchemaReplaceSpec(into, from *flowcontrolv1.FlowSchema) *flowcontrolv1.FlowSchema {
copy := into.DeepCopy() copy := into.DeepCopy()
copy.Spec = *from.Spec.DeepCopy() copy.Spec = *from.Spec.DeepCopy()
return copy return copy
} }
func flowSchemaSpecEqual(expected, actual *flowcontrolv1beta3.FlowSchema) bool { func flowSchemaSpecEqual(expected, actual *flowcontrolv1.FlowSchema) bool {
copiedExpectedSpec := expected.Spec.DeepCopy() copiedExpectedSpec := expected.Spec.DeepCopy()
flowcontrolapisv1beta3.SetDefaults_FlowSchemaSpec(copiedExpectedSpec) flowcontrolapisv1.SetDefaults_FlowSchemaSpec(copiedExpectedSpec)
return equality.Semantic.DeepEqual(copiedExpectedSpec, &actual.Spec) return equality.Semantic.DeepEqual(copiedExpectedSpec, &actual.Spec)
} }

View File

@ -21,15 +21,15 @@ import (
"reflect" "reflect"
"testing" "testing"
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" flowcontrolv1 "k8s.io/api/flowcontrol/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap" "k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
"k8s.io/client-go/kubernetes/fake" "k8s.io/client-go/kubernetes/fake"
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta3" flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1"
toolscache "k8s.io/client-go/tools/cache" toolscache "k8s.io/client-go/tools/cache"
"k8s.io/klog/v2" "k8s.io/klog/v2"
flowcontrolapisv1beta3 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta3" flowcontrolapisv1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -42,29 +42,29 @@ func init() {
func TestEnsureFlowSchema(t *testing.T) { func TestEnsureFlowSchema(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
strategy func() EnsureStrategy[*flowcontrolv1beta3.FlowSchema] strategy func() EnsureStrategy[*flowcontrolv1.FlowSchema]
current *flowcontrolv1beta3.FlowSchema current *flowcontrolv1.FlowSchema
bootstrap *flowcontrolv1beta3.FlowSchema bootstrap *flowcontrolv1.FlowSchema
expected *flowcontrolv1beta3.FlowSchema expected *flowcontrolv1.FlowSchema
}{ }{
// for suggested configurations // for suggested configurations
{ {
name: "suggested flow schema does not exist - the object should always be re-created", name: "suggested flow schema does not exist - the object should always be re-created",
strategy: NewSuggestedEnsureStrategy[*flowcontrolv1beta3.FlowSchema], strategy: NewSuggestedEnsureStrategy[*flowcontrolv1.FlowSchema],
bootstrap: newFlowSchema("fs1", "pl1", 100).Object(), bootstrap: newFlowSchema("fs1", "pl1", 100).Object(),
current: nil, current: nil,
expected: newFlowSchema("fs1", "pl1", 100).Object(), expected: newFlowSchema("fs1", "pl1", 100).Object(),
}, },
{ {
name: "suggested flow schema exists, auto update is enabled, spec does not match - current object should be updated", name: "suggested flow schema exists, auto update is enabled, spec does not match - current object should be updated",
strategy: NewSuggestedEnsureStrategy[*flowcontrolv1beta3.FlowSchema], strategy: NewSuggestedEnsureStrategy[*flowcontrolv1.FlowSchema],
bootstrap: newFlowSchema("fs1", "pl1", 100).Object(), bootstrap: newFlowSchema("fs1", "pl1", 100).Object(),
current: newFlowSchema("fs1", "pl1", 200).WithAutoUpdateAnnotation("true").Object(), current: newFlowSchema("fs1", "pl1", 200).WithAutoUpdateAnnotation("true").Object(),
expected: newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(), expected: newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
}, },
{ {
name: "suggested flow schema exists, auto update is disabled, spec does not match - current object should not be updated", name: "suggested flow schema exists, auto update is disabled, spec does not match - current object should not be updated",
strategy: NewSuggestedEnsureStrategy[*flowcontrolv1beta3.FlowSchema], strategy: NewSuggestedEnsureStrategy[*flowcontrolv1.FlowSchema],
bootstrap: newFlowSchema("fs1", "pl1", 100).Object(), bootstrap: newFlowSchema("fs1", "pl1", 100).Object(),
current: newFlowSchema("fs1", "pl1", 200).WithAutoUpdateAnnotation("false").Object(), current: newFlowSchema("fs1", "pl1", 200).WithAutoUpdateAnnotation("false").Object(),
expected: newFlowSchema("fs1", "pl1", 200).WithAutoUpdateAnnotation("false").Object(), expected: newFlowSchema("fs1", "pl1", 200).WithAutoUpdateAnnotation("false").Object(),
@ -73,21 +73,21 @@ func TestEnsureFlowSchema(t *testing.T) {
// for mandatory configurations // for mandatory configurations
{ {
name: "mandatory flow schema does not exist - new object should be created", name: "mandatory flow schema does not exist - new object should be created",
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1beta3.FlowSchema], strategy: NewMandatoryEnsureStrategy[*flowcontrolv1.FlowSchema],
bootstrap: newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(), bootstrap: newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
current: nil, current: nil,
expected: newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(), expected: newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
}, },
{ {
name: "mandatory flow schema exists, annotation is missing - annotation should be added", name: "mandatory flow schema exists, annotation is missing - annotation should be added",
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1beta3.FlowSchema], strategy: NewMandatoryEnsureStrategy[*flowcontrolv1.FlowSchema],
bootstrap: newFlowSchema("fs1", "pl1", 100).Object(), bootstrap: newFlowSchema("fs1", "pl1", 100).Object(),
current: newFlowSchema("fs1", "pl1", 100).Object(), current: newFlowSchema("fs1", "pl1", 100).Object(),
expected: newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(), expected: newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
}, },
{ {
name: "mandatory flow schema exists, auto update is disabled, spec does not match - current object should be updated", name: "mandatory flow schema exists, auto update is disabled, spec does not match - current object should be updated",
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1beta3.FlowSchema], strategy: NewMandatoryEnsureStrategy[*flowcontrolv1.FlowSchema],
bootstrap: newFlowSchema("fs1", "pl1", 100).Object(), bootstrap: newFlowSchema("fs1", "pl1", 100).Object(),
current: newFlowSchema("fs1", "pl1", 200).WithAutoUpdateAnnotation("false").Object(), current: newFlowSchema("fs1", "pl1", 200).WithAutoUpdateAnnotation("false").Object(),
expected: newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(), expected: newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
@ -96,7 +96,7 @@ func TestEnsureFlowSchema(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
client := fake.NewSimpleClientset().FlowcontrolV1beta3().FlowSchemas() client := fake.NewSimpleClientset().FlowcontrolV1().FlowSchemas()
indexer := toolscache.NewIndexer(toolscache.MetaNamespaceKeyFunc, toolscache.Indexers{}) indexer := toolscache.NewIndexer(toolscache.MetaNamespaceKeyFunc, toolscache.Indexers{})
if test.current != nil { if test.current != nil {
client.Create(context.TODO(), test.current, metav1.CreateOptions{}) client.Create(context.TODO(), test.current, metav1.CreateOptions{})
@ -104,7 +104,7 @@ func TestEnsureFlowSchema(t *testing.T) {
} }
ops := NewFlowSchemaOps(client, flowcontrollisters.NewFlowSchemaLister(indexer)) ops := NewFlowSchemaOps(client, flowcontrollisters.NewFlowSchemaLister(indexer))
boots := []*flowcontrolv1beta3.FlowSchema{test.bootstrap} boots := []*flowcontrolv1.FlowSchema{test.bootstrap}
strategy := test.strategy() strategy := test.strategy()
err := EnsureConfigurations(context.Background(), ops, boots, strategy) err := EnsureConfigurations(context.Background(), ops, boots, strategy)
if err != nil { if err != nil {
@ -131,9 +131,9 @@ func TestEnsureFlowSchema(t *testing.T) {
func TestSuggestedFSEnsureStrategy_ShouldUpdate(t *testing.T) { func TestSuggestedFSEnsureStrategy_ShouldUpdate(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
current *flowcontrolv1beta3.FlowSchema current *flowcontrolv1.FlowSchema
bootstrap *flowcontrolv1beta3.FlowSchema bootstrap *flowcontrolv1.FlowSchema
newObjectExpected *flowcontrolv1beta3.FlowSchema newObjectExpected *flowcontrolv1.FlowSchema
}{ }{
{ {
name: "auto update is enabled, first generation, spec does not match - spec update expected", name: "auto update is enabled, first generation, spec does not match - spec update expected",
@ -212,7 +212,7 @@ func TestSuggestedFSEnsureStrategy_ShouldUpdate(t *testing.T) {
ops := NewFlowSchemaOps(nil, nil) ops := NewFlowSchemaOps(nil, nil)
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
strategy := NewSuggestedEnsureStrategy[*flowcontrolv1beta3.FlowSchema]() strategy := NewSuggestedEnsureStrategy[*flowcontrolv1.FlowSchema]()
updatableGot, updateGot, err := strategy.ReviseIfNeeded(ops, test.current, test.bootstrap) updatableGot, updateGot, err := strategy.ReviseIfNeeded(ops, test.current, test.bootstrap)
if err != nil { if err != nil {
t.Errorf("Expected no error, but got: %v", err) t.Errorf("Expected no error, but got: %v", err)
@ -238,23 +238,23 @@ func TestSuggestedFSEnsureStrategy_ShouldUpdate(t *testing.T) {
} }
func TestFlowSchemaSpecChanged(t *testing.T) { func TestFlowSchemaSpecChanged(t *testing.T) {
fs1 := &flowcontrolv1beta3.FlowSchema{ fs1 := &flowcontrolv1.FlowSchema{
Spec: flowcontrolv1beta3.FlowSchemaSpec{}, Spec: flowcontrolv1.FlowSchemaSpec{},
} }
fs2 := &flowcontrolv1beta3.FlowSchema{ fs2 := &flowcontrolv1.FlowSchema{
Spec: flowcontrolv1beta3.FlowSchemaSpec{ Spec: flowcontrolv1.FlowSchemaSpec{
MatchingPrecedence: 1, MatchingPrecedence: 1,
}, },
} }
fs1Defaulted := &flowcontrolv1beta3.FlowSchema{ fs1Defaulted := &flowcontrolv1.FlowSchema{
Spec: flowcontrolv1beta3.FlowSchemaSpec{ Spec: flowcontrolv1.FlowSchemaSpec{
MatchingPrecedence: flowcontrolapisv1beta3.FlowSchemaDefaultMatchingPrecedence, MatchingPrecedence: flowcontrolapisv1.FlowSchemaDefaultMatchingPrecedence,
}, },
} }
testCases := []struct { testCases := []struct {
name string name string
expected *flowcontrolv1beta3.FlowSchema expected *flowcontrolv1.FlowSchema
actual *flowcontrolv1beta3.FlowSchema actual *flowcontrolv1.FlowSchema
specChanged bool specChanged bool
}{ }{
{ {
@ -287,7 +287,7 @@ func TestFlowSchemaSpecChanged(t *testing.T) {
func TestRemoveFlowSchema(t *testing.T) { func TestRemoveFlowSchema(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
current *flowcontrolv1beta3.FlowSchema current *flowcontrolv1.FlowSchema
bootstrapName string bootstrapName string
removeExpected bool removeExpected bool
}{ }{
@ -336,7 +336,7 @@ func TestRemoveFlowSchema(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
client := fake.NewSimpleClientset().FlowcontrolV1beta3().FlowSchemas() client := fake.NewSimpleClientset().FlowcontrolV1().FlowSchemas()
indexer := toolscache.NewIndexer(toolscache.MetaNamespaceKeyFunc, toolscache.Indexers{}) indexer := toolscache.NewIndexer(toolscache.MetaNamespaceKeyFunc, toolscache.Indexers{})
if test.current != nil { if test.current != nil {
client.Create(context.TODO(), test.current, metav1.CreateOptions{}) client.Create(context.TODO(), test.current, metav1.CreateOptions{})
@ -344,7 +344,7 @@ func TestRemoveFlowSchema(t *testing.T) {
} }
bootFS := newFlowSchema(test.bootstrapName, "pl", 100).Object() bootFS := newFlowSchema(test.bootstrapName, "pl", 100).Object()
ops := NewFlowSchemaOps(client, flowcontrollisters.NewFlowSchemaLister(indexer)) ops := NewFlowSchemaOps(client, flowcontrollisters.NewFlowSchemaLister(indexer))
boots := []*flowcontrolv1beta3.FlowSchema{bootFS} boots := []*flowcontrolv1.FlowSchema{bootFS}
err := RemoveUnwantedObjects(context.Background(), ops, boots) err := RemoveUnwantedObjects(context.Background(), ops, boots)
if err != nil { if err != nil {
@ -370,17 +370,17 @@ func TestRemoveFlowSchema(t *testing.T) {
} }
type fsBuilder struct { type fsBuilder struct {
object *flowcontrolv1beta3.FlowSchema object *flowcontrolv1.FlowSchema
} }
func newFlowSchema(name, plName string, matchingPrecedence int32) *fsBuilder { func newFlowSchema(name, plName string, matchingPrecedence int32) *fsBuilder {
return &fsBuilder{ return &fsBuilder{
object: &flowcontrolv1beta3.FlowSchema{ object: &flowcontrolv1.FlowSchema{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: name, Name: name,
}, },
Spec: flowcontrolv1beta3.FlowSchemaSpec{ Spec: flowcontrolv1.FlowSchemaSpec{
PriorityLevelConfiguration: flowcontrolv1beta3.PriorityLevelConfigurationReference{ PriorityLevelConfiguration: flowcontrolv1.PriorityLevelConfigurationReference{
Name: plName, Name: plName,
}, },
MatchingPrecedence: matchingPrecedence, MatchingPrecedence: matchingPrecedence,
@ -389,7 +389,7 @@ func newFlowSchema(name, plName string, matchingPrecedence int32) *fsBuilder {
} }
} }
func (b *fsBuilder) Object() *flowcontrolv1beta3.FlowSchema { func (b *fsBuilder) Object() *flowcontrolv1.FlowSchema {
return b.object return b.object
} }
@ -408,5 +408,5 @@ func setAnnotation(accessor metav1.Object, value string) {
accessor.SetAnnotations(map[string]string{}) accessor.SetAnnotations(map[string]string{})
} }
accessor.GetAnnotations()[flowcontrolv1beta3.AutoUpdateAnnotationKey] = value accessor.GetAnnotations()[flowcontrolv1.AutoUpdateAnnotationKey] = value
} }

View File

@ -17,28 +17,28 @@ limitations under the License.
package ensurer package ensurer
import ( import (
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" flowcontrolv1 "k8s.io/api/flowcontrol/v1"
"k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/api/equality"
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3" flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1"
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta3" flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1"
flowcontrolapisv1beta3 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta3" flowcontrolapisv1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1"
) )
func NewPriorityLevelConfigurationOps(client flowcontrolclient.PriorityLevelConfigurationInterface, lister flowcontrollisters.PriorityLevelConfigurationLister) ObjectOps[*flowcontrolv1beta3.PriorityLevelConfiguration] { func NewPriorityLevelConfigurationOps(client flowcontrolclient.PriorityLevelConfigurationInterface, lister flowcontrollisters.PriorityLevelConfigurationLister) ObjectOps[*flowcontrolv1.PriorityLevelConfiguration] {
return NewObjectOps[*flowcontrolv1beta3.PriorityLevelConfiguration](client, lister, (*flowcontrolv1beta3.PriorityLevelConfiguration).DeepCopy, return NewObjectOps[*flowcontrolv1.PriorityLevelConfiguration](client, lister, (*flowcontrolv1.PriorityLevelConfiguration).DeepCopy,
plcReplaceSpec, plcSpecEqualish) plcReplaceSpec, plcSpecEqualish)
} }
func plcReplaceSpec(into, from *flowcontrolv1beta3.PriorityLevelConfiguration) *flowcontrolv1beta3.PriorityLevelConfiguration { func plcReplaceSpec(into, from *flowcontrolv1.PriorityLevelConfiguration) *flowcontrolv1.PriorityLevelConfiguration {
copy := into.DeepCopy() copy := into.DeepCopy()
copy.Spec = *from.Spec.DeepCopy() copy.Spec = *from.Spec.DeepCopy()
return copy return copy
} }
func plcSpecEqualish(expected, actual *flowcontrolv1beta3.PriorityLevelConfiguration) bool { func plcSpecEqualish(expected, actual *flowcontrolv1.PriorityLevelConfiguration) bool {
copiedExpected := expected.DeepCopy() copiedExpected := expected.DeepCopy()
flowcontrolapisv1beta3.SetObjectDefaults_PriorityLevelConfiguration(copiedExpected) flowcontrolapisv1.SetObjectDefaults_PriorityLevelConfiguration(copiedExpected)
if expected.Name == flowcontrolv1beta3.PriorityLevelConfigurationNameExempt { if expected.Name == flowcontrolv1.PriorityLevelConfigurationNameExempt {
if actual.Spec.Exempt == nil { if actual.Spec.Exempt == nil {
return false return false
} }

View File

@ -21,23 +21,23 @@ import (
"reflect" "reflect"
"testing" "testing"
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" flowcontrolv1 "k8s.io/api/flowcontrol/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap" "k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
"k8s.io/client-go/kubernetes/fake" "k8s.io/client-go/kubernetes/fake"
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta3" flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1"
toolscache "k8s.io/client-go/tools/cache" toolscache "k8s.io/client-go/tools/cache"
flowcontrolapisv1beta3 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta3" flowcontrolapisv1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1"
"k8s.io/utils/pointer" "k8s.io/utils/pointer"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
) )
func TestEnsurePriorityLevel(t *testing.T) { func TestEnsurePriorityLevel(t *testing.T) {
validExemptPL := func() *flowcontrolv1beta3.PriorityLevelConfiguration { validExemptPL := func() *flowcontrolv1.PriorityLevelConfiguration {
copy := bootstrap.MandatoryPriorityLevelConfigurationExempt.DeepCopy() copy := bootstrap.MandatoryPriorityLevelConfigurationExempt.DeepCopy()
copy.Annotations[flowcontrolv1beta3.AutoUpdateAnnotationKey] = "true" copy.Annotations[flowcontrolv1.AutoUpdateAnnotationKey] = "true"
copy.Spec.Exempt.NominalConcurrencyShares = pointer.Int32(10) copy.Spec.Exempt.NominalConcurrencyShares = pointer.Int32(10)
copy.Spec.Exempt.LendablePercent = pointer.Int32(50) copy.Spec.Exempt.LendablePercent = pointer.Int32(50)
return copy return copy
@ -45,29 +45,29 @@ func TestEnsurePriorityLevel(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
strategy func() EnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration] strategy func() EnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration]
current *flowcontrolv1beta3.PriorityLevelConfiguration current *flowcontrolv1.PriorityLevelConfiguration
bootstrap *flowcontrolv1beta3.PriorityLevelConfiguration bootstrap *flowcontrolv1.PriorityLevelConfiguration
expected *flowcontrolv1beta3.PriorityLevelConfiguration expected *flowcontrolv1.PriorityLevelConfiguration
}{ }{
// for suggested configurations // for suggested configurations
{ {
name: "suggested priority level configuration does not exist - the object should always be re-created", name: "suggested priority level configuration does not exist - the object should always be re-created",
strategy: NewSuggestedEnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration], strategy: NewSuggestedEnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration],
bootstrap: newPLConfiguration("pl1").WithLimited(10).Object(), bootstrap: newPLConfiguration("pl1").WithLimited(10).Object(),
current: nil, current: nil,
expected: newPLConfiguration("pl1").WithLimited(10).Object(), expected: newPLConfiguration("pl1").WithLimited(10).Object(),
}, },
{ {
name: "suggested priority level configuration exists, auto update is enabled, spec does not match - current object should be updated", name: "suggested priority level configuration exists, auto update is enabled, spec does not match - current object should be updated",
strategy: NewSuggestedEnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration], strategy: NewSuggestedEnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration],
bootstrap: newPLConfiguration("pl1").WithLimited(20).Object(), bootstrap: newPLConfiguration("pl1").WithLimited(20).Object(),
current: newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").WithLimited(10).Object(), current: newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").WithLimited(10).Object(),
expected: newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").WithLimited(20).Object(), expected: newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").WithLimited(20).Object(),
}, },
{ {
name: "suggested priority level configuration exists, auto update is disabled, spec does not match - current object should not be updated", name: "suggested priority level configuration exists, auto update is disabled, spec does not match - current object should not be updated",
strategy: NewSuggestedEnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration], strategy: NewSuggestedEnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration],
bootstrap: newPLConfiguration("pl1").WithLimited(20).Object(), bootstrap: newPLConfiguration("pl1").WithLimited(20).Object(),
current: newPLConfiguration("pl1").WithAutoUpdateAnnotation("false").WithLimited(10).Object(), current: newPLConfiguration("pl1").WithAutoUpdateAnnotation("false").WithLimited(10).Object(),
expected: newPLConfiguration("pl1").WithAutoUpdateAnnotation("false").WithLimited(10).Object(), expected: newPLConfiguration("pl1").WithAutoUpdateAnnotation("false").WithLimited(10).Object(),
@ -76,29 +76,29 @@ func TestEnsurePriorityLevel(t *testing.T) {
// for mandatory configurations // for mandatory configurations
{ {
name: "mandatory priority level configuration does not exist - new object should be created", name: "mandatory priority level configuration does not exist - new object should be created",
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration], strategy: NewMandatoryEnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration],
bootstrap: newPLConfiguration("pl1").WithLimited(10).WithAutoUpdateAnnotation("true").Object(), bootstrap: newPLConfiguration("pl1").WithLimited(10).WithAutoUpdateAnnotation("true").Object(),
current: nil, current: nil,
expected: newPLConfiguration("pl1").WithLimited(10).WithAutoUpdateAnnotation("true").Object(), expected: newPLConfiguration("pl1").WithLimited(10).WithAutoUpdateAnnotation("true").Object(),
}, },
{ {
name: "mandatory priority level configuration exists, annotation is missing - annotation is added", name: "mandatory priority level configuration exists, annotation is missing - annotation is added",
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration], strategy: NewMandatoryEnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration],
bootstrap: newPLConfiguration("pl1").WithLimited(20).Object(), bootstrap: newPLConfiguration("pl1").WithLimited(20).Object(),
current: newPLConfiguration("pl1").WithLimited(20).Object(), current: newPLConfiguration("pl1").WithLimited(20).Object(),
expected: newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").WithLimited(20).Object(), expected: newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").WithLimited(20).Object(),
}, },
{ {
name: "mandatory priority level configuration exists, auto update is disabled, spec does not match - current object should be updated", name: "mandatory priority level configuration exists, auto update is disabled, spec does not match - current object should be updated",
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration], strategy: NewMandatoryEnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration],
bootstrap: newPLConfiguration("pl1").WithLimited(20).Object(), bootstrap: newPLConfiguration("pl1").WithLimited(20).Object(),
current: newPLConfiguration("pl1").WithAutoUpdateAnnotation("false").WithLimited(10).Object(), current: newPLConfiguration("pl1").WithAutoUpdateAnnotation("false").WithLimited(10).Object(),
expected: newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").WithLimited(20).Object(), expected: newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").WithLimited(20).Object(),
}, },
{ {
name: "admin changes the Exempt field of the exempt priority level configuration", name: "admin changes the Exempt field of the exempt priority level configuration",
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration], strategy: NewMandatoryEnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration],
bootstrap: func() *flowcontrolv1beta3.PriorityLevelConfiguration { bootstrap: func() *flowcontrolv1.PriorityLevelConfiguration {
return bootstrap.MandatoryPriorityLevelConfigurationExempt return bootstrap.MandatoryPriorityLevelConfigurationExempt
}(), }(),
current: validExemptPL, current: validExemptPL,
@ -108,7 +108,7 @@ func TestEnsurePriorityLevel(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
client := fake.NewSimpleClientset().FlowcontrolV1beta3().PriorityLevelConfigurations() client := fake.NewSimpleClientset().FlowcontrolV1().PriorityLevelConfigurations()
indexer := toolscache.NewIndexer(toolscache.MetaNamespaceKeyFunc, toolscache.Indexers{}) indexer := toolscache.NewIndexer(toolscache.MetaNamespaceKeyFunc, toolscache.Indexers{})
if test.current != nil { if test.current != nil {
client.Create(context.TODO(), test.current, metav1.CreateOptions{}) client.Create(context.TODO(), test.current, metav1.CreateOptions{})
@ -116,7 +116,7 @@ func TestEnsurePriorityLevel(t *testing.T) {
} }
ops := NewPriorityLevelConfigurationOps(client, flowcontrollisters.NewPriorityLevelConfigurationLister(indexer)) ops := NewPriorityLevelConfigurationOps(client, flowcontrollisters.NewPriorityLevelConfigurationLister(indexer))
boots := []*flowcontrolv1beta3.PriorityLevelConfiguration{test.bootstrap} boots := []*flowcontrolv1.PriorityLevelConfiguration{test.bootstrap}
strategy := test.strategy() strategy := test.strategy()
err := EnsureConfigurations(context.Background(), ops, boots, strategy) err := EnsureConfigurations(context.Background(), ops, boots, strategy)
@ -144,9 +144,9 @@ func TestEnsurePriorityLevel(t *testing.T) {
func TestSuggestedPLEnsureStrategy_ShouldUpdate(t *testing.T) { func TestSuggestedPLEnsureStrategy_ShouldUpdate(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
current *flowcontrolv1beta3.PriorityLevelConfiguration current *flowcontrolv1.PriorityLevelConfiguration
bootstrap *flowcontrolv1beta3.PriorityLevelConfiguration bootstrap *flowcontrolv1.PriorityLevelConfiguration
newObjectExpected *flowcontrolv1beta3.PriorityLevelConfiguration newObjectExpected *flowcontrolv1.PriorityLevelConfiguration
}{ }{
{ {
name: "auto update is enabled, first generation, spec does not match - spec update expected", name: "auto update is enabled, first generation, spec does not match - spec update expected",
@ -225,7 +225,7 @@ func TestSuggestedPLEnsureStrategy_ShouldUpdate(t *testing.T) {
ops := NewPriorityLevelConfigurationOps(nil, nil) ops := NewPriorityLevelConfigurationOps(nil, nil)
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
strategy := NewSuggestedEnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration]() strategy := NewSuggestedEnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration]()
updatableGot, updateGot, err := strategy.ReviseIfNeeded(ops, test.current, test.bootstrap) updatableGot, updateGot, err := strategy.ReviseIfNeeded(ops, test.current, test.bootstrap)
if err != nil { if err != nil {
t.Errorf("Expected no error, but got: %v", err) t.Errorf("Expected no error, but got: %v", err)
@ -251,75 +251,75 @@ func TestSuggestedPLEnsureStrategy_ShouldUpdate(t *testing.T) {
} }
func TestPriorityLevelSpecChanged(t *testing.T) { func TestPriorityLevelSpecChanged(t *testing.T) {
pl1 := &flowcontrolv1beta3.PriorityLevelConfiguration{ pl1 := &flowcontrolv1.PriorityLevelConfiguration{
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{ Spec: flowcontrolv1.PriorityLevelConfigurationSpec{
Type: flowcontrolv1beta3.PriorityLevelEnablementLimited, Type: flowcontrolv1.PriorityLevelEnablementLimited,
Limited: &flowcontrolv1beta3.LimitedPriorityLevelConfiguration{ Limited: &flowcontrolv1.LimitedPriorityLevelConfiguration{
LimitResponse: flowcontrolv1beta3.LimitResponse{ LimitResponse: flowcontrolv1.LimitResponse{
Type: flowcontrolv1beta3.LimitResponseTypeReject, Type: flowcontrolv1.LimitResponseTypeReject,
}, },
}, },
}, },
} }
pl2 := &flowcontrolv1beta3.PriorityLevelConfiguration{ pl2 := &flowcontrolv1.PriorityLevelConfiguration{
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{ Spec: flowcontrolv1.PriorityLevelConfigurationSpec{
Type: flowcontrolv1beta3.PriorityLevelEnablementLimited, Type: flowcontrolv1.PriorityLevelEnablementLimited,
Limited: &flowcontrolv1beta3.LimitedPriorityLevelConfiguration{ Limited: &flowcontrolv1.LimitedPriorityLevelConfiguration{
NominalConcurrencyShares: 1, NominalConcurrencyShares: 1,
}, },
}, },
} }
pl1Defaulted := &flowcontrolv1beta3.PriorityLevelConfiguration{ pl1Defaulted := &flowcontrolv1.PriorityLevelConfiguration{
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{ Spec: flowcontrolv1.PriorityLevelConfigurationSpec{
Type: flowcontrolv1beta3.PriorityLevelEnablementLimited, Type: flowcontrolv1.PriorityLevelEnablementLimited,
Limited: &flowcontrolv1beta3.LimitedPriorityLevelConfiguration{ Limited: &flowcontrolv1.LimitedPriorityLevelConfiguration{
NominalConcurrencyShares: flowcontrolapisv1beta3.PriorityLevelConfigurationDefaultNominalConcurrencyShares, NominalConcurrencyShares: flowcontrolapisv1.PriorityLevelConfigurationDefaultNominalConcurrencyShares,
LendablePercent: pointer.Int32(0), LendablePercent: pointer.Int32(0),
LimitResponse: flowcontrolv1beta3.LimitResponse{ LimitResponse: flowcontrolv1.LimitResponse{
Type: flowcontrolv1beta3.LimitResponseTypeReject, Type: flowcontrolv1.LimitResponseTypeReject,
}, },
}, },
}, },
} }
ple1 := &flowcontrolv1beta3.PriorityLevelConfiguration{ ple1 := &flowcontrolv1.PriorityLevelConfiguration{
ObjectMeta: metav1.ObjectMeta{Name: "exempt"}, ObjectMeta: metav1.ObjectMeta{Name: "exempt"},
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{ Spec: flowcontrolv1.PriorityLevelConfigurationSpec{
Type: flowcontrolv1beta3.PriorityLevelEnablementExempt, Type: flowcontrolv1.PriorityLevelEnablementExempt,
Exempt: &flowcontrolv1beta3.ExemptPriorityLevelConfiguration{ Exempt: &flowcontrolv1.ExemptPriorityLevelConfiguration{
NominalConcurrencyShares: pointer.Int32(42), NominalConcurrencyShares: pointer.Int32(42),
LendablePercent: pointer.Int32(33), LendablePercent: pointer.Int32(33),
}, },
}, },
} }
ple2 := &flowcontrolv1beta3.PriorityLevelConfiguration{ ple2 := &flowcontrolv1.PriorityLevelConfiguration{
ObjectMeta: metav1.ObjectMeta{Name: "exempt"}, ObjectMeta: metav1.ObjectMeta{Name: "exempt"},
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{ Spec: flowcontrolv1.PriorityLevelConfigurationSpec{
Type: flowcontrolv1beta3.PriorityLevelEnablementExempt, Type: flowcontrolv1.PriorityLevelEnablementExempt,
Exempt: &flowcontrolv1beta3.ExemptPriorityLevelConfiguration{ Exempt: &flowcontrolv1.ExemptPriorityLevelConfiguration{
NominalConcurrencyShares: pointer.Int32(24), NominalConcurrencyShares: pointer.Int32(24),
LendablePercent: pointer.Int32(86), LendablePercent: pointer.Int32(86),
}, },
}, },
} }
pleWrong := &flowcontrolv1beta3.PriorityLevelConfiguration{ pleWrong := &flowcontrolv1.PriorityLevelConfiguration{
ObjectMeta: metav1.ObjectMeta{Name: "exempt"}, ObjectMeta: metav1.ObjectMeta{Name: "exempt"},
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{ Spec: flowcontrolv1.PriorityLevelConfigurationSpec{
Type: flowcontrolv1beta3.PriorityLevelEnablementLimited, Type: flowcontrolv1.PriorityLevelEnablementLimited,
Limited: &flowcontrolv1beta3.LimitedPriorityLevelConfiguration{ Limited: &flowcontrolv1.LimitedPriorityLevelConfiguration{
NominalConcurrencyShares: 1, NominalConcurrencyShares: 1,
}, },
}, },
} }
pleInvalid := &flowcontrolv1beta3.PriorityLevelConfiguration{ pleInvalid := &flowcontrolv1.PriorityLevelConfiguration{
ObjectMeta: metav1.ObjectMeta{Name: "exempt"}, ObjectMeta: metav1.ObjectMeta{Name: "exempt"},
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{ Spec: flowcontrolv1.PriorityLevelConfigurationSpec{
Type: "widget", Type: "widget",
}, },
} }
testCases := []struct { testCases := []struct {
name string name string
expected *flowcontrolv1beta3.PriorityLevelConfiguration expected *flowcontrolv1.PriorityLevelConfiguration
actual *flowcontrolv1beta3.PriorityLevelConfiguration actual *flowcontrolv1.PriorityLevelConfiguration
specChanged bool specChanged bool
}{ }{
{ {
@ -373,7 +373,7 @@ func TestPriorityLevelSpecChanged(t *testing.T) {
func TestRemovePriorityLevelConfiguration(t *testing.T) { func TestRemovePriorityLevelConfiguration(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
current *flowcontrolv1beta3.PriorityLevelConfiguration current *flowcontrolv1.PriorityLevelConfiguration
bootstrapName string bootstrapName string
removeExpected bool removeExpected bool
}{ }{
@ -422,7 +422,7 @@ func TestRemovePriorityLevelConfiguration(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
client := fake.NewSimpleClientset().FlowcontrolV1beta3().PriorityLevelConfigurations() client := fake.NewSimpleClientset().FlowcontrolV1().PriorityLevelConfigurations()
indexer := toolscache.NewIndexer(toolscache.MetaNamespaceKeyFunc, toolscache.Indexers{}) indexer := toolscache.NewIndexer(toolscache.MetaNamespaceKeyFunc, toolscache.Indexers{})
if test.current != nil { if test.current != nil {
client.Create(context.TODO(), test.current, metav1.CreateOptions{}) client.Create(context.TODO(), test.current, metav1.CreateOptions{})
@ -430,7 +430,7 @@ func TestRemovePriorityLevelConfiguration(t *testing.T) {
} }
boot := newPLConfiguration(test.bootstrapName).Object() boot := newPLConfiguration(test.bootstrapName).Object()
boots := []*flowcontrolv1beta3.PriorityLevelConfiguration{boot} boots := []*flowcontrolv1.PriorityLevelConfiguration{boot}
ops := NewPriorityLevelConfigurationOps(client, flowcontrollisters.NewPriorityLevelConfigurationLister(indexer)) ops := NewPriorityLevelConfigurationOps(client, flowcontrollisters.NewPriorityLevelConfigurationLister(indexer))
err := RemoveUnwantedObjects(context.Background(), ops, boots) err := RemoveUnwantedObjects(context.Background(), ops, boots)
if err != nil { if err != nil {
@ -456,12 +456,12 @@ func TestRemovePriorityLevelConfiguration(t *testing.T) {
} }
type plBuilder struct { type plBuilder struct {
object *flowcontrolv1beta3.PriorityLevelConfiguration object *flowcontrolv1.PriorityLevelConfiguration
} }
func newPLConfiguration(name string) *plBuilder { func newPLConfiguration(name string) *plBuilder {
return &plBuilder{ return &plBuilder{
object: &flowcontrolv1beta3.PriorityLevelConfiguration{ object: &flowcontrolv1.PriorityLevelConfiguration{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: name, Name: name,
}, },
@ -469,7 +469,7 @@ func newPLConfiguration(name string) *plBuilder {
} }
} }
func (b *plBuilder) Object() *flowcontrolv1beta3.PriorityLevelConfiguration { func (b *plBuilder) Object() *flowcontrolv1.PriorityLevelConfiguration {
return b.object return b.object
} }
@ -484,12 +484,12 @@ func (b *plBuilder) WithAutoUpdateAnnotation(value string) *plBuilder {
} }
func (b *plBuilder) WithLimited(nominalConcurrencyShares int32) *plBuilder { func (b *plBuilder) WithLimited(nominalConcurrencyShares int32) *plBuilder {
b.object.Spec.Type = flowcontrolv1beta3.PriorityLevelEnablementLimited b.object.Spec.Type = flowcontrolv1.PriorityLevelEnablementLimited
b.object.Spec.Limited = &flowcontrolv1beta3.LimitedPriorityLevelConfiguration{ b.object.Spec.Limited = &flowcontrolv1.LimitedPriorityLevelConfiguration{
NominalConcurrencyShares: nominalConcurrencyShares, NominalConcurrencyShares: nominalConcurrencyShares,
LendablePercent: pointer.Int32(0), LendablePercent: pointer.Int32(0),
LimitResponse: flowcontrolv1beta3.LimitResponse{ LimitResponse: flowcontrolv1.LimitResponse{
Type: flowcontrolv1beta3.LimitResponseTypeReject, Type: flowcontrolv1.LimitResponseTypeReject,
}, },
} }
return b return b
@ -502,8 +502,8 @@ func (b *plBuilder) WithQueuing(queues, handSize, queueLengthLimit int32) *plBui
return b return b
} }
limited.LimitResponse.Type = flowcontrolv1beta3.LimitResponseTypeQueue limited.LimitResponse.Type = flowcontrolv1.LimitResponseTypeQueue
limited.LimitResponse.Queuing = &flowcontrolv1beta3.QueuingConfiguration{ limited.LimitResponse.Queuing = &flowcontrolv1.QueuingConfiguration{
Queues: queues, Queues: queues,
HandSize: handSize, HandSize: handSize,
QueueLengthLimit: queueLengthLimit, QueueLengthLimit: queueLengthLimit,

View File

@ -22,7 +22,7 @@ import (
"strconv" "strconv"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" flowcontrolv1 "k8s.io/api/flowcontrol/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
@ -199,7 +199,7 @@ func (s *strategy[ObjectType]) ReviseIfNeeded(objectOps objectLocalOps[ObjectTyp
// shouldUpdateSpec inspects the auto-update annotation key and generation field to determine // shouldUpdateSpec inspects the auto-update annotation key and generation field to determine
// whether the config object should be auto-updated. // whether the config object should be auto-updated.
func shouldUpdateSpec(accessor metav1.Object) bool { func shouldUpdateSpec(accessor metav1.Object) bool {
value, _ := accessor.GetAnnotations()[flowcontrolv1beta3.AutoUpdateAnnotationKey] value, _ := accessor.GetAnnotations()[flowcontrolv1.AutoUpdateAnnotationKey]
if autoUpdate, err := strconv.ParseBool(value); err == nil { if autoUpdate, err := strconv.ParseBool(value); err == nil {
return autoUpdate return autoUpdate
} }
@ -219,7 +219,7 @@ func shouldUpdateSpec(accessor metav1.Object) bool {
// shouldUpdateAnnotation determines whether the current value of the auto-update annotation // shouldUpdateAnnotation determines whether the current value of the auto-update annotation
// key matches the desired value. // key matches the desired value.
func shouldUpdateAnnotation(accessor metav1.Object, desired bool) bool { func shouldUpdateAnnotation(accessor metav1.Object, desired bool) bool {
if value, ok := accessor.GetAnnotations()[flowcontrolv1beta3.AutoUpdateAnnotationKey]; ok { if value, ok := accessor.GetAnnotations()[flowcontrolv1.AutoUpdateAnnotationKey]; ok {
if current, err := strconv.ParseBool(value); err == nil && current == desired { if current, err := strconv.ParseBool(value); err == nil && current == desired {
return false return false
} }
@ -234,7 +234,7 @@ func setAutoUpdateAnnotation(accessor metav1.Object, autoUpdate bool) {
accessor.SetAnnotations(map[string]string{}) accessor.SetAnnotations(map[string]string{})
} }
accessor.GetAnnotations()[flowcontrolv1beta3.AutoUpdateAnnotationKey] = strconv.FormatBool(autoUpdate) accessor.GetAnnotations()[flowcontrolv1.AutoUpdateAnnotationKey] = strconv.FormatBool(autoUpdate)
} }
// EnsureConfigurations applies the given maintenance strategy to the given objects. // EnsureConfigurations applies the given maintenance strategy to the given objects.
@ -321,21 +321,21 @@ func RemoveUnwantedObjects[ObjectType configurationObjectType](ctx context.Conte
var value string var value string
var ok, autoUpdate bool var ok, autoUpdate bool
var err error var err error
if value, ok = object.GetAnnotations()[flowcontrolv1beta3.AutoUpdateAnnotationKey]; !ok { if value, ok = object.GetAnnotations()[flowcontrolv1.AutoUpdateAnnotationKey]; !ok {
// the configuration object does not have the annotation key, // the configuration object does not have the annotation key,
// it's probably a user defined configuration object, // it's probably a user defined configuration object,
// so we can skip it. // so we can skip it.
klog.V(5).InfoS("Skipping deletion of APF object with no "+flowcontrolv1beta3.AutoUpdateAnnotationKey+" annotation", "name", name) klog.V(5).InfoS("Skipping deletion of APF object with no "+flowcontrolv1.AutoUpdateAnnotationKey+" annotation", "name", name)
continue continue
} }
autoUpdate, err = strconv.ParseBool(value) autoUpdate, err = strconv.ParseBool(value)
if err != nil { if err != nil {
// Log this because it is not an expected situation. // Log this because it is not an expected situation.
klog.V(4).InfoS("Skipping deletion of APF object with malformed "+flowcontrolv1beta3.AutoUpdateAnnotationKey+" annotation", "name", name, "annotationValue", value, "parseError", err) klog.V(4).InfoS("Skipping deletion of APF object with malformed "+flowcontrolv1.AutoUpdateAnnotationKey+" annotation", "name", name, "annotationValue", value, "parseError", err)
continue continue
} }
if !autoUpdate { if !autoUpdate {
klog.V(5).InfoS("Skipping deletion of APF object with "+flowcontrolv1beta3.AutoUpdateAnnotationKey+"=false annotation", "name", name) klog.V(5).InfoS("Skipping deletion of APF object with "+flowcontrolv1.AutoUpdateAnnotationKey+"=false annotation", "name", name)
continue continue
} }
// TODO: expectedResourceVersion := object.GetResourceVersion() // TODO: expectedResourceVersion := object.GetResourceVersion()

View File

@ -21,7 +21,7 @@ import (
"fmt" "fmt"
"time" "time"
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3" flowcontrolv1 "k8s.io/api/flowcontrol/v1"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
flowcontrolbootstrap "k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap" flowcontrolbootstrap "k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
@ -30,8 +30,8 @@ import (
genericapiserver "k8s.io/apiserver/pkg/server" genericapiserver "k8s.io/apiserver/pkg/server"
serverstorage "k8s.io/apiserver/pkg/server/storage" serverstorage "k8s.io/apiserver/pkg/server/storage"
"k8s.io/client-go/informers" "k8s.io/client-go/informers"
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3" flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1"
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta3" flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
"k8s.io/klog/v2" "k8s.io/klog/v2"
"k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/api/legacyscheme"
@ -121,11 +121,11 @@ func (p RESTStorageProvider) GroupName() string {
func (p RESTStorageProvider) PostStartHook() (string, genericapiserver.PostStartHookFunc, error) { func (p RESTStorageProvider) PostStartHook() (string, genericapiserver.PostStartHookFunc, error) {
bce := &bootstrapConfigurationEnsurer{ bce := &bootstrapConfigurationEnsurer{
informersSynced: []cache.InformerSynced{ informersSynced: []cache.InformerSynced{
p.InformerFactory.Flowcontrol().V1beta3().PriorityLevelConfigurations().Informer().HasSynced, p.InformerFactory.Flowcontrol().V1().PriorityLevelConfigurations().Informer().HasSynced,
p.InformerFactory.Flowcontrol().V1beta3().FlowSchemas().Informer().HasSynced, p.InformerFactory.Flowcontrol().V1().FlowSchemas().Informer().HasSynced,
}, },
fsLister: p.InformerFactory.Flowcontrol().V1beta3().FlowSchemas().Lister(), fsLister: p.InformerFactory.Flowcontrol().V1().FlowSchemas().Lister(),
plcLister: p.InformerFactory.Flowcontrol().V1beta3().PriorityLevelConfigurations().Lister(), plcLister: p.InformerFactory.Flowcontrol().V1().PriorityLevelConfigurations().Lister(),
} }
return PostStartHookName, bce.ensureAPFBootstrapConfiguration, nil return PostStartHookName, bce.ensureAPFBootstrapConfiguration, nil
} }
@ -190,7 +190,7 @@ func (bce *bootstrapConfigurationEnsurer) ensureAPFBootstrapConfiguration(hookCo
return nil return nil
} }
func ensure(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1beta3Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error { func ensure(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
if err := ensureSuggestedConfiguration(ctx, clientset, fsLister, plcLister); err != nil { if err := ensureSuggestedConfiguration(ctx, clientset, fsLister, plcLister); err != nil {
// We should not attempt creation of mandatory objects if ensuring the suggested // We should not attempt creation of mandatory objects if ensuring the suggested
@ -210,27 +210,27 @@ func ensure(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1beta3I
return nil return nil
} }
func ensureSuggestedConfiguration(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1beta3Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error { func ensureSuggestedConfiguration(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
plcOps := ensurer.NewPriorityLevelConfigurationOps(clientset.PriorityLevelConfigurations(), plcLister) plcOps := ensurer.NewPriorityLevelConfigurationOps(clientset.PriorityLevelConfigurations(), plcLister)
if err := ensurer.EnsureConfigurations(ctx, plcOps, flowcontrolbootstrap.SuggestedPriorityLevelConfigurations, ensurer.NewSuggestedEnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration]()); err != nil { if err := ensurer.EnsureConfigurations(ctx, plcOps, flowcontrolbootstrap.SuggestedPriorityLevelConfigurations, ensurer.NewSuggestedEnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration]()); err != nil {
return err return err
} }
fsOps := ensurer.NewFlowSchemaOps(clientset.FlowSchemas(), fsLister) fsOps := ensurer.NewFlowSchemaOps(clientset.FlowSchemas(), fsLister)
return ensurer.EnsureConfigurations(ctx, fsOps, flowcontrolbootstrap.SuggestedFlowSchemas, ensurer.NewSuggestedEnsureStrategy[*flowcontrolv1beta3.FlowSchema]()) return ensurer.EnsureConfigurations(ctx, fsOps, flowcontrolbootstrap.SuggestedFlowSchemas, ensurer.NewSuggestedEnsureStrategy[*flowcontrolv1.FlowSchema]())
} }
func ensureMandatoryConfiguration(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1beta3Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error { func ensureMandatoryConfiguration(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
plcOps := ensurer.NewPriorityLevelConfigurationOps(clientset.PriorityLevelConfigurations(), plcLister) plcOps := ensurer.NewPriorityLevelConfigurationOps(clientset.PriorityLevelConfigurations(), plcLister)
if err := ensurer.EnsureConfigurations(ctx, plcOps, flowcontrolbootstrap.MandatoryPriorityLevelConfigurations, ensurer.NewMandatoryEnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration]()); err != nil { if err := ensurer.EnsureConfigurations(ctx, plcOps, flowcontrolbootstrap.MandatoryPriorityLevelConfigurations, ensurer.NewMandatoryEnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration]()); err != nil {
return err return err
} }
fsOps := ensurer.NewFlowSchemaOps(clientset.FlowSchemas(), fsLister) fsOps := ensurer.NewFlowSchemaOps(clientset.FlowSchemas(), fsLister)
return ensurer.EnsureConfigurations(ctx, fsOps, flowcontrolbootstrap.MandatoryFlowSchemas, ensurer.NewMandatoryEnsureStrategy[*flowcontrolv1beta3.FlowSchema]()) return ensurer.EnsureConfigurations(ctx, fsOps, flowcontrolbootstrap.MandatoryFlowSchemas, ensurer.NewMandatoryEnsureStrategy[*flowcontrolv1.FlowSchema]())
} }
func removeDanglingBootstrapConfiguration(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1beta3Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error { func removeDanglingBootstrapConfiguration(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
if err := removeDanglingBootstrapFlowSchema(ctx, clientset, fsLister); err != nil { if err := removeDanglingBootstrapFlowSchema(ctx, clientset, fsLister); err != nil {
return err return err
} }
@ -238,13 +238,13 @@ func removeDanglingBootstrapConfiguration(ctx context.Context, clientset flowcon
return removeDanglingBootstrapPriorityLevel(ctx, clientset, plcLister) return removeDanglingBootstrapPriorityLevel(ctx, clientset, plcLister)
} }
func removeDanglingBootstrapFlowSchema(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1beta3Interface, fsLister flowcontrollisters.FlowSchemaLister) error { func removeDanglingBootstrapFlowSchema(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1Interface, fsLister flowcontrollisters.FlowSchemaLister) error {
bootstrap := append(flowcontrolbootstrap.MandatoryFlowSchemas, flowcontrolbootstrap.SuggestedFlowSchemas...) bootstrap := append(flowcontrolbootstrap.MandatoryFlowSchemas, flowcontrolbootstrap.SuggestedFlowSchemas...)
fsOps := ensurer.NewFlowSchemaOps(clientset.FlowSchemas(), fsLister) fsOps := ensurer.NewFlowSchemaOps(clientset.FlowSchemas(), fsLister)
return ensurer.RemoveUnwantedObjects(ctx, fsOps, bootstrap) return ensurer.RemoveUnwantedObjects(ctx, fsOps, bootstrap)
} }
func removeDanglingBootstrapPriorityLevel(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1beta3Interface, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error { func removeDanglingBootstrapPriorityLevel(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1Interface, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
bootstrap := append(flowcontrolbootstrap.MandatoryPriorityLevelConfigurations, flowcontrolbootstrap.SuggestedPriorityLevelConfigurations...) bootstrap := append(flowcontrolbootstrap.MandatoryPriorityLevelConfigurations, flowcontrolbootstrap.SuggestedPriorityLevelConfigurations...)
plcOps := ensurer.NewPriorityLevelConfigurationOps(clientset.PriorityLevelConfigurations(), plcLister) plcOps := ensurer.NewPriorityLevelConfigurationOps(clientset.PriorityLevelConfigurations(), plcLister)
return ensurer.RemoveUnwantedObjects(ctx, plcOps, bootstrap) return ensurer.RemoveUnwantedObjects(ctx, plcOps, bootstrap)

View File

@ -19,7 +19,7 @@ package bootstrap
import ( import (
coordinationv1 "k8s.io/api/coordination/v1" coordinationv1 "k8s.io/api/coordination/v1"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
flowcontrol "k8s.io/api/flowcontrol/v1beta3" flowcontrol "k8s.io/api/flowcontrol/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apiserver/pkg/authentication/serviceaccount" "k8s.io/apiserver/pkg/authentication/serviceaccount"
"k8s.io/apiserver/pkg/authentication/user" "k8s.io/apiserver/pkg/authentication/user"

View File

@ -19,7 +19,7 @@ package bootstrap
import ( import (
"testing" "testing"
flowcontrol "k8s.io/api/flowcontrol/v1beta3" flowcontrol "k8s.io/api/flowcontrol/v1"
) )
func TestBootstrapPriorityLevelConfigurationWithBorrowing(t *testing.T) { func TestBootstrapPriorityLevelConfigurationWithBorrowing(t *testing.T) {

View File

@ -26,7 +26,7 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
flowcontrol "k8s.io/api/flowcontrol/v1beta3" flowcontrol "k8s.io/api/flowcontrol/v1"
apitypes "k8s.io/apimachinery/pkg/types" apitypes "k8s.io/apimachinery/pkg/types"
epmetrics "k8s.io/apiserver/pkg/endpoints/metrics" epmetrics "k8s.io/apiserver/pkg/endpoints/metrics"
apirequest "k8s.io/apiserver/pkg/endpoints/request" apirequest "k8s.io/apiserver/pkg/endpoints/request"

View File

@ -29,7 +29,7 @@ import (
"testing" "testing"
"time" "time"
flowcontrol "k8s.io/api/flowcontrol/v1beta3" flowcontrol "k8s.io/api/flowcontrol/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
@ -1119,7 +1119,7 @@ func startAPFController(t *testing.T, stopCh <-chan struct{}, apfConfiguration [
clientset := newClientset(t, apfConfiguration...) clientset := newClientset(t, apfConfiguration...)
// this test does not rely on resync, so resync period is set to zero // this test does not rely on resync, so resync period is set to zero
factory := informers.NewSharedInformerFactory(clientset, 0) factory := informers.NewSharedInformerFactory(clientset, 0)
controller := utilflowcontrol.New(factory, clientset.FlowcontrolV1beta3(), serverConcurrency) controller := utilflowcontrol.New(factory, clientset.FlowcontrolV1(), serverConcurrency)
factory.Start(stopCh) factory.Start(stopCh)

View File

@ -79,7 +79,7 @@ func (o *FeatureOptions) ApplyTo(c *server.Config, clientset kubernetes.Interfac
} }
c.FlowControl = utilflowcontrol.New( c.FlowControl = utilflowcontrol.New(
informers, informers,
clientset.FlowcontrolV1beta3(), clientset.FlowcontrolV1(),
c.MaxRequestsInFlight+c.MaxMutatingRequestsInFlight, c.MaxRequestsInFlight+c.MaxMutatingRequestsInFlight,
) )
} }

View File

@ -19,7 +19,7 @@ package apihelpers
import ( import (
"sort" "sort"
flowcontrol "k8s.io/api/flowcontrol/v1beta3" flowcontrol "k8s.io/api/flowcontrol/v1"
) )
// SetFlowSchemaCondition sets conditions. // SetFlowSchemaCondition sets conditions.

View File

@ -50,10 +50,10 @@ import (
"k8s.io/klog/v2" "k8s.io/klog/v2"
"k8s.io/utils/clock" "k8s.io/utils/clock"
flowcontrol "k8s.io/api/flowcontrol/v1beta3" flowcontrol "k8s.io/api/flowcontrol/v1"
flowcontrolapplyconfiguration "k8s.io/client-go/applyconfigurations/flowcontrol/v1beta3" flowcontrolapplyconfiguration "k8s.io/client-go/applyconfigurations/flowcontrol/v1"
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3" flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1"
flowcontrollister "k8s.io/client-go/listers/flowcontrol/v1beta3" flowcontrollister "k8s.io/client-go/listers/flowcontrol/v1"
) )
const timeFmt = "2006-01-02T15:04:05.999" const timeFmt = "2006-01-02T15:04:05.999"
@ -143,7 +143,7 @@ type configController struct {
fsLister flowcontrollister.FlowSchemaLister fsLister flowcontrollister.FlowSchemaLister
fsInformerSynced cache.InformerSynced fsInformerSynced cache.InformerSynced
flowcontrolClient flowcontrolclient.FlowcontrolV1beta3Interface flowcontrolClient flowcontrolclient.FlowcontrolV1Interface
// serverConcurrencyLimit is the limit on the server's total // serverConcurrencyLimit is the limit on the server's total
// number of non-exempt requests being served at once. This comes // number of non-exempt requests being served at once. This comes
@ -295,7 +295,7 @@ func newTestableController(config TestableConfig) *configController {
cfgCtlr.configQueue = workqueue.NewNamedRateLimitingQueue(workqueue.NewItemExponentialFailureRateLimiter(200*time.Millisecond, 8*time.Hour), "priority_and_fairness_config_queue") cfgCtlr.configQueue = workqueue.NewNamedRateLimitingQueue(workqueue.NewItemExponentialFailureRateLimiter(200*time.Millisecond, 8*time.Hour), "priority_and_fairness_config_queue")
// ensure the data structure reflects the mandatory config // ensure the data structure reflects the mandatory config
cfgCtlr.lockAndDigestConfigObjects(nil, nil) cfgCtlr.lockAndDigestConfigObjects(nil, nil)
fci := config.InformerFactory.Flowcontrol().V1beta3() fci := config.InformerFactory.Flowcontrol().V1()
pli := fci.PriorityLevelConfigurations() pli := fci.PriorityLevelConfigurations()
fsi := fci.FlowSchemas() fsi := fci.FlowSchemas()
cfgCtlr.plLister = pli.Lister() cfgCtlr.plLister = pli.Lister()

View File

@ -33,8 +33,8 @@ import (
"k8s.io/klog/v2" "k8s.io/klog/v2"
"k8s.io/utils/clock" "k8s.io/utils/clock"
flowcontrol "k8s.io/api/flowcontrol/v1beta3" flowcontrol "k8s.io/api/flowcontrol/v1"
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3" flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1"
) )
// ConfigConsumerAsFieldManager is how the config consuminng // ConfigConsumerAsFieldManager is how the config consuminng
@ -88,7 +88,7 @@ type Interface interface {
// New creates a new instance to implement API priority and fairness // New creates a new instance to implement API priority and fairness
func New( func New(
informerFactory kubeinformers.SharedInformerFactory, informerFactory kubeinformers.SharedInformerFactory,
flowcontrolClient flowcontrolclient.FlowcontrolV1beta3Interface, flowcontrolClient flowcontrolclient.FlowcontrolV1Interface,
serverConcurrencyLimit int, serverConcurrencyLimit int,
) Interface { ) Interface {
clk := eventclock.Real{} clk := eventclock.Real{}
@ -132,7 +132,7 @@ type TestableConfig struct {
InformerFactory kubeinformers.SharedInformerFactory InformerFactory kubeinformers.SharedInformerFactory
// FlowcontrolClient to use for manipulating config objects // FlowcontrolClient to use for manipulating config objects
FlowcontrolClient flowcontrolclient.FlowcontrolV1beta3Interface FlowcontrolClient flowcontrolclient.FlowcontrolV1Interface
// ServerConcurrencyLimit for the controller to enforce // ServerConcurrencyLimit for the controller to enforce
ServerConcurrencyLimit int ServerConcurrencyLimit int

View File

@ -21,7 +21,7 @@ import (
"testing" "testing"
"time" "time"
flowcontrol "k8s.io/api/flowcontrol/v1beta3" flowcontrol "k8s.io/api/flowcontrol/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
@ -98,7 +98,7 @@ func TestQueueWaitTimeLatencyTracker(t *testing.T) {
clientset := clientsetfake.NewSimpleClientset(cfgObjs...) clientset := clientsetfake.NewSimpleClientset(cfgObjs...)
informerFactory := informers.NewSharedInformerFactory(clientset, time.Second) informerFactory := informers.NewSharedInformerFactory(clientset, time.Second)
flowcontrolClient := clientset.FlowcontrolV1beta3() flowcontrolClient := clientset.FlowcontrolV1()
startTime := time.Now() startTime := time.Now()
clk, _ := eventclock.NewFake(startTime, 0, nil) clk, _ := eventclock.NewFake(startTime, 0, nil)
controller := newTestableController(TestableConfig{ controller := newTestableController(TestableConfig{

View File

@ -23,7 +23,7 @@ import (
"testing" "testing"
"time" "time"
flowcontrol "k8s.io/api/flowcontrol/v1beta3" flowcontrol "k8s.io/api/flowcontrol/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
@ -133,7 +133,7 @@ func TestBorrowing(t *testing.T) {
} }
clientset := clientsetfake.NewSimpleClientset(cfgObjs...) clientset := clientsetfake.NewSimpleClientset(cfgObjs...)
informerFactory := informers.NewSharedInformerFactory(clientset, time.Second) informerFactory := informers.NewSharedInformerFactory(clientset, time.Second)
flowcontrolClient := clientset.FlowcontrolV1beta3() flowcontrolClient := clientset.FlowcontrolV1()
clk := eventclock.Real{} clk := eventclock.Real{}
controller := newTestableController(TestableConfig{ controller := newTestableController(TestableConfig{
Name: "Controller", Name: "Controller",

View File

@ -26,7 +26,7 @@ import (
"testing" "testing"
"time" "time"
flowcontrol "k8s.io/api/flowcontrol/v1beta3" flowcontrol "k8s.io/api/flowcontrol/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
@ -38,7 +38,7 @@ import (
fcrequest "k8s.io/apiserver/pkg/util/flowcontrol/request" fcrequest "k8s.io/apiserver/pkg/util/flowcontrol/request"
"k8s.io/client-go/informers" "k8s.io/client-go/informers"
clientsetfake "k8s.io/client-go/kubernetes/fake" clientsetfake "k8s.io/client-go/kubernetes/fake"
fcclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3" fcclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1"
"k8s.io/klog/v2" "k8s.io/klog/v2"
"k8s.io/utils/clock" "k8s.io/utils/clock"
) )
@ -70,7 +70,7 @@ func (cfgCtlr *configController) hasPriorityLevelState(plName string) bool {
type ctlrTestState struct { type ctlrTestState struct {
t *testing.T t *testing.T
cfgCtlr *configController cfgCtlr *configController
fcIfc fcclient.FlowcontrolV1beta3Interface fcIfc fcclient.FlowcontrolV1Interface
existingPLs map[string]*flowcontrol.PriorityLevelConfiguration existingPLs map[string]*flowcontrol.PriorityLevelConfiguration
existingFSs map[string]*flowcontrol.FlowSchema existingFSs map[string]*flowcontrol.FlowSchema
heldRequestsMap map[string][]heldRequest heldRequestsMap map[string][]heldRequest
@ -236,7 +236,7 @@ func TestConfigConsumer(t *testing.T) {
t.Run(fmt.Sprintf("trial%d:", i), func(t *testing.T) { t.Run(fmt.Sprintf("trial%d:", i), func(t *testing.T) {
clientset := clientsetfake.NewSimpleClientset() clientset := clientsetfake.NewSimpleClientset()
informerFactory := informers.NewSharedInformerFactory(clientset, 0) informerFactory := informers.NewSharedInformerFactory(clientset, 0)
flowcontrolClient := clientset.FlowcontrolV1beta3() flowcontrolClient := clientset.FlowcontrolV1()
cts := &ctlrTestState{t: t, cts := &ctlrTestState{t: t,
fcIfc: flowcontrolClient, fcIfc: flowcontrolClient,
existingFSs: map[string]*flowcontrol.FlowSchema{}, existingFSs: map[string]*flowcontrol.FlowSchema{},
@ -367,7 +367,7 @@ func TestAPFControllerWithGracefulShutdown(t *testing.T) {
clientset := clientsetfake.NewSimpleClientset(fs, pl) clientset := clientsetfake.NewSimpleClientset(fs, pl)
informerFactory := informers.NewSharedInformerFactory(clientset, time.Second) informerFactory := informers.NewSharedInformerFactory(clientset, time.Second)
flowcontrolClient := clientset.FlowcontrolV1beta3() flowcontrolClient := clientset.FlowcontrolV1()
cts := &ctlrTestState{t: t, cts := &ctlrTestState{t: t,
fcIfc: flowcontrolClient, fcIfc: flowcontrolClient,
existingFSs: map[string]*flowcontrol.FlowSchema{}, existingFSs: map[string]*flowcontrol.FlowSchema{},

View File

@ -21,7 +21,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
flowcontrol "k8s.io/api/flowcontrol/v1beta3" flowcontrol "k8s.io/api/flowcontrol/v1"
"k8s.io/apiserver/pkg/authentication/user" "k8s.io/apiserver/pkg/authentication/user"
"k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/endpoints/request"
) )
@ -93,7 +93,7 @@ func FmtPriorityLevelConfiguration(pl *flowcontrol.PriorityLevelConfiguration) s
return "nil" return "nil"
} }
var buf bytes.Buffer var buf bytes.Buffer
buf.WriteString(fmt.Sprintf("&flowcontrolv1beta3.PriorityLevelConfiguration{ObjectMeta: %#+v, Spec: ", buf.WriteString(fmt.Sprintf("&flowcontrolv1.PriorityLevelConfiguration{ObjectMeta: %#+v, Spec: ",
pl.ObjectMeta)) pl.ObjectMeta))
BufferPriorityLevelConfigurationSpec(&buf, &pl.Spec) BufferPriorityLevelConfigurationSpec(&buf, &pl.Spec)
buf.WriteString(fmt.Sprintf(", Status: %#+v}", pl.Status)) buf.WriteString(fmt.Sprintf(", Status: %#+v}", pl.Status))
@ -111,7 +111,7 @@ func FmtPriorityLevelConfigurationSpec(plSpec *flowcontrol.PriorityLevelConfigur
// BufferPriorityLevelConfigurationSpec writes a golang source // BufferPriorityLevelConfigurationSpec writes a golang source
// expression for the given value to the given buffer // expression for the given value to the given buffer
func BufferPriorityLevelConfigurationSpec(buf *bytes.Buffer, plSpec *flowcontrol.PriorityLevelConfigurationSpec) { func BufferPriorityLevelConfigurationSpec(buf *bytes.Buffer, plSpec *flowcontrol.PriorityLevelConfigurationSpec) {
buf.WriteString(fmt.Sprintf("flowcontrolv1beta3.PriorityLevelConfigurationSpec{Type: %#v", plSpec.Type)) buf.WriteString(fmt.Sprintf("flowcontrolv1.PriorityLevelConfigurationSpec{Type: %#v", plSpec.Type))
if plSpec.Limited != nil { if plSpec.Limited != nil {
buf.WriteString(fmt.Sprintf(", Limited: &flowcontrol.LimitedPriorityLevelConfiguration{NominalConcurrencyShares:%d, LimitResponse:flowcontrol.LimitResponse{Type:%#v", plSpec.Limited.NominalConcurrencyShares, plSpec.Limited.LimitResponse.Type)) buf.WriteString(fmt.Sprintf(", Limited: &flowcontrol.LimitedPriorityLevelConfiguration{NominalConcurrencyShares:%d, LimitResponse:flowcontrol.LimitResponse{Type:%#v", plSpec.Limited.NominalConcurrencyShares, plSpec.Limited.LimitResponse.Type))
if plSpec.Limited.LimitResponse.Queuing != nil { if plSpec.Limited.LimitResponse.Queuing != nil {
@ -128,7 +128,7 @@ func FmtFlowSchema(fs *flowcontrol.FlowSchema) string {
return "nil" return "nil"
} }
var buf bytes.Buffer var buf bytes.Buffer
buf.WriteString(fmt.Sprintf("&flowcontrolv1beta3.FlowSchema{ObjectMeta: %#+v, Spec: ", buf.WriteString(fmt.Sprintf("&flowcontrolv1.FlowSchema{ObjectMeta: %#+v, Spec: ",
fs.ObjectMeta)) fs.ObjectMeta))
BufferFlowSchemaSpec(&buf, &fs.Spec) BufferFlowSchemaSpec(&buf, &fs.Spec)
buf.WriteString(fmt.Sprintf(", Status: %#+v}", fs.Status)) buf.WriteString(fmt.Sprintf(", Status: %#+v}", fs.Status))
@ -146,7 +146,7 @@ func FmtFlowSchemaSpec(fsSpec *flowcontrol.FlowSchemaSpec) string {
// BufferFlowSchemaSpec writes a golang source expression for the // BufferFlowSchemaSpec writes a golang source expression for the
// given value to the given buffer // given value to the given buffer
func BufferFlowSchemaSpec(buf *bytes.Buffer, fsSpec *flowcontrol.FlowSchemaSpec) { func BufferFlowSchemaSpec(buf *bytes.Buffer, fsSpec *flowcontrol.FlowSchemaSpec) {
buf.WriteString(fmt.Sprintf("flowcontrolv1beta3.FlowSchemaSpec{PriorityLevelConfiguration: %#+v, MatchingPrecedence: %d, DistinguisherMethod: ", buf.WriteString(fmt.Sprintf("flowcontrolv1.FlowSchemaSpec{PriorityLevelConfiguration: %#+v, MatchingPrecedence: %d, DistinguisherMethod: ",
fsSpec.PriorityLevelConfiguration, fsSpec.PriorityLevelConfiguration,
fsSpec.MatchingPrecedence)) fsSpec.MatchingPrecedence))
if fsSpec.DistinguisherMethod == nil { if fsSpec.DistinguisherMethod == nil {
@ -166,7 +166,7 @@ func BufferFlowSchemaSpec(buf *bytes.Buffer, fsSpec *flowcontrol.FlowSchemaSpec)
// FmtPolicyRulesWithSubjects produces a golang source expression of the value. // FmtPolicyRulesWithSubjects produces a golang source expression of the value.
func FmtPolicyRulesWithSubjects(rule flowcontrol.PolicyRulesWithSubjects) string { func FmtPolicyRulesWithSubjects(rule flowcontrol.PolicyRulesWithSubjects) string {
return "flowcontrolv1beta3.PolicyRulesWithSubjects" + FmtPolicyRulesWithSubjectsSlim(rule) return "flowcontrolv1.PolicyRulesWithSubjects" + FmtPolicyRulesWithSubjectsSlim(rule)
} }
// FmtPolicyRulesWithSubjectsSlim produces a golang source expression // FmtPolicyRulesWithSubjectsSlim produces a golang source expression
@ -182,7 +182,7 @@ func FmtPolicyRulesWithSubjectsSlim(rule flowcontrol.PolicyRulesWithSubjects) st
// expression for the given value to the given buffer but excludes the // expression for the given value to the given buffer but excludes the
// leading type name // leading type name
func BufferFmtPolicyRulesWithSubjectsSlim(buf *bytes.Buffer, rule flowcontrol.PolicyRulesWithSubjects) { func BufferFmtPolicyRulesWithSubjectsSlim(buf *bytes.Buffer, rule flowcontrol.PolicyRulesWithSubjects) {
buf.WriteString("{Subjects: []flowcontrolv1beta3.Subject{") buf.WriteString("{Subjects: []flowcontrolv1.Subject{")
for jdx, subj := range rule.Subjects { for jdx, subj := range rule.Subjects {
if jdx > 0 { if jdx > 0 {
buf.WriteString(", ") buf.WriteString(", ")

View File

@ -24,7 +24,7 @@ import (
"k8s.io/utils/clock" "k8s.io/utils/clock"
flowcontrol "k8s.io/api/flowcontrol/v1beta3" flowcontrol "k8s.io/api/flowcontrol/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
fcboot "k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap" fcboot "k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"

View File

@ -21,7 +21,7 @@ import (
"math/rand" "math/rand"
"testing" "testing"
flowcontrol "k8s.io/api/flowcontrol/v1beta3" flowcontrol "k8s.io/api/flowcontrol/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apiserver/pkg/authentication/user" "k8s.io/apiserver/pkg/authentication/user"

View File

@ -20,7 +20,7 @@ import (
"testing" "testing"
"time" "time"
"k8s.io/api/flowcontrol/v1beta3" flowcontrolv1 "k8s.io/api/flowcontrol/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
fqs "k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/queueset" fqs "k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/queueset"
"k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/testing/eventclock" "k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/testing/eventclock"
@ -97,7 +97,7 @@ func Test_GetMaxSeats(t *testing.T) {
t.Run(testcase.name, func(t *testing.T) { t.Run(testcase.name, func(t *testing.T) {
clientset := clientsetfake.NewSimpleClientset() clientset := clientsetfake.NewSimpleClientset()
informerFactory := informers.NewSharedInformerFactory(clientset, time.Second) informerFactory := informers.NewSharedInformerFactory(clientset, time.Second)
flowcontrolClient := clientset.FlowcontrolV1beta3() flowcontrolClient := clientset.FlowcontrolV1()
startTime := time.Now() startTime := time.Now()
clk, _ := eventclock.NewFake(startTime, 0, nil) clk, _ := eventclock.NewFake(startTime, 0, nil)
c := newTestableController(TestableConfig{ c := newTestableController(TestableConfig{
@ -113,23 +113,23 @@ func Test_GetMaxSeats(t *testing.T) {
QueueSetFactory: fqs.NewQueueSetFactory(clk), QueueSetFactory: fqs.NewQueueSetFactory(clk),
}) })
testPriorityLevel := &v1beta3.PriorityLevelConfiguration{ testPriorityLevel := &flowcontrolv1.PriorityLevelConfiguration{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "test-pl", Name: "test-pl",
}, },
Spec: v1beta3.PriorityLevelConfigurationSpec{ Spec: flowcontrolv1.PriorityLevelConfigurationSpec{
Type: v1beta3.PriorityLevelEnablementLimited, Type: flowcontrolv1.PriorityLevelEnablementLimited,
Limited: &v1beta3.LimitedPriorityLevelConfiguration{ Limited: &flowcontrolv1.LimitedPriorityLevelConfiguration{
NominalConcurrencyShares: 10000, NominalConcurrencyShares: 10000,
LimitResponse: v1beta3.LimitResponse{ LimitResponse: flowcontrolv1.LimitResponse{
Queuing: &v1beta3.QueuingConfiguration{ Queuing: &flowcontrolv1.QueuingConfiguration{
HandSize: testcase.handSize, HandSize: testcase.handSize,
}, },
}, },
}, },
}, },
} }
c.digestConfigObjects([]*v1beta3.PriorityLevelConfiguration{testPriorityLevel}, nil) c.digestConfigObjects([]*flowcontrolv1.PriorityLevelConfiguration{testPriorityLevel}, nil)
maxSeats := c.GetMaxSeats("test-pl") maxSeats := c.GetMaxSeats("test-pl")
if maxSeats != testcase.expectedMaxSeats { if maxSeats != testcase.expectedMaxSeats {
t.Errorf("unexpected max seats, got=%d, want=%d", maxSeats, testcase.expectedMaxSeats) t.Errorf("unexpected max seats, got=%d, want=%d", maxSeats, testcase.expectedMaxSeats)

View File

@ -19,7 +19,7 @@ package flowcontrol
import ( import (
"strings" "strings"
flowcontrol "k8s.io/api/flowcontrol/v1beta3" flowcontrol "k8s.io/api/flowcontrol/v1"
"k8s.io/apiserver/pkg/authentication/serviceaccount" "k8s.io/apiserver/pkg/authentication/serviceaccount"
"k8s.io/apiserver/pkg/authentication/user" "k8s.io/apiserver/pkg/authentication/user"
"k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/endpoints/request"

View File

@ -31,7 +31,7 @@ import (
"github.com/prometheus/common/expfmt" "github.com/prometheus/common/expfmt"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
flowcontrol "k8s.io/api/flowcontrol/v1beta3" flowcontrol "k8s.io/api/flowcontrol/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apiserver/pkg/util/apihelpers" "k8s.io/apiserver/pkg/util/apihelpers"
@ -251,7 +251,7 @@ var _ = SIGDescribe("API priority and fairness", func() {
// createPriorityLevel creates a priority level with the provided assured // createPriorityLevel creates a priority level with the provided assured
// concurrency share. // concurrency share.
func createPriorityLevel(ctx context.Context, f *framework.Framework, priorityLevelName string, nominalConcurrencyShares int32) *flowcontrol.PriorityLevelConfiguration { func createPriorityLevel(ctx context.Context, f *framework.Framework, priorityLevelName string, nominalConcurrencyShares int32) *flowcontrol.PriorityLevelConfiguration {
createdPriorityLevel, err := f.ClientSet.FlowcontrolV1beta3().PriorityLevelConfigurations().Create( createdPriorityLevel, err := f.ClientSet.FlowcontrolV1().PriorityLevelConfigurations().Create(
ctx, ctx,
&flowcontrol.PriorityLevelConfiguration{ &flowcontrol.PriorityLevelConfiguration{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
@ -269,7 +269,7 @@ func createPriorityLevel(ctx context.Context, f *framework.Framework, priorityLe
}, },
metav1.CreateOptions{}) metav1.CreateOptions{})
framework.ExpectNoError(err) framework.ExpectNoError(err)
ginkgo.DeferCleanup(f.ClientSet.FlowcontrolV1beta3().PriorityLevelConfigurations().Delete, priorityLevelName, metav1.DeleteOptions{}) ginkgo.DeferCleanup(f.ClientSet.FlowcontrolV1().PriorityLevelConfigurations().Delete, priorityLevelName, metav1.DeleteOptions{})
return createdPriorityLevel return createdPriorityLevel
} }
@ -318,7 +318,7 @@ func createFlowSchema(ctx context.Context, f *framework.Framework, flowSchemaNam
}) })
} }
createdFlowSchema, err := f.ClientSet.FlowcontrolV1beta3().FlowSchemas().Create( createdFlowSchema, err := f.ClientSet.FlowcontrolV1().FlowSchemas().Create(
ctx, ctx,
&flowcontrol.FlowSchema{ &flowcontrol.FlowSchema{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
@ -347,7 +347,7 @@ func createFlowSchema(ctx context.Context, f *framework.Framework, flowSchemaNam
}, },
metav1.CreateOptions{}) metav1.CreateOptions{})
framework.ExpectNoError(err) framework.ExpectNoError(err)
ginkgo.DeferCleanup(f.ClientSet.FlowcontrolV1beta3().FlowSchemas().Delete, flowSchemaName, metav1.DeleteOptions{}) ginkgo.DeferCleanup(f.ClientSet.FlowcontrolV1().FlowSchemas().Delete, flowSchemaName, metav1.DeleteOptions{})
return createdFlowSchema return createdFlowSchema
} }
@ -357,7 +357,7 @@ func createFlowSchema(ctx context.Context, f *framework.Framework, flowSchemaNam
// schema status, and (2) metrics. The function times out after 30 seconds. // schema status, and (2) metrics. The function times out after 30 seconds.
func waitForSteadyState(ctx context.Context, f *framework.Framework, flowSchemaName string, priorityLevelName string) { func waitForSteadyState(ctx context.Context, f *framework.Framework, flowSchemaName string, priorityLevelName string) {
framework.ExpectNoError(wait.PollWithContext(ctx, time.Second, 30*time.Second, func(ctx context.Context) (bool, error) { framework.ExpectNoError(wait.PollWithContext(ctx, time.Second, 30*time.Second, func(ctx context.Context) (bool, error) {
fs, err := f.ClientSet.FlowcontrolV1beta3().FlowSchemas().Get(ctx, flowSchemaName, metav1.GetOptions{}) fs, err := f.ClientSet.FlowcontrolV1().FlowSchemas().Get(ctx, flowSchemaName, metav1.GetOptions{})
if err != nil { if err != nil {
return false, err return false, err
} }

View File

@ -28,7 +28,7 @@ import (
"github.com/prometheus/common/expfmt" "github.com/prometheus/common/expfmt"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
flowcontrol "k8s.io/api/flowcontrol/v1beta3" flowcontrol "k8s.io/api/flowcontrol/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
genericfeatures "k8s.io/apiserver/pkg/features" genericfeatures "k8s.io/apiserver/pkg/features"
@ -240,7 +240,7 @@ func getRequestCountOfPriorityLevel(c clientset.Interface) (map[string]int, map[
func createPriorityLevelAndBindingFlowSchemaForUser(c clientset.Interface, username string, concurrencyShares, queuelength int) (*flowcontrol.PriorityLevelConfiguration, *flowcontrol.FlowSchema, error) { func createPriorityLevelAndBindingFlowSchemaForUser(c clientset.Interface, username string, concurrencyShares, queuelength int) (*flowcontrol.PriorityLevelConfiguration, *flowcontrol.FlowSchema, error) {
i0 := int32(0) i0 := int32(0)
pl, err := c.FlowcontrolV1beta3().PriorityLevelConfigurations().Create(context.Background(), &flowcontrol.PriorityLevelConfiguration{ pl, err := c.FlowcontrolV1().PriorityLevelConfigurations().Create(context.Background(), &flowcontrol.PriorityLevelConfiguration{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: username, Name: username,
}, },
@ -263,7 +263,7 @@ func createPriorityLevelAndBindingFlowSchemaForUser(c clientset.Interface, usern
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
fs, err := c.FlowcontrolV1beta3().FlowSchemas().Create(context.TODO(), &flowcontrol.FlowSchema{ fs, err := c.FlowcontrolV1().FlowSchemas().Create(context.TODO(), &flowcontrol.FlowSchema{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: username, Name: username,
}, },
@ -303,7 +303,7 @@ func createPriorityLevelAndBindingFlowSchemaForUser(c clientset.Interface, usern
} }
return pl, fs, wait.Poll(time.Second, timeout, func() (bool, error) { return pl, fs, wait.Poll(time.Second, timeout, func() (bool, error) {
fs, err := c.FlowcontrolV1beta3().FlowSchemas().Get(context.TODO(), username, metav1.GetOptions{}) fs, err := c.FlowcontrolV1().FlowSchemas().Get(context.TODO(), username, metav1.GetOptions{})
if err != nil { if err != nil {
return false, err return false, err
} }

View File

@ -25,7 +25,7 @@ import (
"testing" "testing"
"time" "time"
flowcontrol "k8s.io/api/flowcontrol/v1beta3" flowcontrol "k8s.io/api/flowcontrol/v1"
genericfeatures "k8s.io/apiserver/pkg/features" genericfeatures "k8s.io/apiserver/pkg/features"
utilfeature "k8s.io/apiserver/pkg/util/feature" utilfeature "k8s.io/apiserver/pkg/util/feature"
utilfc "k8s.io/apiserver/pkg/util/flowcontrol" utilfc "k8s.io/apiserver/pkg/util/flowcontrol"
@ -98,7 +98,7 @@ func (ft *fightTest) createMainInformer() {
myConfig = rest.AddUserAgent(myConfig, "audience") myConfig = rest.AddUserAgent(myConfig, "audience")
myClientset := clientset.NewForConfigOrDie(myConfig) myClientset := clientset.NewForConfigOrDie(myConfig)
informerFactory := informers.NewSharedInformerFactory(myClientset, 0) informerFactory := informers.NewSharedInformerFactory(myClientset, 0)
inf := informerFactory.Flowcontrol().V1beta3().FlowSchemas().Informer() inf := informerFactory.Flowcontrol().V1().FlowSchemas().Informer()
inf.AddEventHandler(cache.ResourceEventHandlerFuncs{ inf.AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) { AddFunc: func(obj interface{}) {
fs := obj.(*flowcontrol.FlowSchema) fs := obj.(*flowcontrol.FlowSchema)
@ -126,7 +126,7 @@ func (ft *fightTest) createController(invert bool, i int) {
myConfig := rest.CopyConfig(ft.loopbackConfig) myConfig := rest.CopyConfig(ft.loopbackConfig)
myConfig = rest.AddUserAgent(myConfig, fieldMgr) myConfig = rest.AddUserAgent(myConfig, fieldMgr)
myClientset := clientset.NewForConfigOrDie(myConfig) myClientset := clientset.NewForConfigOrDie(myConfig)
fcIfc := myClientset.FlowcontrolV1beta3() fcIfc := myClientset.FlowcontrolV1()
informerFactory := informers.NewSharedInformerFactory(myClientset, 0) informerFactory := informers.NewSharedInformerFactory(myClientset, 0)
foundToDangling := func(found bool) bool { return !found } foundToDangling := func(found bool) bool { return !found }
if invert { if invert {

View File

@ -21,14 +21,14 @@ import (
"testing" "testing"
"time" "time"
flowcontrol "k8s.io/api/flowcontrol/v1beta3" flowcontrol "k8s.io/api/flowcontrol/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
machinerytypes "k8s.io/apimachinery/pkg/types" machinerytypes "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
fcboot "k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap" fcboot "k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
genericfeatures "k8s.io/apiserver/pkg/features" genericfeatures "k8s.io/apiserver/pkg/features"
utilfeature "k8s.io/apiserver/pkg/util/feature" utilfeature "k8s.io/apiserver/pkg/util/feature"
flowcontrolapply "k8s.io/client-go/applyconfigurations/flowcontrol/v1beta3" flowcontrolapply "k8s.io/client-go/applyconfigurations/flowcontrol/v1"
clientset "k8s.io/client-go/kubernetes" clientset "k8s.io/client-go/kubernetes"
featuregatetesting "k8s.io/component-base/featuregate/testing" featuregatetesting "k8s.io/component-base/featuregate/testing"
"k8s.io/klog/v2" "k8s.io/klog/v2"
@ -44,7 +44,7 @@ func TestConditionIsolation(t *testing.T) {
fsOrig := fcboot.SuggestedFlowSchemas[0] fsOrig := fcboot.SuggestedFlowSchemas[0]
t.Logf("Testing Status Condition isolation in FlowSchema %q", fsOrig.Name) t.Logf("Testing Status Condition isolation in FlowSchema %q", fsOrig.Name)
fsClient := loopbackClient.FlowcontrolV1beta3().FlowSchemas() fsClient := loopbackClient.FlowcontrolV1().FlowSchemas()
var dangleOrig *flowcontrol.FlowSchemaCondition var dangleOrig *flowcontrol.FlowSchemaCondition
wait.PollUntil(time.Second, func() (bool, error) { wait.PollUntil(time.Second, func() (bool, error) {