apiserver: update apf logic to use v1beta3

This commit is contained in:
Abu Kashem 2022-09-10 07:26:31 -04:00
parent 6edc251686
commit 0a99e6ebb1
No known key found for this signature in database
GPG Key ID: 33A4FA7088DB68A9
21 changed files with 172 additions and 172 deletions

View File

@ -507,7 +507,7 @@ func BuildPriorityAndFairness(s *options.ServerRunOptions, extclient clientgocli
}
return utilflowcontrol.New(
versionedInformer,
extclient.FlowcontrolV1beta2(),
extclient.FlowcontrolV1beta3(),
s.GenericServerRunOptions.MaxRequestsInFlight+s.GenericServerRunOptions.MaxMutatingRequestsInFlight,
s.GenericServerRunOptions.RequestTimeout/4,
), nil

View File

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

View File

@ -19,7 +19,7 @@ package internalbootstrap
import (
"testing"
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
)

View File

@ -21,15 +21,15 @@ import (
"errors"
"fmt"
flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2"
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3"
"k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets"
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta2"
flowcontrolapisv1beta2 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta2"
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta3"
flowcontrolapisv1beta3 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta3"
)
var (
@ -38,7 +38,7 @@ var (
// FlowSchemaEnsurer ensures the specified bootstrap configuration objects
type FlowSchemaEnsurer interface {
Ensure([]*flowcontrolv1beta2.FlowSchema) error
Ensure([]*flowcontrolv1beta3.FlowSchema) error
}
// FlowSchemaRemover is the interface that wraps the
@ -92,7 +92,7 @@ func NewFlowSchemaRemover(client flowcontrolclient.FlowSchemaInterface, lister f
// names that are candidates for deletion from the cluster.
// bootstrap: a set of hard coded FlowSchema configuration objects
// kube-apiserver maintains in-memory.
func GetFlowSchemaRemoveCandidates(lister flowcontrollisters.FlowSchemaLister, bootstrap []*flowcontrolv1beta2.FlowSchema) ([]string, error) {
func GetFlowSchemaRemoveCandidates(lister flowcontrollisters.FlowSchemaLister, bootstrap []*flowcontrolv1beta3.FlowSchema) ([]string, error) {
fsList, err := lister.List(labels.Everything())
if err != nil {
return nil, fmt.Errorf("failed to list FlowSchema - %w", err)
@ -116,7 +116,7 @@ type fsEnsurer struct {
wrapper configurationWrapper
}
func (e *fsEnsurer) Ensure(flowSchemas []*flowcontrolv1beta2.FlowSchema) error {
func (e *fsEnsurer) Ensure(flowSchemas []*flowcontrolv1beta3.FlowSchema) error {
for _, flowSchema := range flowSchemas {
if err := ensureConfiguration(e.wrapper, e.strategy, flowSchema); err != nil {
return err
@ -148,7 +148,7 @@ func (fs *flowSchemaWrapper) TypeName() string {
}
func (fs *flowSchemaWrapper) Create(object runtime.Object) (runtime.Object, error) {
fsObject, ok := object.(*flowcontrolv1beta2.FlowSchema)
fsObject, ok := object.(*flowcontrolv1beta3.FlowSchema)
if !ok {
return nil, errObjectNotFlowSchema
}
@ -157,7 +157,7 @@ func (fs *flowSchemaWrapper) Create(object runtime.Object) (runtime.Object, erro
}
func (fs *flowSchemaWrapper) Update(object runtime.Object) (runtime.Object, error) {
fsObject, ok := object.(*flowcontrolv1beta2.FlowSchema)
fsObject, ok := object.(*flowcontrolv1beta3.FlowSchema)
if !ok {
return nil, errObjectNotFlowSchema
}
@ -174,11 +174,11 @@ func (fs *flowSchemaWrapper) Delete(name string) error {
}
func (fs *flowSchemaWrapper) CopySpec(bootstrap, current runtime.Object) error {
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta2.FlowSchema)
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta3.FlowSchema)
if !ok {
return errObjectNotFlowSchema
}
currentFS, ok := current.(*flowcontrolv1beta2.FlowSchema)
currentFS, ok := current.(*flowcontrolv1beta3.FlowSchema)
if !ok {
return errObjectNotFlowSchema
}
@ -189,11 +189,11 @@ func (fs *flowSchemaWrapper) CopySpec(bootstrap, current runtime.Object) error {
}
func (fs *flowSchemaWrapper) HasSpecChanged(bootstrap, current runtime.Object) (bool, error) {
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta2.FlowSchema)
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta3.FlowSchema)
if !ok {
return false, errObjectNotFlowSchema
}
currentFS, ok := current.(*flowcontrolv1beta2.FlowSchema)
currentFS, ok := current.(*flowcontrolv1beta3.FlowSchema)
if !ok {
return false, errObjectNotFlowSchema
}
@ -201,8 +201,8 @@ func (fs *flowSchemaWrapper) HasSpecChanged(bootstrap, current runtime.Object) (
return flowSchemaSpecChanged(bootstrapFS, currentFS), nil
}
func flowSchemaSpecChanged(expected, actual *flowcontrolv1beta2.FlowSchema) bool {
func flowSchemaSpecChanged(expected, actual *flowcontrolv1beta3.FlowSchema) bool {
copiedExpectedFlowSchema := expected.DeepCopy()
flowcontrolapisv1beta2.SetObjectDefaults_FlowSchema(copiedExpectedFlowSchema)
flowcontrolapisv1beta3.SetObjectDefaults_FlowSchema(copiedExpectedFlowSchema)
return !equality.Semantic.DeepEqual(copiedExpectedFlowSchema.Spec, actual.Spec)
}

View File

@ -21,15 +21,15 @@ import (
"reflect"
"testing"
flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2"
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
"k8s.io/client-go/kubernetes/fake"
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta2"
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta3"
"k8s.io/client-go/tools/cache"
flowcontrolapisv1beta2 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta2"
flowcontrolapisv1beta3 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta3"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
@ -40,9 +40,9 @@ func TestEnsureFlowSchema(t *testing.T) {
tests := []struct {
name string
strategy func(flowcontrolclient.FlowSchemaInterface, flowcontrollisters.FlowSchemaLister) FlowSchemaEnsurer
current *flowcontrolv1beta2.FlowSchema
bootstrap *flowcontrolv1beta2.FlowSchema
expected *flowcontrolv1beta2.FlowSchema
current *flowcontrolv1beta3.FlowSchema
bootstrap *flowcontrolv1beta3.FlowSchema
expected *flowcontrolv1beta3.FlowSchema
}{
// for suggested configurations
{
@ -93,7 +93,7 @@ func TestEnsureFlowSchema(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
client := fake.NewSimpleClientset().FlowcontrolV1beta2().FlowSchemas()
client := fake.NewSimpleClientset().FlowcontrolV1beta3().FlowSchemas()
indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
if test.current != nil {
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
@ -102,7 +102,7 @@ func TestEnsureFlowSchema(t *testing.T) {
ensurer := test.strategy(client, flowcontrollisters.NewFlowSchemaLister(indexer))
err := ensurer.Ensure([]*flowcontrolv1beta2.FlowSchema{test.bootstrap})
err := ensurer.Ensure([]*flowcontrolv1beta3.FlowSchema{test.bootstrap})
if err != nil {
t.Fatalf("Expected no error, but got: %v", err)
}
@ -127,9 +127,9 @@ func TestEnsureFlowSchema(t *testing.T) {
func TestSuggestedFSEnsureStrategy_ShouldUpdate(t *testing.T) {
tests := []struct {
name string
current *flowcontrolv1beta2.FlowSchema
bootstrap *flowcontrolv1beta2.FlowSchema
newObjectExpected *flowcontrolv1beta2.FlowSchema
current *flowcontrolv1beta3.FlowSchema
bootstrap *flowcontrolv1beta3.FlowSchema
newObjectExpected *flowcontrolv1beta3.FlowSchema
}{
{
name: "auto update is enabled, first generation, spec does not match - spec update expected",
@ -234,23 +234,23 @@ func TestSuggestedFSEnsureStrategy_ShouldUpdate(t *testing.T) {
}
func TestFlowSchemaSpecChanged(t *testing.T) {
fs1 := &flowcontrolv1beta2.FlowSchema{
Spec: flowcontrolv1beta2.FlowSchemaSpec{},
fs1 := &flowcontrolv1beta3.FlowSchema{
Spec: flowcontrolv1beta3.FlowSchemaSpec{},
}
fs2 := &flowcontrolv1beta2.FlowSchema{
Spec: flowcontrolv1beta2.FlowSchemaSpec{
fs2 := &flowcontrolv1beta3.FlowSchema{
Spec: flowcontrolv1beta3.FlowSchemaSpec{
MatchingPrecedence: 1,
},
}
fs1Defaulted := &flowcontrolv1beta2.FlowSchema{
Spec: flowcontrolv1beta2.FlowSchemaSpec{
MatchingPrecedence: flowcontrolapisv1beta2.FlowSchemaDefaultMatchingPrecedence,
fs1Defaulted := &flowcontrolv1beta3.FlowSchema{
Spec: flowcontrolv1beta3.FlowSchemaSpec{
MatchingPrecedence: flowcontrolapisv1beta3.FlowSchemaDefaultMatchingPrecedence,
},
}
testCases := []struct {
name string
expected *flowcontrolv1beta2.FlowSchema
actual *flowcontrolv1beta2.FlowSchema
expected *flowcontrolv1beta3.FlowSchema
actual *flowcontrolv1beta3.FlowSchema
specChanged bool
}{
{
@ -283,7 +283,7 @@ func TestFlowSchemaSpecChanged(t *testing.T) {
func TestRemoveFlowSchema(t *testing.T) {
tests := []struct {
name string
current *flowcontrolv1beta2.FlowSchema
current *flowcontrolv1beta3.FlowSchema
bootstrapName string
removeExpected bool
}{
@ -314,7 +314,7 @@ func TestRemoveFlowSchema(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
client := fake.NewSimpleClientset().FlowcontrolV1beta2().FlowSchemas()
client := fake.NewSimpleClientset().FlowcontrolV1beta3().FlowSchemas()
indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
if test.current != nil {
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
@ -348,18 +348,18 @@ func TestRemoveFlowSchema(t *testing.T) {
func TestGetFlowSchemaRemoveCandidate(t *testing.T) {
tests := []struct {
name string
current []*flowcontrolv1beta2.FlowSchema
bootstrap []*flowcontrolv1beta2.FlowSchema
current []*flowcontrolv1beta3.FlowSchema
bootstrap []*flowcontrolv1beta3.FlowSchema
expected []string
}{
{
name: "no object has been removed from the bootstrap configuration",
bootstrap: []*flowcontrolv1beta2.FlowSchema{
bootstrap: []*flowcontrolv1beta3.FlowSchema{
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
newFlowSchema("fs2", "pl2", 200).WithAutoUpdateAnnotation("true").Object(),
newFlowSchema("fs3", "pl3", 300).WithAutoUpdateAnnotation("true").Object(),
},
current: []*flowcontrolv1beta2.FlowSchema{
current: []*flowcontrolv1beta3.FlowSchema{
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
newFlowSchema("fs2", "pl2", 200).WithAutoUpdateAnnotation("true").Object(),
newFlowSchema("fs3", "pl3", 300).WithAutoUpdateAnnotation("true").Object(),
@ -368,8 +368,8 @@ func TestGetFlowSchemaRemoveCandidate(t *testing.T) {
},
{
name: "bootstrap is empty, all current objects with the annotation should be candidates",
bootstrap: []*flowcontrolv1beta2.FlowSchema{},
current: []*flowcontrolv1beta2.FlowSchema{
bootstrap: []*flowcontrolv1beta3.FlowSchema{},
current: []*flowcontrolv1beta3.FlowSchema{
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
newFlowSchema("fs2", "pl2", 200).WithAutoUpdateAnnotation("true").Object(),
newFlowSchema("fs3", "pl3", 300).Object(),
@ -378,10 +378,10 @@ func TestGetFlowSchemaRemoveCandidate(t *testing.T) {
},
{
name: "object(s) have been removed from the bootstrap configuration",
bootstrap: []*flowcontrolv1beta2.FlowSchema{
bootstrap: []*flowcontrolv1beta3.FlowSchema{
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
},
current: []*flowcontrolv1beta2.FlowSchema{
current: []*flowcontrolv1beta3.FlowSchema{
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
newFlowSchema("fs2", "pl2", 200).WithAutoUpdateAnnotation("true").Object(),
newFlowSchema("fs3", "pl3", 300).WithAutoUpdateAnnotation("true").Object(),
@ -390,10 +390,10 @@ func TestGetFlowSchemaRemoveCandidate(t *testing.T) {
},
{
name: "object(s) without the annotation key are ignored",
bootstrap: []*flowcontrolv1beta2.FlowSchema{
bootstrap: []*flowcontrolv1beta3.FlowSchema{
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
},
current: []*flowcontrolv1beta2.FlowSchema{
current: []*flowcontrolv1beta3.FlowSchema{
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
newFlowSchema("fs2", "pl2", 200).Object(),
newFlowSchema("fs3", "pl3", 300).Object(),
@ -425,17 +425,17 @@ func TestGetFlowSchemaRemoveCandidate(t *testing.T) {
}
type fsBuilder struct {
object *flowcontrolv1beta2.FlowSchema
object *flowcontrolv1beta3.FlowSchema
}
func newFlowSchema(name, plName string, matchingPrecedence int32) *fsBuilder {
return &fsBuilder{
object: &flowcontrolv1beta2.FlowSchema{
object: &flowcontrolv1beta3.FlowSchema{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
Spec: flowcontrolv1beta2.FlowSchemaSpec{
PriorityLevelConfiguration: flowcontrolv1beta2.PriorityLevelConfigurationReference{
Spec: flowcontrolv1beta3.FlowSchemaSpec{
PriorityLevelConfiguration: flowcontrolv1beta3.PriorityLevelConfigurationReference{
Name: plName,
},
MatchingPrecedence: matchingPrecedence,
@ -444,7 +444,7 @@ func newFlowSchema(name, plName string, matchingPrecedence int32) *fsBuilder {
}
}
func (b *fsBuilder) Object() *flowcontrolv1beta2.FlowSchema {
func (b *fsBuilder) Object() *flowcontrolv1beta3.FlowSchema {
return b.object
}
@ -463,5 +463,5 @@ func setAnnotation(accessor metav1.Object, value string) {
accessor.SetAnnotations(map[string]string{})
}
accessor.GetAnnotations()[flowcontrolv1beta2.AutoUpdateAnnotationKey] = value
accessor.GetAnnotations()[flowcontrolv1beta3.AutoUpdateAnnotationKey] = value
}

View File

@ -21,15 +21,15 @@ import (
"errors"
"fmt"
flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2"
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3"
"k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets"
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta2"
flowcontrolapisv1beta2 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta2"
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta3"
flowcontrolapisv1beta3 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta3"
)
var (
@ -38,7 +38,7 @@ var (
// PriorityLevelEnsurer ensures the specified bootstrap configuration objects
type PriorityLevelEnsurer interface {
Ensure([]*flowcontrolv1beta2.PriorityLevelConfiguration) error
Ensure([]*flowcontrolv1beta3.PriorityLevelConfiguration) error
}
// PriorityLevelRemover is the interface that wraps the
@ -93,7 +93,7 @@ func NewPriorityLevelRemover(client flowcontrolclient.PriorityLevelConfiguration
// names that are candidates for removal from the cluster.
// bootstrap: a set of hard coded PriorityLevelConfiguration configuration
// objects kube-apiserver maintains in-memory.
func GetPriorityLevelRemoveCandidates(lister flowcontrollisters.PriorityLevelConfigurationLister, bootstrap []*flowcontrolv1beta2.PriorityLevelConfiguration) ([]string, error) {
func GetPriorityLevelRemoveCandidates(lister flowcontrollisters.PriorityLevelConfigurationLister, bootstrap []*flowcontrolv1beta3.PriorityLevelConfiguration) ([]string, error) {
plList, err := lister.List(labels.Everything())
if err != nil {
return nil, fmt.Errorf("failed to list PriorityLevelConfiguration - %w", err)
@ -117,7 +117,7 @@ type plEnsurer struct {
wrapper configurationWrapper
}
func (e *plEnsurer) Ensure(priorityLevels []*flowcontrolv1beta2.PriorityLevelConfiguration) error {
func (e *plEnsurer) Ensure(priorityLevels []*flowcontrolv1beta3.PriorityLevelConfiguration) error {
for _, priorityLevel := range priorityLevels {
if err := ensureConfiguration(e.wrapper, e.strategy, priorityLevel); err != nil {
return err
@ -149,7 +149,7 @@ func (fs *priorityLevelConfigurationWrapper) TypeName() string {
}
func (fs *priorityLevelConfigurationWrapper) Create(object runtime.Object) (runtime.Object, error) {
plObject, ok := object.(*flowcontrolv1beta2.PriorityLevelConfiguration)
plObject, ok := object.(*flowcontrolv1beta3.PriorityLevelConfiguration)
if !ok {
return nil, errObjectNotPriorityLevel
}
@ -158,7 +158,7 @@ func (fs *priorityLevelConfigurationWrapper) Create(object runtime.Object) (runt
}
func (fs *priorityLevelConfigurationWrapper) Update(object runtime.Object) (runtime.Object, error) {
fsObject, ok := object.(*flowcontrolv1beta2.PriorityLevelConfiguration)
fsObject, ok := object.(*flowcontrolv1beta3.PriorityLevelConfiguration)
if !ok {
return nil, errObjectNotPriorityLevel
}
@ -175,11 +175,11 @@ func (fs *priorityLevelConfigurationWrapper) Delete(name string) error {
}
func (fs *priorityLevelConfigurationWrapper) CopySpec(bootstrap, current runtime.Object) error {
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta2.PriorityLevelConfiguration)
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta3.PriorityLevelConfiguration)
if !ok {
return errObjectNotPriorityLevel
}
currentFS, ok := current.(*flowcontrolv1beta2.PriorityLevelConfiguration)
currentFS, ok := current.(*flowcontrolv1beta3.PriorityLevelConfiguration)
if !ok {
return errObjectNotPriorityLevel
}
@ -190,11 +190,11 @@ func (fs *priorityLevelConfigurationWrapper) CopySpec(bootstrap, current runtime
}
func (fs *priorityLevelConfigurationWrapper) HasSpecChanged(bootstrap, current runtime.Object) (bool, error) {
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta2.PriorityLevelConfiguration)
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta3.PriorityLevelConfiguration)
if !ok {
return false, errObjectNotPriorityLevel
}
currentFS, ok := current.(*flowcontrolv1beta2.PriorityLevelConfiguration)
currentFS, ok := current.(*flowcontrolv1beta3.PriorityLevelConfiguration)
if !ok {
return false, errObjectNotPriorityLevel
}
@ -202,8 +202,8 @@ func (fs *priorityLevelConfigurationWrapper) HasSpecChanged(bootstrap, current r
return priorityLevelSpecChanged(bootstrapFS, currentFS), nil
}
func priorityLevelSpecChanged(expected, actual *flowcontrolv1beta2.PriorityLevelConfiguration) bool {
func priorityLevelSpecChanged(expected, actual *flowcontrolv1beta3.PriorityLevelConfiguration) bool {
copiedExpectedPriorityLevel := expected.DeepCopy()
flowcontrolapisv1beta2.SetObjectDefaults_PriorityLevelConfiguration(copiedExpectedPriorityLevel)
flowcontrolapisv1beta3.SetObjectDefaults_PriorityLevelConfiguration(copiedExpectedPriorityLevel)
return !equality.Semantic.DeepEqual(copiedExpectedPriorityLevel.Spec, actual.Spec)
}

View File

@ -21,15 +21,15 @@ import (
"reflect"
"testing"
flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2"
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
"k8s.io/client-go/kubernetes/fake"
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta2"
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta3"
"k8s.io/client-go/tools/cache"
flowcontrolapisv1beta2 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta2"
flowcontrolapisv1beta3 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta3"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
@ -40,9 +40,9 @@ func TestEnsurePriorityLevel(t *testing.T) {
tests := []struct {
name string
strategy func(flowcontrolclient.PriorityLevelConfigurationInterface, flowcontrollisters.PriorityLevelConfigurationLister) PriorityLevelEnsurer
current *flowcontrolv1beta2.PriorityLevelConfiguration
bootstrap *flowcontrolv1beta2.PriorityLevelConfiguration
expected *flowcontrolv1beta2.PriorityLevelConfiguration
current *flowcontrolv1beta3.PriorityLevelConfiguration
bootstrap *flowcontrolv1beta3.PriorityLevelConfiguration
expected *flowcontrolv1beta3.PriorityLevelConfiguration
}{
// for suggested configurations
{
@ -93,7 +93,7 @@ func TestEnsurePriorityLevel(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
client := fake.NewSimpleClientset().FlowcontrolV1beta2().PriorityLevelConfigurations()
client := fake.NewSimpleClientset().FlowcontrolV1beta3().PriorityLevelConfigurations()
indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
if test.current != nil {
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
@ -102,7 +102,7 @@ func TestEnsurePriorityLevel(t *testing.T) {
ensurer := test.strategy(client, flowcontrollisters.NewPriorityLevelConfigurationLister(indexer))
err := ensurer.Ensure([]*flowcontrolv1beta2.PriorityLevelConfiguration{test.bootstrap})
err := ensurer.Ensure([]*flowcontrolv1beta3.PriorityLevelConfiguration{test.bootstrap})
if err != nil {
t.Fatalf("Expected no error, but got: %v", err)
}
@ -127,9 +127,9 @@ func TestEnsurePriorityLevel(t *testing.T) {
func TestSuggestedPLEnsureStrategy_ShouldUpdate(t *testing.T) {
tests := []struct {
name string
current *flowcontrolv1beta2.PriorityLevelConfiguration
bootstrap *flowcontrolv1beta2.PriorityLevelConfiguration
newObjectExpected *flowcontrolv1beta2.PriorityLevelConfiguration
current *flowcontrolv1beta3.PriorityLevelConfiguration
bootstrap *flowcontrolv1beta3.PriorityLevelConfiguration
newObjectExpected *flowcontrolv1beta3.PriorityLevelConfiguration
}{
{
name: "auto update is enabled, first generation, spec does not match - spec update expected",
@ -234,39 +234,39 @@ func TestSuggestedPLEnsureStrategy_ShouldUpdate(t *testing.T) {
}
func TestPriorityLevelSpecChanged(t *testing.T) {
pl1 := &flowcontrolv1beta2.PriorityLevelConfiguration{
Spec: flowcontrolv1beta2.PriorityLevelConfigurationSpec{
Type: flowcontrolv1beta2.PriorityLevelEnablementLimited,
Limited: &flowcontrolv1beta2.LimitedPriorityLevelConfiguration{
LimitResponse: flowcontrolv1beta2.LimitResponse{
Type: flowcontrolv1beta2.LimitResponseTypeReject,
pl1 := &flowcontrolv1beta3.PriorityLevelConfiguration{
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{
Type: flowcontrolv1beta3.PriorityLevelEnablementLimited,
Limited: &flowcontrolv1beta3.LimitedPriorityLevelConfiguration{
LimitResponse: flowcontrolv1beta3.LimitResponse{
Type: flowcontrolv1beta3.LimitResponseTypeReject,
},
},
},
}
pl2 := &flowcontrolv1beta2.PriorityLevelConfiguration{
Spec: flowcontrolv1beta2.PriorityLevelConfigurationSpec{
Type: flowcontrolv1beta2.PriorityLevelEnablementLimited,
Limited: &flowcontrolv1beta2.LimitedPriorityLevelConfiguration{
pl2 := &flowcontrolv1beta3.PriorityLevelConfiguration{
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{
Type: flowcontrolv1beta3.PriorityLevelEnablementLimited,
Limited: &flowcontrolv1beta3.LimitedPriorityLevelConfiguration{
AssuredConcurrencyShares: 1,
},
},
}
pl1Defaulted := &flowcontrolv1beta2.PriorityLevelConfiguration{
Spec: flowcontrolv1beta2.PriorityLevelConfigurationSpec{
Type: flowcontrolv1beta2.PriorityLevelEnablementLimited,
Limited: &flowcontrolv1beta2.LimitedPriorityLevelConfiguration{
AssuredConcurrencyShares: flowcontrolapisv1beta2.PriorityLevelConfigurationDefaultAssuredConcurrencyShares,
LimitResponse: flowcontrolv1beta2.LimitResponse{
Type: flowcontrolv1beta2.LimitResponseTypeReject,
pl1Defaulted := &flowcontrolv1beta3.PriorityLevelConfiguration{
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{
Type: flowcontrolv1beta3.PriorityLevelEnablementLimited,
Limited: &flowcontrolv1beta3.LimitedPriorityLevelConfiguration{
AssuredConcurrencyShares: flowcontrolapisv1beta3.PriorityLevelConfigurationDefaultAssuredConcurrencyShares,
LimitResponse: flowcontrolv1beta3.LimitResponse{
Type: flowcontrolv1beta3.LimitResponseTypeReject,
},
},
},
}
testCases := []struct {
name string
expected *flowcontrolv1beta2.PriorityLevelConfiguration
actual *flowcontrolv1beta2.PriorityLevelConfiguration
expected *flowcontrolv1beta3.PriorityLevelConfiguration
actual *flowcontrolv1beta3.PriorityLevelConfiguration
specChanged bool
}{
{
@ -299,7 +299,7 @@ func TestPriorityLevelSpecChanged(t *testing.T) {
func TestRemovePriorityLevelConfiguration(t *testing.T) {
tests := []struct {
name string
current *flowcontrolv1beta2.PriorityLevelConfiguration
current *flowcontrolv1beta3.PriorityLevelConfiguration
bootstrapName string
removeExpected bool
}{
@ -330,7 +330,7 @@ func TestRemovePriorityLevelConfiguration(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
client := fake.NewSimpleClientset().FlowcontrolV1beta2().PriorityLevelConfigurations()
client := fake.NewSimpleClientset().FlowcontrolV1beta3().PriorityLevelConfigurations()
indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
if test.current != nil {
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
@ -364,18 +364,18 @@ func TestRemovePriorityLevelConfiguration(t *testing.T) {
func TestGetPriorityLevelRemoveCandidate(t *testing.T) {
tests := []struct {
name string
current []*flowcontrolv1beta2.PriorityLevelConfiguration
bootstrap []*flowcontrolv1beta2.PriorityLevelConfiguration
current []*flowcontrolv1beta3.PriorityLevelConfiguration
bootstrap []*flowcontrolv1beta3.PriorityLevelConfiguration
expected []string
}{
{
name: "no object has been removed from the bootstrap configuration",
bootstrap: []*flowcontrolv1beta2.PriorityLevelConfiguration{
bootstrap: []*flowcontrolv1beta3.PriorityLevelConfiguration{
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
newPLConfiguration("pl2").WithAutoUpdateAnnotation("true").Object(),
newPLConfiguration("pl3").WithAutoUpdateAnnotation("true").Object(),
},
current: []*flowcontrolv1beta2.PriorityLevelConfiguration{
current: []*flowcontrolv1beta3.PriorityLevelConfiguration{
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
newPLConfiguration("pl2").WithAutoUpdateAnnotation("true").Object(),
newPLConfiguration("pl3").WithAutoUpdateAnnotation("true").Object(),
@ -384,8 +384,8 @@ func TestGetPriorityLevelRemoveCandidate(t *testing.T) {
},
{
name: "bootstrap is empty, all current objects with the annotation should be candidates",
bootstrap: []*flowcontrolv1beta2.PriorityLevelConfiguration{},
current: []*flowcontrolv1beta2.PriorityLevelConfiguration{
bootstrap: []*flowcontrolv1beta3.PriorityLevelConfiguration{},
current: []*flowcontrolv1beta3.PriorityLevelConfiguration{
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
newPLConfiguration("pl2").WithAutoUpdateAnnotation("true").Object(),
newPLConfiguration("pl3").Object(),
@ -394,10 +394,10 @@ func TestGetPriorityLevelRemoveCandidate(t *testing.T) {
},
{
name: "object(s) have been removed from the bootstrap configuration",
bootstrap: []*flowcontrolv1beta2.PriorityLevelConfiguration{
bootstrap: []*flowcontrolv1beta3.PriorityLevelConfiguration{
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
},
current: []*flowcontrolv1beta2.PriorityLevelConfiguration{
current: []*flowcontrolv1beta3.PriorityLevelConfiguration{
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
newPLConfiguration("pl2").WithAutoUpdateAnnotation("true").Object(),
newPLConfiguration("pl3").WithAutoUpdateAnnotation("true").Object(),
@ -406,10 +406,10 @@ func TestGetPriorityLevelRemoveCandidate(t *testing.T) {
},
{
name: "object(s) without the annotation key are ignored",
bootstrap: []*flowcontrolv1beta2.PriorityLevelConfiguration{
bootstrap: []*flowcontrolv1beta3.PriorityLevelConfiguration{
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
},
current: []*flowcontrolv1beta2.PriorityLevelConfiguration{
current: []*flowcontrolv1beta3.PriorityLevelConfiguration{
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
newPLConfiguration("pl2").Object(),
newPLConfiguration("pl3").Object(),
@ -441,12 +441,12 @@ func TestGetPriorityLevelRemoveCandidate(t *testing.T) {
}
type plBuilder struct {
object *flowcontrolv1beta2.PriorityLevelConfiguration
object *flowcontrolv1beta3.PriorityLevelConfiguration
}
func newPLConfiguration(name string) *plBuilder {
return &plBuilder{
object: &flowcontrolv1beta2.PriorityLevelConfiguration{
object: &flowcontrolv1beta3.PriorityLevelConfiguration{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
@ -454,7 +454,7 @@ func newPLConfiguration(name string) *plBuilder {
}
}
func (b *plBuilder) Object() *flowcontrolv1beta2.PriorityLevelConfiguration {
func (b *plBuilder) Object() *flowcontrolv1beta3.PriorityLevelConfiguration {
return b.object
}
@ -469,11 +469,11 @@ func (b *plBuilder) WithAutoUpdateAnnotation(value string) *plBuilder {
}
func (b *plBuilder) WithLimited(assuredConcurrencyShares int32) *plBuilder {
b.object.Spec.Type = flowcontrolv1beta2.PriorityLevelEnablementLimited
b.object.Spec.Limited = &flowcontrolv1beta2.LimitedPriorityLevelConfiguration{
b.object.Spec.Type = flowcontrolv1beta3.PriorityLevelEnablementLimited
b.object.Spec.Limited = &flowcontrolv1beta3.LimitedPriorityLevelConfiguration{
AssuredConcurrencyShares: assuredConcurrencyShares,
LimitResponse: flowcontrolv1beta2.LimitResponse{
Type: flowcontrolv1beta2.LimitResponseTypeReject,
LimitResponse: flowcontrolv1beta3.LimitResponse{
Type: flowcontrolv1beta3.LimitResponseTypeReject,
},
}
return b
@ -486,8 +486,8 @@ func (b *plBuilder) WithQueuing(queues, handSize, queueLengthLimit int32) *plBui
return b
}
limited.LimitResponse.Type = flowcontrolv1beta2.LimitResponseTypeQueue
limited.LimitResponse.Queuing = &flowcontrolv1beta2.QueuingConfiguration{
limited.LimitResponse.Type = flowcontrolv1beta3.LimitResponseTypeQueue
limited.LimitResponse.Queuing = &flowcontrolv1beta3.QueuingConfiguration{
Queues: queues,
HandSize: handSize,
QueueLengthLimit: queueLengthLimit,

View File

@ -21,7 +21,7 @@ import (
"fmt"
"strconv"
flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2"
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
@ -177,7 +177,7 @@ func (s *strategy) ShouldUpdate(current, bootstrap configurationObject) (runtime
// shouldUpdateSpec inspects the auto-update annotation key and generation field to determine
// whether the configurationWrapper object should be auto-updated.
func shouldUpdateSpec(accessor metav1.Object) bool {
value, _ := accessor.GetAnnotations()[flowcontrolv1beta2.AutoUpdateAnnotationKey]
value, _ := accessor.GetAnnotations()[flowcontrolv1beta3.AutoUpdateAnnotationKey]
if autoUpdate, err := strconv.ParseBool(value); err == nil {
return autoUpdate
}
@ -197,7 +197,7 @@ func shouldUpdateSpec(accessor metav1.Object) bool {
// shouldUpdateAnnotation determines whether the current value of the auto-update annotation
// key matches the desired value.
func shouldUpdateAnnotation(accessor metav1.Object, desired bool) bool {
if value, ok := accessor.GetAnnotations()[flowcontrolv1beta2.AutoUpdateAnnotationKey]; ok {
if value, ok := accessor.GetAnnotations()[flowcontrolv1beta3.AutoUpdateAnnotationKey]; ok {
if current, err := strconv.ParseBool(value); err == nil && current == desired {
return false
}
@ -212,7 +212,7 @@ func setAutoUpdateAnnotation(accessor metav1.Object, autoUpdate bool) {
accessor.SetAnnotations(map[string]string{})
}
accessor.GetAnnotations()[flowcontrolv1beta2.AutoUpdateAnnotationKey] = strconv.FormatBool(autoUpdate)
accessor.GetAnnotations()[flowcontrolv1beta3.AutoUpdateAnnotationKey] = strconv.FormatBool(autoUpdate)
}
// ensureConfiguration ensures the boostrap configurationWrapper on the cluster based on the specified strategy.
@ -281,7 +281,7 @@ func removeAutoUpdateEnabledConfiguration(wrapper configurationWrapper, name str
return fmt.Errorf("failed to retrieve the %s, will retry later name=%q error=%w", wrapper.TypeName(), name, err)
}
value := current.GetAnnotations()[flowcontrolv1beta2.AutoUpdateAnnotationKey]
value := current.GetAnnotations()[flowcontrolv1beta3.AutoUpdateAnnotationKey]
autoUpdate, err := strconv.ParseBool(value)
if err != nil {
klog.ErrorS(err, fmt.Sprintf("Skipping deletion of the %s", wrapper.TypeName()), "name", name)
@ -329,7 +329,7 @@ func getDanglingBootstrapObjectNames(bootstrap sets.String, current []metav1.Obj
candidates := make([]string, 0)
for i := range current {
object := current[i]
if _, ok := object.GetAnnotations()[flowcontrolv1beta2.AutoUpdateAnnotationKey]; !ok {
if _, ok := object.GetAnnotations()[flowcontrolv1beta3.AutoUpdateAnnotationKey]; !ok {
// the configuration object does not have the annotation key,
// it's probably a user defined configuration object,
// so we can skip it.

View File

@ -29,8 +29,8 @@ import (
genericapiserver "k8s.io/apiserver/pkg/server"
serverstorage "k8s.io/apiserver/pkg/server/storage"
"k8s.io/client-go/informers"
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta2"
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta3"
"k8s.io/client-go/tools/cache"
"k8s.io/klog/v2"
"k8s.io/kubernetes/pkg/api/legacyscheme"
@ -120,11 +120,11 @@ func (p RESTStorageProvider) GroupName() string {
func (p RESTStorageProvider) PostStartHook() (string, genericapiserver.PostStartHookFunc, error) {
bce := &bootstrapConfigurationEnsurer{
informersSynced: []cache.InformerSynced{
p.InformerFactory.Flowcontrol().V1beta2().PriorityLevelConfigurations().Informer().HasSynced,
p.InformerFactory.Flowcontrol().V1beta2().FlowSchemas().Informer().HasSynced,
p.InformerFactory.Flowcontrol().V1beta3().PriorityLevelConfigurations().Informer().HasSynced,
p.InformerFactory.Flowcontrol().V1beta3().FlowSchemas().Informer().HasSynced,
},
fsLister: p.InformerFactory.Flowcontrol().V1beta2().FlowSchemas().Lister(),
plcLister: p.InformerFactory.Flowcontrol().V1beta2().PriorityLevelConfigurations().Lister(),
fsLister: p.InformerFactory.Flowcontrol().V1beta3().FlowSchemas().Lister(),
plcLister: p.InformerFactory.Flowcontrol().V1beta3().PriorityLevelConfigurations().Lister(),
}
return PostStartHookName, bce.ensureAPFBootstrapConfiguration, nil
}
@ -182,7 +182,7 @@ func (bce *bootstrapConfigurationEnsurer) ensureAPFBootstrapConfiguration(hookCo
return nil
}
func ensure(clientset flowcontrolclient.FlowcontrolV1beta2Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
func ensure(clientset flowcontrolclient.FlowcontrolV1beta3Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
if err := ensureSuggestedConfiguration(clientset, fsLister, plcLister); err != nil {
// We should not attempt creation of mandatory objects if ensuring the suggested
// configuration resulted in an error.
@ -201,7 +201,7 @@ func ensure(clientset flowcontrolclient.FlowcontrolV1beta2Interface, fsLister fl
return nil
}
func ensureSuggestedConfiguration(clientset flowcontrolclient.FlowcontrolV1beta2Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
func ensureSuggestedConfiguration(clientset flowcontrolclient.FlowcontrolV1beta3Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
plEnsurer := ensurer.NewSuggestedPriorityLevelEnsurerEnsurer(clientset.PriorityLevelConfigurations(), plcLister)
if err := plEnsurer.Ensure(flowcontrolbootstrap.SuggestedPriorityLevelConfigurations); err != nil {
return err
@ -211,7 +211,7 @@ func ensureSuggestedConfiguration(clientset flowcontrolclient.FlowcontrolV1beta2
return fsEnsurer.Ensure(flowcontrolbootstrap.SuggestedFlowSchemas)
}
func ensureMandatoryConfiguration(clientset flowcontrolclient.FlowcontrolV1beta2Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
func ensureMandatoryConfiguration(clientset flowcontrolclient.FlowcontrolV1beta3Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
fsEnsurer := ensurer.NewMandatoryFlowSchemaEnsurer(clientset.FlowSchemas(), fsLister)
if err := fsEnsurer.Ensure(flowcontrolbootstrap.MandatoryFlowSchemas); err != nil {
return err
@ -221,7 +221,7 @@ func ensureMandatoryConfiguration(clientset flowcontrolclient.FlowcontrolV1beta2
return plEnsurer.Ensure(flowcontrolbootstrap.MandatoryPriorityLevelConfigurations)
}
func removeDanglingBootstrapConfiguration(clientset flowcontrolclient.FlowcontrolV1beta2Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
func removeDanglingBootstrapConfiguration(clientset flowcontrolclient.FlowcontrolV1beta3Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
if err := removeDanglingBootstrapFlowSchema(clientset.FlowSchemas(), fsLister); err != nil {
return err
}

View File

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

View File

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

View File

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

View File

@ -141,7 +141,7 @@ func (o *RecommendedOptions) ApplyTo(config *server.RecommendedConfig) error {
}
config.FlowControl = utilflowcontrol.New(
config.SharedInformerFactory,
kubernetes.NewForConfigOrDie(config.ClientConfig).FlowcontrolV1beta2(),
kubernetes.NewForConfigOrDie(config.ClientConfig).FlowcontrolV1beta3(),
config.MaxRequestsInFlight+config.MaxMutatingRequestsInFlight,
config.RequestTimeout/4,
)

View File

@ -52,9 +52,9 @@ import (
"k8s.io/klog/v2"
"k8s.io/utils/clock"
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
flowcontrollister "k8s.io/client-go/listers/flowcontrol/v1beta2"
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
flowcontrollister "k8s.io/client-go/listers/flowcontrol/v1beta3"
)
const timeFmt = "2006-01-02T15:04:05.999"
@ -123,7 +123,7 @@ type configController struct {
fsLister flowcontrollister.FlowSchemaLister
fsInformerSynced cache.InformerSynced
flowcontrolClient flowcontrolclient.FlowcontrolV1beta2Interface
flowcontrolClient flowcontrolclient.FlowcontrolV1beta3Interface
// serverConcurrencyLimit is the limit on the server's total
// number of non-exempt requests being served at once. This comes
@ -221,7 +221,7 @@ func newTestableController(config TestableConfig) *configController {
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
cfgCtlr.lockAndDigestConfigObjects(nil, nil)
fci := config.InformerFactory.Flowcontrol().V1beta2()
fci := config.InformerFactory.Flowcontrol().V1beta3()
pli := fci.PriorityLevelConfigurations()
fsi := fci.FlowSchemas()
cfgCtlr.plLister = pli.Lister()

View File

@ -32,8 +32,8 @@ import (
"k8s.io/klog/v2"
"k8s.io/utils/clock"
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
)
// ConfigConsumerAsFieldManager is how the config consuminng
@ -83,7 +83,7 @@ type Interface interface {
// New creates a new instance to implement API priority and fairness
func New(
informerFactory kubeinformers.SharedInformerFactory,
flowcontrolClient flowcontrolclient.FlowcontrolV1beta2Interface,
flowcontrolClient flowcontrolclient.FlowcontrolV1beta3Interface,
serverConcurrencyLimit int,
requestWaitLimit time.Duration,
) Interface {
@ -129,7 +129,7 @@ type TestableConfig struct {
InformerFactory kubeinformers.SharedInformerFactory
// FlowcontrolClient to use for manipulating config objects
FlowcontrolClient flowcontrolclient.FlowcontrolV1beta2Interface
FlowcontrolClient flowcontrolclient.FlowcontrolV1beta3Interface
// ServerConcurrencyLimit for the controller to enforce
ServerConcurrencyLimit int

View File

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

View File

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

View File

@ -23,7 +23,7 @@ import (
"testing"
"time"
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/sets"
fcboot "k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"

View File

@ -21,7 +21,7 @@ import (
"math/rand"
"testing"
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/sets"
"k8s.io/apiserver/pkg/authentication/user"

View File

@ -23,7 +23,7 @@ import (
"time"
"github.com/google/go-cmp/cmp"
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

View File

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