mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
apf: update apf logic to use v1beta2
This commit is contained in:
parent
d99497ef6d
commit
28f2b42a41
@ -507,7 +507,7 @@ func BuildPriorityAndFairness(s *options.ServerRunOptions, extclient clientgocli
|
|||||||
}
|
}
|
||||||
return utilflowcontrol.New(
|
return utilflowcontrol.New(
|
||||||
versionedInformer,
|
versionedInformer,
|
||||||
extclient.FlowcontrolV1beta1(),
|
extclient.FlowcontrolV1beta2(),
|
||||||
s.GenericServerRunOptions.MaxRequestsInFlight+s.GenericServerRunOptions.MaxMutatingRequestsInFlight,
|
s.GenericServerRunOptions.MaxRequestsInFlight+s.GenericServerRunOptions.MaxMutatingRequestsInFlight,
|
||||||
s.GenericServerRunOptions.RequestTimeout/4,
|
s.GenericServerRunOptions.RequestTimeout/4,
|
||||||
), nil
|
), nil
|
||||||
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||||||
package internalbootstrap
|
package internalbootstrap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
flowcontrolv1beta1 "k8s.io/api/flowcontrol/v1beta1"
|
flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2"
|
||||||
"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 []*flowcontrolv1beta1.FlowSchema) map[string]*flowcontrol.FlowSchema {
|
func internalizeFSes(exts []*flowcontrolv1beta2.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 []*flowcontrolv1beta1.FlowSchema) map[string]*flowcont
|
|||||||
return ans
|
return ans
|
||||||
}
|
}
|
||||||
|
|
||||||
func internalizePLs(exts []*flowcontrolv1beta1.PriorityLevelConfiguration) map[string]*flowcontrol.PriorityLevelConfiguration {
|
func internalizePLs(exts []*flowcontrolv1beta2.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 {
|
||||||
|
@ -19,7 +19,7 @@ package internalbootstrap
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
flowcontrol "k8s.io/api/flowcontrol/v1beta1"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
||||||
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"
|
||||||
)
|
)
|
||||||
|
@ -21,13 +21,13 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
flowcontrolv1beta1 "k8s.io/api/flowcontrol/v1beta1"
|
flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2"
|
||||||
"k8s.io/apimachinery/pkg/api/equality"
|
"k8s.io/apimachinery/pkg/api/equality"
|
||||||
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/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1"
|
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
|
||||||
flowcontrolapisv1beta1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta1"
|
flowcontrolapisv1beta2 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -36,7 +36,7 @@ var (
|
|||||||
|
|
||||||
// FlowSchemaEnsurer ensures the specified bootstrap configuration objects
|
// FlowSchemaEnsurer ensures the specified bootstrap configuration objects
|
||||||
type FlowSchemaEnsurer interface {
|
type FlowSchemaEnsurer interface {
|
||||||
Ensure([]*flowcontrolv1beta1.FlowSchema) error
|
Ensure([]*flowcontrolv1beta2.FlowSchema) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// FlowSchemaRemover removes the specified bootstrap configuration objects
|
// FlowSchemaRemover removes the specified bootstrap configuration objects
|
||||||
@ -82,7 +82,7 @@ func NewFlowSchemaRemover(client flowcontrolclient.FlowSchemaInterface) FlowSche
|
|||||||
// names that are candidates for deletion from the cluster.
|
// names that are candidates for deletion from the cluster.
|
||||||
// bootstrap: a set of hard coded FlowSchema configuration objects
|
// bootstrap: a set of hard coded FlowSchema configuration objects
|
||||||
// kube-apiserver maintains in-memory.
|
// kube-apiserver maintains in-memory.
|
||||||
func GetFlowSchemaRemoveCandidate(client flowcontrolclient.FlowSchemaInterface, bootstrap []*flowcontrolv1beta1.FlowSchema) ([]string, error) {
|
func GetFlowSchemaRemoveCandidate(client flowcontrolclient.FlowSchemaInterface, bootstrap []*flowcontrolv1beta2.FlowSchema) ([]string, error) {
|
||||||
// TODO(101667): Use a lister here to avoid periodic LIST calls
|
// TODO(101667): Use a lister here to avoid periodic LIST calls
|
||||||
fsList, err := client.List(context.TODO(), metav1.ListOptions{})
|
fsList, err := client.List(context.TODO(), metav1.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -107,7 +107,7 @@ type fsEnsurer struct {
|
|||||||
wrapper configurationWrapper
|
wrapper configurationWrapper
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *fsEnsurer) Ensure(flowSchemas []*flowcontrolv1beta1.FlowSchema) error {
|
func (e *fsEnsurer) Ensure(flowSchemas []*flowcontrolv1beta2.FlowSchema) error {
|
||||||
for _, flowSchema := range flowSchemas {
|
for _, flowSchema := range flowSchemas {
|
||||||
if err := ensureConfiguration(e.wrapper, e.strategy, flowSchema); err != nil {
|
if err := ensureConfiguration(e.wrapper, e.strategy, flowSchema); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -138,7 +138,7 @@ func (fs *flowSchemaWrapper) TypeName() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (fs *flowSchemaWrapper) Create(object runtime.Object) (runtime.Object, error) {
|
func (fs *flowSchemaWrapper) Create(object runtime.Object) (runtime.Object, error) {
|
||||||
fsObject, ok := object.(*flowcontrolv1beta1.FlowSchema)
|
fsObject, ok := object.(*flowcontrolv1beta2.FlowSchema)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errObjectNotFlowSchema
|
return nil, errObjectNotFlowSchema
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ func (fs *flowSchemaWrapper) Create(object runtime.Object) (runtime.Object, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (fs *flowSchemaWrapper) Update(object runtime.Object) (runtime.Object, error) {
|
func (fs *flowSchemaWrapper) Update(object runtime.Object) (runtime.Object, error) {
|
||||||
fsObject, ok := object.(*flowcontrolv1beta1.FlowSchema)
|
fsObject, ok := object.(*flowcontrolv1beta2.FlowSchema)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errObjectNotFlowSchema
|
return nil, errObjectNotFlowSchema
|
||||||
}
|
}
|
||||||
@ -164,11 +164,11 @@ func (fs *flowSchemaWrapper) Delete(name string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (fs *flowSchemaWrapper) CopySpec(bootstrap, current runtime.Object) error {
|
func (fs *flowSchemaWrapper) CopySpec(bootstrap, current runtime.Object) error {
|
||||||
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta1.FlowSchema)
|
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta2.FlowSchema)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errObjectNotFlowSchema
|
return errObjectNotFlowSchema
|
||||||
}
|
}
|
||||||
currentFS, ok := current.(*flowcontrolv1beta1.FlowSchema)
|
currentFS, ok := current.(*flowcontrolv1beta2.FlowSchema)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errObjectNotFlowSchema
|
return errObjectNotFlowSchema
|
||||||
}
|
}
|
||||||
@ -179,11 +179,11 @@ func (fs *flowSchemaWrapper) CopySpec(bootstrap, current runtime.Object) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (fs *flowSchemaWrapper) HasSpecChanged(bootstrap, current runtime.Object) (bool, error) {
|
func (fs *flowSchemaWrapper) HasSpecChanged(bootstrap, current runtime.Object) (bool, error) {
|
||||||
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta1.FlowSchema)
|
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta2.FlowSchema)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, errObjectNotFlowSchema
|
return false, errObjectNotFlowSchema
|
||||||
}
|
}
|
||||||
currentFS, ok := current.(*flowcontrolv1beta1.FlowSchema)
|
currentFS, ok := current.(*flowcontrolv1beta2.FlowSchema)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, errObjectNotFlowSchema
|
return false, errObjectNotFlowSchema
|
||||||
}
|
}
|
||||||
@ -191,8 +191,8 @@ func (fs *flowSchemaWrapper) HasSpecChanged(bootstrap, current runtime.Object) (
|
|||||||
return flowSchemaSpecChanged(bootstrapFS, currentFS), nil
|
return flowSchemaSpecChanged(bootstrapFS, currentFS), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func flowSchemaSpecChanged(expected, actual *flowcontrolv1beta1.FlowSchema) bool {
|
func flowSchemaSpecChanged(expected, actual *flowcontrolv1beta2.FlowSchema) bool {
|
||||||
copiedExpectedFlowSchema := expected.DeepCopy()
|
copiedExpectedFlowSchema := expected.DeepCopy()
|
||||||
flowcontrolapisv1beta1.SetObjectDefaults_FlowSchema(copiedExpectedFlowSchema)
|
flowcontrolapisv1beta2.SetObjectDefaults_FlowSchema(copiedExpectedFlowSchema)
|
||||||
return !equality.Semantic.DeepEqual(copiedExpectedFlowSchema.Spec, actual.Spec)
|
return !equality.Semantic.DeepEqual(copiedExpectedFlowSchema.Spec, actual.Spec)
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,13 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
flowcontrolv1beta1 "k8s.io/api/flowcontrol/v1beta1"
|
flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2"
|
||||||
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"
|
||||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1"
|
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
|
||||||
flowcontrolapisv1beta1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta1"
|
flowcontrolapisv1beta2 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta2"
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -37,9 +37,9 @@ func TestEnsureFlowSchema(t *testing.T) {
|
|||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
strategy func(flowcontrolclient.FlowSchemaInterface) FlowSchemaEnsurer
|
strategy func(flowcontrolclient.FlowSchemaInterface) FlowSchemaEnsurer
|
||||||
current *flowcontrolv1beta1.FlowSchema
|
current *flowcontrolv1beta2.FlowSchema
|
||||||
bootstrap *flowcontrolv1beta1.FlowSchema
|
bootstrap *flowcontrolv1beta2.FlowSchema
|
||||||
expected *flowcontrolv1beta1.FlowSchema
|
expected *flowcontrolv1beta2.FlowSchema
|
||||||
}{
|
}{
|
||||||
// for suggested configurations
|
// for suggested configurations
|
||||||
{
|
{
|
||||||
@ -102,14 +102,14 @@ 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().FlowcontrolV1beta1().FlowSchemas()
|
client := fake.NewSimpleClientset().FlowcontrolV1beta2().FlowSchemas()
|
||||||
if test.current != nil {
|
if test.current != nil {
|
||||||
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
|
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
|
||||||
}
|
}
|
||||||
|
|
||||||
ensurer := test.strategy(client)
|
ensurer := test.strategy(client)
|
||||||
|
|
||||||
err := ensurer.Ensure([]*flowcontrolv1beta1.FlowSchema{test.bootstrap})
|
err := ensurer.Ensure([]*flowcontrolv1beta2.FlowSchema{test.bootstrap})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Expected no error, but got: %v", err)
|
t.Fatalf("Expected no error, but got: %v", err)
|
||||||
}
|
}
|
||||||
@ -134,9 +134,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 *flowcontrolv1beta1.FlowSchema
|
current *flowcontrolv1beta2.FlowSchema
|
||||||
bootstrap *flowcontrolv1beta1.FlowSchema
|
bootstrap *flowcontrolv1beta2.FlowSchema
|
||||||
newObjectExpected *flowcontrolv1beta1.FlowSchema
|
newObjectExpected *flowcontrolv1beta2.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",
|
||||||
@ -241,23 +241,23 @@ func TestSuggestedFSEnsureStrategy_ShouldUpdate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFlowSchemaSpecChanged(t *testing.T) {
|
func TestFlowSchemaSpecChanged(t *testing.T) {
|
||||||
fs1 := &flowcontrolv1beta1.FlowSchema{
|
fs1 := &flowcontrolv1beta2.FlowSchema{
|
||||||
Spec: flowcontrolv1beta1.FlowSchemaSpec{},
|
Spec: flowcontrolv1beta2.FlowSchemaSpec{},
|
||||||
}
|
}
|
||||||
fs2 := &flowcontrolv1beta1.FlowSchema{
|
fs2 := &flowcontrolv1beta2.FlowSchema{
|
||||||
Spec: flowcontrolv1beta1.FlowSchemaSpec{
|
Spec: flowcontrolv1beta2.FlowSchemaSpec{
|
||||||
MatchingPrecedence: 1,
|
MatchingPrecedence: 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
fs1Defaulted := &flowcontrolv1beta1.FlowSchema{
|
fs1Defaulted := &flowcontrolv1beta2.FlowSchema{
|
||||||
Spec: flowcontrolv1beta1.FlowSchemaSpec{
|
Spec: flowcontrolv1beta2.FlowSchemaSpec{
|
||||||
MatchingPrecedence: flowcontrolapisv1beta1.FlowSchemaDefaultMatchingPrecedence,
|
MatchingPrecedence: flowcontrolapisv1beta2.FlowSchemaDefaultMatchingPrecedence,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
expected *flowcontrolv1beta1.FlowSchema
|
expected *flowcontrolv1beta2.FlowSchema
|
||||||
actual *flowcontrolv1beta1.FlowSchema
|
actual *flowcontrolv1beta2.FlowSchema
|
||||||
specChanged bool
|
specChanged bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
@ -290,7 +290,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 *flowcontrolv1beta1.FlowSchema
|
current *flowcontrolv1beta2.FlowSchema
|
||||||
bootstrapName string
|
bootstrapName string
|
||||||
removeExpected bool
|
removeExpected bool
|
||||||
}{
|
}{
|
||||||
@ -321,7 +321,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().FlowcontrolV1beta1().FlowSchemas()
|
client := fake.NewSimpleClientset().FlowcontrolV1beta2().FlowSchemas()
|
||||||
if test.current != nil {
|
if test.current != nil {
|
||||||
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
|
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
|
||||||
}
|
}
|
||||||
@ -353,18 +353,18 @@ func TestRemoveFlowSchema(t *testing.T) {
|
|||||||
func TestGetFlowSchemaRemoveCandidate(t *testing.T) {
|
func TestGetFlowSchemaRemoveCandidate(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
current []*flowcontrolv1beta1.FlowSchema
|
current []*flowcontrolv1beta2.FlowSchema
|
||||||
bootstrap []*flowcontrolv1beta1.FlowSchema
|
bootstrap []*flowcontrolv1beta2.FlowSchema
|
||||||
expected []string
|
expected []string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "no object has been removed from the bootstrap configuration",
|
name: "no object has been removed from the bootstrap configuration",
|
||||||
bootstrap: []*flowcontrolv1beta1.FlowSchema{
|
bootstrap: []*flowcontrolv1beta2.FlowSchema{
|
||||||
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
||||||
newFlowSchema("fs2", "pl2", 200).WithAutoUpdateAnnotation("true").Object(),
|
newFlowSchema("fs2", "pl2", 200).WithAutoUpdateAnnotation("true").Object(),
|
||||||
newFlowSchema("fs3", "pl3", 300).WithAutoUpdateAnnotation("true").Object(),
|
newFlowSchema("fs3", "pl3", 300).WithAutoUpdateAnnotation("true").Object(),
|
||||||
},
|
},
|
||||||
current: []*flowcontrolv1beta1.FlowSchema{
|
current: []*flowcontrolv1beta2.FlowSchema{
|
||||||
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
||||||
newFlowSchema("fs2", "pl2", 200).WithAutoUpdateAnnotation("true").Object(),
|
newFlowSchema("fs2", "pl2", 200).WithAutoUpdateAnnotation("true").Object(),
|
||||||
newFlowSchema("fs3", "pl3", 300).WithAutoUpdateAnnotation("true").Object(),
|
newFlowSchema("fs3", "pl3", 300).WithAutoUpdateAnnotation("true").Object(),
|
||||||
@ -373,8 +373,8 @@ func TestGetFlowSchemaRemoveCandidate(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "bootstrap is empty, all current objects with the annotation should be candidates",
|
name: "bootstrap is empty, all current objects with the annotation should be candidates",
|
||||||
bootstrap: []*flowcontrolv1beta1.FlowSchema{},
|
bootstrap: []*flowcontrolv1beta2.FlowSchema{},
|
||||||
current: []*flowcontrolv1beta1.FlowSchema{
|
current: []*flowcontrolv1beta2.FlowSchema{
|
||||||
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
||||||
newFlowSchema("fs2", "pl2", 200).WithAutoUpdateAnnotation("true").Object(),
|
newFlowSchema("fs2", "pl2", 200).WithAutoUpdateAnnotation("true").Object(),
|
||||||
newFlowSchema("fs3", "pl3", 300).Object(),
|
newFlowSchema("fs3", "pl3", 300).Object(),
|
||||||
@ -383,10 +383,10 @@ func TestGetFlowSchemaRemoveCandidate(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "object(s) have been removed from the bootstrap configuration",
|
name: "object(s) have been removed from the bootstrap configuration",
|
||||||
bootstrap: []*flowcontrolv1beta1.FlowSchema{
|
bootstrap: []*flowcontrolv1beta2.FlowSchema{
|
||||||
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
||||||
},
|
},
|
||||||
current: []*flowcontrolv1beta1.FlowSchema{
|
current: []*flowcontrolv1beta2.FlowSchema{
|
||||||
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
||||||
newFlowSchema("fs2", "pl2", 200).WithAutoUpdateAnnotation("true").Object(),
|
newFlowSchema("fs2", "pl2", 200).WithAutoUpdateAnnotation("true").Object(),
|
||||||
newFlowSchema("fs3", "pl3", 300).WithAutoUpdateAnnotation("true").Object(),
|
newFlowSchema("fs3", "pl3", 300).WithAutoUpdateAnnotation("true").Object(),
|
||||||
@ -395,10 +395,10 @@ func TestGetFlowSchemaRemoveCandidate(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "object(s) without the annotation key are ignored",
|
name: "object(s) without the annotation key are ignored",
|
||||||
bootstrap: []*flowcontrolv1beta1.FlowSchema{
|
bootstrap: []*flowcontrolv1beta2.FlowSchema{
|
||||||
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
||||||
},
|
},
|
||||||
current: []*flowcontrolv1beta1.FlowSchema{
|
current: []*flowcontrolv1beta2.FlowSchema{
|
||||||
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
||||||
newFlowSchema("fs2", "pl2", 200).Object(),
|
newFlowSchema("fs2", "pl2", 200).Object(),
|
||||||
newFlowSchema("fs3", "pl3", 300).Object(),
|
newFlowSchema("fs3", "pl3", 300).Object(),
|
||||||
@ -409,7 +409,7 @@ func TestGetFlowSchemaRemoveCandidate(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().FlowcontrolV1beta1().FlowSchemas()
|
client := fake.NewSimpleClientset().FlowcontrolV1beta2().FlowSchemas()
|
||||||
for i := range test.current {
|
for i := range test.current {
|
||||||
client.Create(context.TODO(), test.current[i], metav1.CreateOptions{})
|
client.Create(context.TODO(), test.current[i], metav1.CreateOptions{})
|
||||||
}
|
}
|
||||||
@ -427,17 +427,17 @@ func TestGetFlowSchemaRemoveCandidate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type fsBuilder struct {
|
type fsBuilder struct {
|
||||||
object *flowcontrolv1beta1.FlowSchema
|
object *flowcontrolv1beta2.FlowSchema
|
||||||
}
|
}
|
||||||
|
|
||||||
func newFlowSchema(name, plName string, matchingPrecedence int32) *fsBuilder {
|
func newFlowSchema(name, plName string, matchingPrecedence int32) *fsBuilder {
|
||||||
return &fsBuilder{
|
return &fsBuilder{
|
||||||
object: &flowcontrolv1beta1.FlowSchema{
|
object: &flowcontrolv1beta2.FlowSchema{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
},
|
},
|
||||||
Spec: flowcontrolv1beta1.FlowSchemaSpec{
|
Spec: flowcontrolv1beta2.FlowSchemaSpec{
|
||||||
PriorityLevelConfiguration: flowcontrolv1beta1.PriorityLevelConfigurationReference{
|
PriorityLevelConfiguration: flowcontrolv1beta2.PriorityLevelConfigurationReference{
|
||||||
Name: plName,
|
Name: plName,
|
||||||
},
|
},
|
||||||
MatchingPrecedence: matchingPrecedence,
|
MatchingPrecedence: matchingPrecedence,
|
||||||
@ -446,7 +446,7 @@ func newFlowSchema(name, plName string, matchingPrecedence int32) *fsBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *fsBuilder) Object() *flowcontrolv1beta1.FlowSchema {
|
func (b *fsBuilder) Object() *flowcontrolv1beta2.FlowSchema {
|
||||||
return b.object
|
return b.object
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -465,5 +465,5 @@ func setAnnotation(accessor metav1.Object, value string) {
|
|||||||
accessor.SetAnnotations(map[string]string{})
|
accessor.SetAnnotations(map[string]string{})
|
||||||
}
|
}
|
||||||
|
|
||||||
accessor.GetAnnotations()[flowcontrolv1beta1.AutoUpdateAnnotationKey] = value
|
accessor.GetAnnotations()[flowcontrolv1beta2.AutoUpdateAnnotationKey] = value
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,13 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
flowcontrolv1beta1 "k8s.io/api/flowcontrol/v1beta1"
|
flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2"
|
||||||
"k8s.io/apimachinery/pkg/api/equality"
|
"k8s.io/apimachinery/pkg/api/equality"
|
||||||
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/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1"
|
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
|
||||||
flowcontrolapisv1beta1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta1"
|
flowcontrolapisv1beta2 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -36,7 +36,7 @@ var (
|
|||||||
|
|
||||||
// PriorityLevelEnsurer ensures the specified bootstrap configuration objects
|
// PriorityLevelEnsurer ensures the specified bootstrap configuration objects
|
||||||
type PriorityLevelEnsurer interface {
|
type PriorityLevelEnsurer interface {
|
||||||
Ensure([]*flowcontrolv1beta1.PriorityLevelConfiguration) error
|
Ensure([]*flowcontrolv1beta2.PriorityLevelConfiguration) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// PriorityLevelRemover removes the specified bootstrap configuration objects
|
// PriorityLevelRemover removes the specified bootstrap configuration objects
|
||||||
@ -82,7 +82,7 @@ func NewPriorityLevelRemover(client flowcontrolclient.PriorityLevelConfiguration
|
|||||||
// names that are candidates for removal from the cluster.
|
// names that are candidates for removal from the cluster.
|
||||||
// bootstrap: a set of hard coded PriorityLevelConfiguration configuration
|
// bootstrap: a set of hard coded PriorityLevelConfiguration configuration
|
||||||
// objects kube-apiserver maintains in-memory.
|
// objects kube-apiserver maintains in-memory.
|
||||||
func GetPriorityLevelRemoveCandidate(client flowcontrolclient.PriorityLevelConfigurationInterface, bootstrap []*flowcontrolv1beta1.PriorityLevelConfiguration) ([]string, error) {
|
func GetPriorityLevelRemoveCandidate(client flowcontrolclient.PriorityLevelConfigurationInterface, bootstrap []*flowcontrolv1beta2.PriorityLevelConfiguration) ([]string, error) {
|
||||||
// TODO(101667): Use a lister here to avoid periodic LIST calls
|
// TODO(101667): Use a lister here to avoid periodic LIST calls
|
||||||
plList, err := client.List(context.TODO(), metav1.ListOptions{})
|
plList, err := client.List(context.TODO(), metav1.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -107,7 +107,7 @@ type plEnsurer struct {
|
|||||||
wrapper configurationWrapper
|
wrapper configurationWrapper
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *plEnsurer) Ensure(priorityLevels []*flowcontrolv1beta1.PriorityLevelConfiguration) error {
|
func (e *plEnsurer) Ensure(priorityLevels []*flowcontrolv1beta2.PriorityLevelConfiguration) error {
|
||||||
for _, priorityLevel := range priorityLevels {
|
for _, priorityLevel := range priorityLevels {
|
||||||
if err := ensureConfiguration(e.wrapper, e.strategy, priorityLevel); err != nil {
|
if err := ensureConfiguration(e.wrapper, e.strategy, priorityLevel); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -138,7 +138,7 @@ func (fs *priorityLevelConfigurationWrapper) TypeName() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (fs *priorityLevelConfigurationWrapper) Create(object runtime.Object) (runtime.Object, error) {
|
func (fs *priorityLevelConfigurationWrapper) Create(object runtime.Object) (runtime.Object, error) {
|
||||||
plObject, ok := object.(*flowcontrolv1beta1.PriorityLevelConfiguration)
|
plObject, ok := object.(*flowcontrolv1beta2.PriorityLevelConfiguration)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errObjectNotPriorityLevel
|
return nil, errObjectNotPriorityLevel
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ func (fs *priorityLevelConfigurationWrapper) Create(object runtime.Object) (runt
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (fs *priorityLevelConfigurationWrapper) Update(object runtime.Object) (runtime.Object, error) {
|
func (fs *priorityLevelConfigurationWrapper) Update(object runtime.Object) (runtime.Object, error) {
|
||||||
fsObject, ok := object.(*flowcontrolv1beta1.PriorityLevelConfiguration)
|
fsObject, ok := object.(*flowcontrolv1beta2.PriorityLevelConfiguration)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errObjectNotPriorityLevel
|
return nil, errObjectNotPriorityLevel
|
||||||
}
|
}
|
||||||
@ -164,11 +164,11 @@ func (fs *priorityLevelConfigurationWrapper) Delete(name string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (fs *priorityLevelConfigurationWrapper) CopySpec(bootstrap, current runtime.Object) error {
|
func (fs *priorityLevelConfigurationWrapper) CopySpec(bootstrap, current runtime.Object) error {
|
||||||
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta1.PriorityLevelConfiguration)
|
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta2.PriorityLevelConfiguration)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errObjectNotPriorityLevel
|
return errObjectNotPriorityLevel
|
||||||
}
|
}
|
||||||
currentFS, ok := current.(*flowcontrolv1beta1.PriorityLevelConfiguration)
|
currentFS, ok := current.(*flowcontrolv1beta2.PriorityLevelConfiguration)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errObjectNotPriorityLevel
|
return errObjectNotPriorityLevel
|
||||||
}
|
}
|
||||||
@ -179,11 +179,11 @@ func (fs *priorityLevelConfigurationWrapper) CopySpec(bootstrap, current runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (fs *priorityLevelConfigurationWrapper) HasSpecChanged(bootstrap, current runtime.Object) (bool, error) {
|
func (fs *priorityLevelConfigurationWrapper) HasSpecChanged(bootstrap, current runtime.Object) (bool, error) {
|
||||||
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta1.PriorityLevelConfiguration)
|
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta2.PriorityLevelConfiguration)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, errObjectNotPriorityLevel
|
return false, errObjectNotPriorityLevel
|
||||||
}
|
}
|
||||||
currentFS, ok := current.(*flowcontrolv1beta1.PriorityLevelConfiguration)
|
currentFS, ok := current.(*flowcontrolv1beta2.PriorityLevelConfiguration)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, errObjectNotPriorityLevel
|
return false, errObjectNotPriorityLevel
|
||||||
}
|
}
|
||||||
@ -191,8 +191,8 @@ func (fs *priorityLevelConfigurationWrapper) HasSpecChanged(bootstrap, current r
|
|||||||
return priorityLevelSpecChanged(bootstrapFS, currentFS), nil
|
return priorityLevelSpecChanged(bootstrapFS, currentFS), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func priorityLevelSpecChanged(expected, actual *flowcontrolv1beta1.PriorityLevelConfiguration) bool {
|
func priorityLevelSpecChanged(expected, actual *flowcontrolv1beta2.PriorityLevelConfiguration) bool {
|
||||||
copiedExpectedPriorityLevel := expected.DeepCopy()
|
copiedExpectedPriorityLevel := expected.DeepCopy()
|
||||||
flowcontrolapisv1beta1.SetObjectDefaults_PriorityLevelConfiguration(copiedExpectedPriorityLevel)
|
flowcontrolapisv1beta2.SetObjectDefaults_PriorityLevelConfiguration(copiedExpectedPriorityLevel)
|
||||||
return !equality.Semantic.DeepEqual(copiedExpectedPriorityLevel.Spec, actual.Spec)
|
return !equality.Semantic.DeepEqual(copiedExpectedPriorityLevel.Spec, actual.Spec)
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,13 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
flowcontrolv1beta1 "k8s.io/api/flowcontrol/v1beta1"
|
flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2"
|
||||||
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"
|
||||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1"
|
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
|
||||||
flowcontrolapisv1beta1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta1"
|
flowcontrolapisv1beta2 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta2"
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -37,9 +37,9 @@ func TestEnsurePriorityLevel(t *testing.T) {
|
|||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
strategy func(flowcontrolclient.PriorityLevelConfigurationInterface) PriorityLevelEnsurer
|
strategy func(flowcontrolclient.PriorityLevelConfigurationInterface) PriorityLevelEnsurer
|
||||||
current *flowcontrolv1beta1.PriorityLevelConfiguration
|
current *flowcontrolv1beta2.PriorityLevelConfiguration
|
||||||
bootstrap *flowcontrolv1beta1.PriorityLevelConfiguration
|
bootstrap *flowcontrolv1beta2.PriorityLevelConfiguration
|
||||||
expected *flowcontrolv1beta1.PriorityLevelConfiguration
|
expected *flowcontrolv1beta2.PriorityLevelConfiguration
|
||||||
}{
|
}{
|
||||||
// for suggested configurations
|
// for suggested configurations
|
||||||
{
|
{
|
||||||
@ -102,14 +102,14 @@ 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().FlowcontrolV1beta1().PriorityLevelConfigurations()
|
client := fake.NewSimpleClientset().FlowcontrolV1beta2().PriorityLevelConfigurations()
|
||||||
if test.current != nil {
|
if test.current != nil {
|
||||||
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
|
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
|
||||||
}
|
}
|
||||||
|
|
||||||
ensurer := test.strategy(client)
|
ensurer := test.strategy(client)
|
||||||
|
|
||||||
err := ensurer.Ensure([]*flowcontrolv1beta1.PriorityLevelConfiguration{test.bootstrap})
|
err := ensurer.Ensure([]*flowcontrolv1beta2.PriorityLevelConfiguration{test.bootstrap})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Expected no error, but got: %v", err)
|
t.Fatalf("Expected no error, but got: %v", err)
|
||||||
}
|
}
|
||||||
@ -134,9 +134,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 *flowcontrolv1beta1.PriorityLevelConfiguration
|
current *flowcontrolv1beta2.PriorityLevelConfiguration
|
||||||
bootstrap *flowcontrolv1beta1.PriorityLevelConfiguration
|
bootstrap *flowcontrolv1beta2.PriorityLevelConfiguration
|
||||||
newObjectExpected *flowcontrolv1beta1.PriorityLevelConfiguration
|
newObjectExpected *flowcontrolv1beta2.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",
|
||||||
@ -241,39 +241,39 @@ func TestSuggestedPLEnsureStrategy_ShouldUpdate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPriorityLevelSpecChanged(t *testing.T) {
|
func TestPriorityLevelSpecChanged(t *testing.T) {
|
||||||
pl1 := &flowcontrolv1beta1.PriorityLevelConfiguration{
|
pl1 := &flowcontrolv1beta2.PriorityLevelConfiguration{
|
||||||
Spec: flowcontrolv1beta1.PriorityLevelConfigurationSpec{
|
Spec: flowcontrolv1beta2.PriorityLevelConfigurationSpec{
|
||||||
Type: flowcontrolv1beta1.PriorityLevelEnablementLimited,
|
Type: flowcontrolv1beta2.PriorityLevelEnablementLimited,
|
||||||
Limited: &flowcontrolv1beta1.LimitedPriorityLevelConfiguration{
|
Limited: &flowcontrolv1beta2.LimitedPriorityLevelConfiguration{
|
||||||
LimitResponse: flowcontrolv1beta1.LimitResponse{
|
LimitResponse: flowcontrolv1beta2.LimitResponse{
|
||||||
Type: flowcontrolv1beta1.LimitResponseTypeReject,
|
Type: flowcontrolv1beta2.LimitResponseTypeReject,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
pl2 := &flowcontrolv1beta1.PriorityLevelConfiguration{
|
pl2 := &flowcontrolv1beta2.PriorityLevelConfiguration{
|
||||||
Spec: flowcontrolv1beta1.PriorityLevelConfigurationSpec{
|
Spec: flowcontrolv1beta2.PriorityLevelConfigurationSpec{
|
||||||
Type: flowcontrolv1beta1.PriorityLevelEnablementLimited,
|
Type: flowcontrolv1beta2.PriorityLevelEnablementLimited,
|
||||||
Limited: &flowcontrolv1beta1.LimitedPriorityLevelConfiguration{
|
Limited: &flowcontrolv1beta2.LimitedPriorityLevelConfiguration{
|
||||||
AssuredConcurrencyShares: 1,
|
AssuredConcurrencyShares: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
pl1Defaulted := &flowcontrolv1beta1.PriorityLevelConfiguration{
|
pl1Defaulted := &flowcontrolv1beta2.PriorityLevelConfiguration{
|
||||||
Spec: flowcontrolv1beta1.PriorityLevelConfigurationSpec{
|
Spec: flowcontrolv1beta2.PriorityLevelConfigurationSpec{
|
||||||
Type: flowcontrolv1beta1.PriorityLevelEnablementLimited,
|
Type: flowcontrolv1beta2.PriorityLevelEnablementLimited,
|
||||||
Limited: &flowcontrolv1beta1.LimitedPriorityLevelConfiguration{
|
Limited: &flowcontrolv1beta2.LimitedPriorityLevelConfiguration{
|
||||||
AssuredConcurrencyShares: flowcontrolapisv1beta1.PriorityLevelConfigurationDefaultAssuredConcurrencyShares,
|
AssuredConcurrencyShares: flowcontrolapisv1beta2.PriorityLevelConfigurationDefaultAssuredConcurrencyShares,
|
||||||
LimitResponse: flowcontrolv1beta1.LimitResponse{
|
LimitResponse: flowcontrolv1beta2.LimitResponse{
|
||||||
Type: flowcontrolv1beta1.LimitResponseTypeReject,
|
Type: flowcontrolv1beta2.LimitResponseTypeReject,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
expected *flowcontrolv1beta1.PriorityLevelConfiguration
|
expected *flowcontrolv1beta2.PriorityLevelConfiguration
|
||||||
actual *flowcontrolv1beta1.PriorityLevelConfiguration
|
actual *flowcontrolv1beta2.PriorityLevelConfiguration
|
||||||
specChanged bool
|
specChanged bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
@ -306,7 +306,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 *flowcontrolv1beta1.PriorityLevelConfiguration
|
current *flowcontrolv1beta2.PriorityLevelConfiguration
|
||||||
bootstrapName string
|
bootstrapName string
|
||||||
removeExpected bool
|
removeExpected bool
|
||||||
}{
|
}{
|
||||||
@ -337,7 +337,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().FlowcontrolV1beta1().PriorityLevelConfigurations()
|
client := fake.NewSimpleClientset().FlowcontrolV1beta2().PriorityLevelConfigurations()
|
||||||
if test.current != nil {
|
if test.current != nil {
|
||||||
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
|
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
|
||||||
}
|
}
|
||||||
@ -369,18 +369,18 @@ func TestRemovePriorityLevelConfiguration(t *testing.T) {
|
|||||||
func TestGetPriorityLevelRemoveCandidate(t *testing.T) {
|
func TestGetPriorityLevelRemoveCandidate(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
current []*flowcontrolv1beta1.PriorityLevelConfiguration
|
current []*flowcontrolv1beta2.PriorityLevelConfiguration
|
||||||
bootstrap []*flowcontrolv1beta1.PriorityLevelConfiguration
|
bootstrap []*flowcontrolv1beta2.PriorityLevelConfiguration
|
||||||
expected []string
|
expected []string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "no object has been removed from the bootstrap configuration",
|
name: "no object has been removed from the bootstrap configuration",
|
||||||
bootstrap: []*flowcontrolv1beta1.PriorityLevelConfiguration{
|
bootstrap: []*flowcontrolv1beta2.PriorityLevelConfiguration{
|
||||||
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
|
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
|
||||||
newPLConfiguration("pl2").WithAutoUpdateAnnotation("true").Object(),
|
newPLConfiguration("pl2").WithAutoUpdateAnnotation("true").Object(),
|
||||||
newPLConfiguration("pl3").WithAutoUpdateAnnotation("true").Object(),
|
newPLConfiguration("pl3").WithAutoUpdateAnnotation("true").Object(),
|
||||||
},
|
},
|
||||||
current: []*flowcontrolv1beta1.PriorityLevelConfiguration{
|
current: []*flowcontrolv1beta2.PriorityLevelConfiguration{
|
||||||
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
|
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
|
||||||
newPLConfiguration("pl2").WithAutoUpdateAnnotation("true").Object(),
|
newPLConfiguration("pl2").WithAutoUpdateAnnotation("true").Object(),
|
||||||
newPLConfiguration("pl3").WithAutoUpdateAnnotation("true").Object(),
|
newPLConfiguration("pl3").WithAutoUpdateAnnotation("true").Object(),
|
||||||
@ -389,8 +389,8 @@ func TestGetPriorityLevelRemoveCandidate(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "bootstrap is empty, all current objects with the annotation should be candidates",
|
name: "bootstrap is empty, all current objects with the annotation should be candidates",
|
||||||
bootstrap: []*flowcontrolv1beta1.PriorityLevelConfiguration{},
|
bootstrap: []*flowcontrolv1beta2.PriorityLevelConfiguration{},
|
||||||
current: []*flowcontrolv1beta1.PriorityLevelConfiguration{
|
current: []*flowcontrolv1beta2.PriorityLevelConfiguration{
|
||||||
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
|
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
|
||||||
newPLConfiguration("pl2").WithAutoUpdateAnnotation("true").Object(),
|
newPLConfiguration("pl2").WithAutoUpdateAnnotation("true").Object(),
|
||||||
newPLConfiguration("pl3").Object(),
|
newPLConfiguration("pl3").Object(),
|
||||||
@ -399,10 +399,10 @@ func TestGetPriorityLevelRemoveCandidate(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "object(s) have been removed from the bootstrap configuration",
|
name: "object(s) have been removed from the bootstrap configuration",
|
||||||
bootstrap: []*flowcontrolv1beta1.PriorityLevelConfiguration{
|
bootstrap: []*flowcontrolv1beta2.PriorityLevelConfiguration{
|
||||||
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
|
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
|
||||||
},
|
},
|
||||||
current: []*flowcontrolv1beta1.PriorityLevelConfiguration{
|
current: []*flowcontrolv1beta2.PriorityLevelConfiguration{
|
||||||
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
|
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
|
||||||
newPLConfiguration("pl2").WithAutoUpdateAnnotation("true").Object(),
|
newPLConfiguration("pl2").WithAutoUpdateAnnotation("true").Object(),
|
||||||
newPLConfiguration("pl3").WithAutoUpdateAnnotation("true").Object(),
|
newPLConfiguration("pl3").WithAutoUpdateAnnotation("true").Object(),
|
||||||
@ -411,10 +411,10 @@ func TestGetPriorityLevelRemoveCandidate(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "object(s) without the annotation key are ignored",
|
name: "object(s) without the annotation key are ignored",
|
||||||
bootstrap: []*flowcontrolv1beta1.PriorityLevelConfiguration{
|
bootstrap: []*flowcontrolv1beta2.PriorityLevelConfiguration{
|
||||||
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
|
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
|
||||||
},
|
},
|
||||||
current: []*flowcontrolv1beta1.PriorityLevelConfiguration{
|
current: []*flowcontrolv1beta2.PriorityLevelConfiguration{
|
||||||
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
|
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
|
||||||
newPLConfiguration("pl2").Object(),
|
newPLConfiguration("pl2").Object(),
|
||||||
newPLConfiguration("pl3").Object(),
|
newPLConfiguration("pl3").Object(),
|
||||||
@ -425,7 +425,7 @@ func TestGetPriorityLevelRemoveCandidate(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().FlowcontrolV1beta1().PriorityLevelConfigurations()
|
client := fake.NewSimpleClientset().FlowcontrolV1beta2().PriorityLevelConfigurations()
|
||||||
for i := range test.current {
|
for i := range test.current {
|
||||||
client.Create(context.TODO(), test.current[i], metav1.CreateOptions{})
|
client.Create(context.TODO(), test.current[i], metav1.CreateOptions{})
|
||||||
}
|
}
|
||||||
@ -443,12 +443,12 @@ func TestGetPriorityLevelRemoveCandidate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type plBuilder struct {
|
type plBuilder struct {
|
||||||
object *flowcontrolv1beta1.PriorityLevelConfiguration
|
object *flowcontrolv1beta2.PriorityLevelConfiguration
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPLConfiguration(name string) *plBuilder {
|
func newPLConfiguration(name string) *plBuilder {
|
||||||
return &plBuilder{
|
return &plBuilder{
|
||||||
object: &flowcontrolv1beta1.PriorityLevelConfiguration{
|
object: &flowcontrolv1beta2.PriorityLevelConfiguration{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
},
|
},
|
||||||
@ -456,7 +456,7 @@ func newPLConfiguration(name string) *plBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *plBuilder) Object() *flowcontrolv1beta1.PriorityLevelConfiguration {
|
func (b *plBuilder) Object() *flowcontrolv1beta2.PriorityLevelConfiguration {
|
||||||
return b.object
|
return b.object
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,11 +471,11 @@ func (b *plBuilder) WithAutoUpdateAnnotation(value string) *plBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *plBuilder) WithLimited(assuredConcurrencyShares int32) *plBuilder {
|
func (b *plBuilder) WithLimited(assuredConcurrencyShares int32) *plBuilder {
|
||||||
b.object.Spec.Type = flowcontrolv1beta1.PriorityLevelEnablementLimited
|
b.object.Spec.Type = flowcontrolv1beta2.PriorityLevelEnablementLimited
|
||||||
b.object.Spec.Limited = &flowcontrolv1beta1.LimitedPriorityLevelConfiguration{
|
b.object.Spec.Limited = &flowcontrolv1beta2.LimitedPriorityLevelConfiguration{
|
||||||
AssuredConcurrencyShares: assuredConcurrencyShares,
|
AssuredConcurrencyShares: assuredConcurrencyShares,
|
||||||
LimitResponse: flowcontrolv1beta1.LimitResponse{
|
LimitResponse: flowcontrolv1beta2.LimitResponse{
|
||||||
Type: flowcontrolv1beta1.LimitResponseTypeReject,
|
Type: flowcontrolv1beta2.LimitResponseTypeReject,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return b
|
return b
|
||||||
@ -488,8 +488,8 @@ func (b *plBuilder) WithQueuing(queues, handSize, queueLengthLimit int32) *plBui
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
limited.LimitResponse.Type = flowcontrolv1beta1.LimitResponseTypeQueue
|
limited.LimitResponse.Type = flowcontrolv1beta2.LimitResponseTypeQueue
|
||||||
limited.LimitResponse.Queuing = &flowcontrolv1beta1.QueuingConfiguration{
|
limited.LimitResponse.Queuing = &flowcontrolv1beta2.QueuingConfiguration{
|
||||||
Queues: queues,
|
Queues: queues,
|
||||||
HandSize: handSize,
|
HandSize: handSize,
|
||||||
QueueLengthLimit: queueLengthLimit,
|
QueueLengthLimit: queueLengthLimit,
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
"k8s.io/apiserver/pkg/registry/rest"
|
"k8s.io/apiserver/pkg/registry/rest"
|
||||||
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"
|
||||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1"
|
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
"k8s.io/kubernetes/pkg/apis/flowcontrol"
|
"k8s.io/kubernetes/pkg/apis/flowcontrol"
|
||||||
@ -153,7 +153,7 @@ func ensureAPFBootstrapConfiguration(hookContext genericapiserver.PostStartHookC
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensure(clientset flowcontrolclient.FlowcontrolV1beta1Interface) error {
|
func ensure(clientset flowcontrolclient.FlowcontrolV1beta2Interface) error {
|
||||||
if err := ensureSuggestedConfiguration(clientset); err != nil {
|
if err := ensureSuggestedConfiguration(clientset); 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
|
||||||
// configuration resulted in an error.
|
// configuration resulted in an error.
|
||||||
@ -172,7 +172,7 @@ func ensure(clientset flowcontrolclient.FlowcontrolV1beta1Interface) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureSuggestedConfiguration(clientset flowcontrolclient.FlowcontrolV1beta1Interface) error {
|
func ensureSuggestedConfiguration(clientset flowcontrolclient.FlowcontrolV1beta2Interface) error {
|
||||||
fsEnsurer := ensurer.NewSuggestedFlowSchemaEnsurer(clientset.FlowSchemas())
|
fsEnsurer := ensurer.NewSuggestedFlowSchemaEnsurer(clientset.FlowSchemas())
|
||||||
if err := fsEnsurer.Ensure(flowcontrolbootstrap.SuggestedFlowSchemas); err != nil {
|
if err := fsEnsurer.Ensure(flowcontrolbootstrap.SuggestedFlowSchemas); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -182,7 +182,7 @@ func ensureSuggestedConfiguration(clientset flowcontrolclient.FlowcontrolV1beta1
|
|||||||
return plEnsurer.Ensure(flowcontrolbootstrap.SuggestedPriorityLevelConfigurations)
|
return plEnsurer.Ensure(flowcontrolbootstrap.SuggestedPriorityLevelConfigurations)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureMandatoryConfiguration(clientset flowcontrolclient.FlowcontrolV1beta1Interface) error {
|
func ensureMandatoryConfiguration(clientset flowcontrolclient.FlowcontrolV1beta2Interface) error {
|
||||||
fsEnsurer := ensurer.NewMandatoryFlowSchemaEnsurer(clientset.FlowSchemas())
|
fsEnsurer := ensurer.NewMandatoryFlowSchemaEnsurer(clientset.FlowSchemas())
|
||||||
if err := fsEnsurer.Ensure(flowcontrolbootstrap.MandatoryFlowSchemas); err != nil {
|
if err := fsEnsurer.Ensure(flowcontrolbootstrap.MandatoryFlowSchemas); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -192,7 +192,7 @@ func ensureMandatoryConfiguration(clientset flowcontrolclient.FlowcontrolV1beta1
|
|||||||
return plEnsurer.Ensure(flowcontrolbootstrap.MandatoryPriorityLevelConfigurations)
|
return plEnsurer.Ensure(flowcontrolbootstrap.MandatoryPriorityLevelConfigurations)
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeConfiguration(clientset flowcontrolclient.FlowcontrolV1beta1Interface) error {
|
func removeConfiguration(clientset flowcontrolclient.FlowcontrolV1beta2Interface) error {
|
||||||
if err := removeFlowSchema(clientset.FlowSchemas()); err != nil {
|
if err := removeFlowSchema(clientset.FlowSchemas()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -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/v1beta1"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
||||||
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"
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
flowcontrol "k8s.io/api/flowcontrol/v1beta1"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
||||||
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"
|
||||||
|
@ -29,7 +29,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
flowcontrol "k8s.io/api/flowcontrol/v1beta1"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
||||||
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"
|
||||||
@ -1080,7 +1080,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.FlowcontrolV1beta1(), serverConcurrency, requestWaitLimit)
|
controller := utilflowcontrol.New(factory, clientset.FlowcontrolV1beta2(), serverConcurrency, requestWaitLimit)
|
||||||
|
|
||||||
factory.Start(stopCh)
|
factory.Start(stopCh)
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ func (o *RecommendedOptions) ApplyTo(config *server.RecommendedConfig) error {
|
|||||||
}
|
}
|
||||||
config.FlowControl = utilflowcontrol.New(
|
config.FlowControl = utilflowcontrol.New(
|
||||||
config.SharedInformerFactory,
|
config.SharedInformerFactory,
|
||||||
kubernetes.NewForConfigOrDie(config.ClientConfig).FlowcontrolV1beta1(),
|
kubernetes.NewForConfigOrDie(config.ClientConfig).FlowcontrolV1beta2(),
|
||||||
config.MaxRequestsInFlight+config.MaxMutatingRequestsInFlight,
|
config.MaxRequestsInFlight+config.MaxMutatingRequestsInFlight,
|
||||||
config.RequestTimeout/4,
|
config.RequestTimeout/4,
|
||||||
)
|
)
|
||||||
|
@ -52,9 +52,9 @@ import (
|
|||||||
"k8s.io/client-go/util/workqueue"
|
"k8s.io/client-go/util/workqueue"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
|
|
||||||
flowcontrol "k8s.io/api/flowcontrol/v1beta1"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
||||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1"
|
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
|
||||||
flowcontrollister "k8s.io/client-go/listers/flowcontrol/v1beta1"
|
flowcontrollister "k8s.io/client-go/listers/flowcontrol/v1beta2"
|
||||||
)
|
)
|
||||||
|
|
||||||
const timeFmt = "2006-01-02T15:04:05.999"
|
const timeFmt = "2006-01-02T15:04:05.999"
|
||||||
@ -115,7 +115,7 @@ type configController struct {
|
|||||||
fsLister flowcontrollister.FlowSchemaLister
|
fsLister flowcontrollister.FlowSchemaLister
|
||||||
fsInformerSynced cache.InformerSynced
|
fsInformerSynced cache.InformerSynced
|
||||||
|
|
||||||
flowcontrolClient flowcontrolclient.FlowcontrolV1beta1Interface
|
flowcontrolClient flowcontrolclient.FlowcontrolV1beta2Interface
|
||||||
|
|
||||||
// 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
|
||||||
@ -203,7 +203,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().V1beta1()
|
fci := config.InformerFactory.Flowcontrol().V1beta2()
|
||||||
pli := fci.PriorityLevelConfigurations()
|
pli := fci.PriorityLevelConfigurations()
|
||||||
fsi := fci.FlowSchemas()
|
fsi := fci.FlowSchemas()
|
||||||
cfgCtlr.plLister = pli.Lister()
|
cfgCtlr.plLister = pli.Lister()
|
||||||
|
@ -30,8 +30,8 @@ import (
|
|||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
"k8s.io/utils/clock"
|
"k8s.io/utils/clock"
|
||||||
|
|
||||||
flowcontrol "k8s.io/api/flowcontrol/v1beta1"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
||||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1"
|
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConfigConsumerAsFieldManager is how the config consuminng
|
// ConfigConsumerAsFieldManager is how the config consuminng
|
||||||
@ -78,7 +78,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.FlowcontrolV1beta1Interface,
|
flowcontrolClient flowcontrolclient.FlowcontrolV1beta2Interface,
|
||||||
serverConcurrencyLimit int,
|
serverConcurrencyLimit int,
|
||||||
requestWaitLimit time.Duration,
|
requestWaitLimit time.Duration,
|
||||||
) Interface {
|
) Interface {
|
||||||
@ -123,7 +123,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.FlowcontrolV1beta1Interface
|
FlowcontrolClient flowcontrolclient.FlowcontrolV1beta2Interface
|
||||||
|
|
||||||
// ServerConcurrencyLimit for the controller to enforce
|
// ServerConcurrencyLimit for the controller to enforce
|
||||||
ServerConcurrencyLimit int
|
ServerConcurrencyLimit int
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
flowcontrol "k8s.io/api/flowcontrol/v1beta1"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/clock"
|
"k8s.io/apimachinery/pkg/util/clock"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
@ -39,7 +39,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/v1beta1"
|
fcclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -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.FlowcontrolV1beta1Interface
|
fcIfc fcclient.FlowcontrolV1beta2Interface
|
||||||
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
|
||||||
@ -244,7 +244,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.FlowcontrolV1beta1()
|
flowcontrolClient := clientset.FlowcontrolV1beta2()
|
||||||
cts := &ctlrTestState{t: t,
|
cts := &ctlrTestState{t: t,
|
||||||
fcIfc: flowcontrolClient,
|
fcIfc: flowcontrolClient,
|
||||||
existingFSs: map[string]*flowcontrol.FlowSchema{},
|
existingFSs: map[string]*flowcontrol.FlowSchema{},
|
||||||
@ -375,7 +375,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.FlowcontrolV1beta1()
|
flowcontrolClient := clientset.FlowcontrolV1beta2()
|
||||||
cts := &ctlrTestState{t: t,
|
cts := &ctlrTestState{t: t,
|
||||||
fcIfc: flowcontrolClient,
|
fcIfc: flowcontrolClient,
|
||||||
existingFSs: map[string]*flowcontrol.FlowSchema{},
|
existingFSs: map[string]*flowcontrol.FlowSchema{},
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
flowcontrol "k8s.io/api/flowcontrol/v1beta1"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
||||||
"k8s.io/apiserver/pkg/authentication/user"
|
"k8s.io/apiserver/pkg/authentication/user"
|
||||||
"k8s.io/apiserver/pkg/endpoints/request"
|
"k8s.io/apiserver/pkg/endpoints/request"
|
||||||
)
|
)
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
flowcontrol "k8s.io/api/flowcontrol/v1beta1"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
||||||
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"
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
flowcontrol "k8s.io/api/flowcontrol/v1beta1"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
||||||
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"
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
flowcontrol "k8s.io/api/flowcontrol/v1beta1"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ package flowcontrol
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
flowcontrol "k8s.io/api/flowcontrol/v1beta1"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
||||||
"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"
|
||||||
|
6
vendor/modules.txt
vendored
6
vendor/modules.txt
vendored
@ -1291,6 +1291,7 @@ k8s.io/api/events/v1beta1
|
|||||||
k8s.io/api/extensions/v1beta1
|
k8s.io/api/extensions/v1beta1
|
||||||
k8s.io/api/flowcontrol/v1alpha1
|
k8s.io/api/flowcontrol/v1alpha1
|
||||||
k8s.io/api/flowcontrol/v1beta1
|
k8s.io/api/flowcontrol/v1beta1
|
||||||
|
k8s.io/api/flowcontrol/v1beta2
|
||||||
k8s.io/api/imagepolicy/v1alpha1
|
k8s.io/api/imagepolicy/v1alpha1
|
||||||
k8s.io/api/networking/v1
|
k8s.io/api/networking/v1
|
||||||
k8s.io/api/networking/v1beta1
|
k8s.io/api/networking/v1beta1
|
||||||
@ -1606,6 +1607,7 @@ k8s.io/client-go/applyconfigurations/events/v1beta1
|
|||||||
k8s.io/client-go/applyconfigurations/extensions/v1beta1
|
k8s.io/client-go/applyconfigurations/extensions/v1beta1
|
||||||
k8s.io/client-go/applyconfigurations/flowcontrol/v1alpha1
|
k8s.io/client-go/applyconfigurations/flowcontrol/v1alpha1
|
||||||
k8s.io/client-go/applyconfigurations/flowcontrol/v1beta1
|
k8s.io/client-go/applyconfigurations/flowcontrol/v1beta1
|
||||||
|
k8s.io/client-go/applyconfigurations/flowcontrol/v1beta2
|
||||||
k8s.io/client-go/applyconfigurations/imagepolicy/v1alpha1
|
k8s.io/client-go/applyconfigurations/imagepolicy/v1alpha1
|
||||||
k8s.io/client-go/applyconfigurations/internal
|
k8s.io/client-go/applyconfigurations/internal
|
||||||
k8s.io/client-go/applyconfigurations/meta/v1
|
k8s.io/client-go/applyconfigurations/meta/v1
|
||||||
@ -1670,6 +1672,7 @@ k8s.io/client-go/informers/extensions/v1beta1
|
|||||||
k8s.io/client-go/informers/flowcontrol
|
k8s.io/client-go/informers/flowcontrol
|
||||||
k8s.io/client-go/informers/flowcontrol/v1alpha1
|
k8s.io/client-go/informers/flowcontrol/v1alpha1
|
||||||
k8s.io/client-go/informers/flowcontrol/v1beta1
|
k8s.io/client-go/informers/flowcontrol/v1beta1
|
||||||
|
k8s.io/client-go/informers/flowcontrol/v1beta2
|
||||||
k8s.io/client-go/informers/internalinterfaces
|
k8s.io/client-go/informers/internalinterfaces
|
||||||
k8s.io/client-go/informers/networking
|
k8s.io/client-go/informers/networking
|
||||||
k8s.io/client-go/informers/networking/v1
|
k8s.io/client-go/informers/networking/v1
|
||||||
@ -1750,6 +1753,8 @@ k8s.io/client-go/kubernetes/typed/flowcontrol/v1alpha1
|
|||||||
k8s.io/client-go/kubernetes/typed/flowcontrol/v1alpha1/fake
|
k8s.io/client-go/kubernetes/typed/flowcontrol/v1alpha1/fake
|
||||||
k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1
|
k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1
|
||||||
k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1/fake
|
k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1/fake
|
||||||
|
k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2
|
||||||
|
k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2/fake
|
||||||
k8s.io/client-go/kubernetes/typed/networking/v1
|
k8s.io/client-go/kubernetes/typed/networking/v1
|
||||||
k8s.io/client-go/kubernetes/typed/networking/v1/fake
|
k8s.io/client-go/kubernetes/typed/networking/v1/fake
|
||||||
k8s.io/client-go/kubernetes/typed/networking/v1beta1
|
k8s.io/client-go/kubernetes/typed/networking/v1beta1
|
||||||
@ -1805,6 +1810,7 @@ k8s.io/client-go/listers/events/v1beta1
|
|||||||
k8s.io/client-go/listers/extensions/v1beta1
|
k8s.io/client-go/listers/extensions/v1beta1
|
||||||
k8s.io/client-go/listers/flowcontrol/v1alpha1
|
k8s.io/client-go/listers/flowcontrol/v1alpha1
|
||||||
k8s.io/client-go/listers/flowcontrol/v1beta1
|
k8s.io/client-go/listers/flowcontrol/v1beta1
|
||||||
|
k8s.io/client-go/listers/flowcontrol/v1beta2
|
||||||
k8s.io/client-go/listers/networking/v1
|
k8s.io/client-go/listers/networking/v1
|
||||||
k8s.io/client-go/listers/networking/v1beta1
|
k8s.io/client-go/listers/networking/v1beta1
|
||||||
k8s.io/client-go/listers/node/v1
|
k8s.io/client-go/listers/node/v1
|
||||||
|
Loading…
Reference in New Issue
Block a user