mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
apiserver: update apf logic to use v1beta3
This commit is contained in:
parent
6edc251686
commit
0a99e6ebb1
@ -507,7 +507,7 @@ func BuildPriorityAndFairness(s *options.ServerRunOptions, extclient clientgocli
|
|||||||
}
|
}
|
||||||
return utilflowcontrol.New(
|
return utilflowcontrol.New(
|
||||||
versionedInformer,
|
versionedInformer,
|
||||||
extclient.FlowcontrolV1beta2(),
|
extclient.FlowcontrolV1beta3(),
|
||||||
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 (
|
||||||
flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2"
|
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3"
|
||||||
"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 []*flowcontrolv1beta2.FlowSchema) map[string]*flowcontrol.FlowSchema {
|
func internalizeFSes(exts []*flowcontrolv1beta3.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 []*flowcontrolv1beta2.FlowSchema) map[string]*flowcont
|
|||||||
return ans
|
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))
|
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/v1beta2"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||||
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,15 +21,15 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2"
|
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3"
|
||||||
"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/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"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/v1beta2"
|
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
|
||||||
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta2"
|
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta3"
|
||||||
flowcontrolapisv1beta2 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta2"
|
flowcontrolapisv1beta3 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -38,7 +38,7 @@ var (
|
|||||||
|
|
||||||
// FlowSchemaEnsurer ensures the specified bootstrap configuration objects
|
// FlowSchemaEnsurer ensures the specified bootstrap configuration objects
|
||||||
type FlowSchemaEnsurer interface {
|
type FlowSchemaEnsurer interface {
|
||||||
Ensure([]*flowcontrolv1beta2.FlowSchema) error
|
Ensure([]*flowcontrolv1beta3.FlowSchema) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// FlowSchemaRemover is the interface that wraps the
|
// 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.
|
// 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 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())
|
fsList, err := lister.List(labels.Everything())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to list FlowSchema - %w", err)
|
return nil, fmt.Errorf("failed to list FlowSchema - %w", err)
|
||||||
@ -116,7 +116,7 @@ type fsEnsurer struct {
|
|||||||
wrapper configurationWrapper
|
wrapper configurationWrapper
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *fsEnsurer) Ensure(flowSchemas []*flowcontrolv1beta2.FlowSchema) error {
|
func (e *fsEnsurer) Ensure(flowSchemas []*flowcontrolv1beta3.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
|
||||||
@ -148,7 +148,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.(*flowcontrolv1beta2.FlowSchema)
|
fsObject, ok := object.(*flowcontrolv1beta3.FlowSchema)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errObjectNotFlowSchema
|
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) {
|
func (fs *flowSchemaWrapper) Update(object runtime.Object) (runtime.Object, error) {
|
||||||
fsObject, ok := object.(*flowcontrolv1beta2.FlowSchema)
|
fsObject, ok := object.(*flowcontrolv1beta3.FlowSchema)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errObjectNotFlowSchema
|
return nil, errObjectNotFlowSchema
|
||||||
}
|
}
|
||||||
@ -174,11 +174,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.(*flowcontrolv1beta2.FlowSchema)
|
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta3.FlowSchema)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errObjectNotFlowSchema
|
return errObjectNotFlowSchema
|
||||||
}
|
}
|
||||||
currentFS, ok := current.(*flowcontrolv1beta2.FlowSchema)
|
currentFS, ok := current.(*flowcontrolv1beta3.FlowSchema)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errObjectNotFlowSchema
|
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) {
|
func (fs *flowSchemaWrapper) HasSpecChanged(bootstrap, current runtime.Object) (bool, error) {
|
||||||
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta2.FlowSchema)
|
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta3.FlowSchema)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, errObjectNotFlowSchema
|
return false, errObjectNotFlowSchema
|
||||||
}
|
}
|
||||||
currentFS, ok := current.(*flowcontrolv1beta2.FlowSchema)
|
currentFS, ok := current.(*flowcontrolv1beta3.FlowSchema)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, errObjectNotFlowSchema
|
return false, errObjectNotFlowSchema
|
||||||
}
|
}
|
||||||
@ -201,8 +201,8 @@ func (fs *flowSchemaWrapper) HasSpecChanged(bootstrap, current runtime.Object) (
|
|||||||
return flowSchemaSpecChanged(bootstrapFS, currentFS), nil
|
return flowSchemaSpecChanged(bootstrapFS, currentFS), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func flowSchemaSpecChanged(expected, actual *flowcontrolv1beta2.FlowSchema) bool {
|
func flowSchemaSpecChanged(expected, actual *flowcontrolv1beta3.FlowSchema) bool {
|
||||||
copiedExpectedFlowSchema := expected.DeepCopy()
|
copiedExpectedFlowSchema := expected.DeepCopy()
|
||||||
flowcontrolapisv1beta2.SetObjectDefaults_FlowSchema(copiedExpectedFlowSchema)
|
flowcontrolapisv1beta3.SetObjectDefaults_FlowSchema(copiedExpectedFlowSchema)
|
||||||
return !equality.Semantic.DeepEqual(copiedExpectedFlowSchema.Spec, actual.Spec)
|
return !equality.Semantic.DeepEqual(copiedExpectedFlowSchema.Spec, actual.Spec)
|
||||||
}
|
}
|
||||||
|
@ -21,15 +21,15 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2"
|
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3"
|
||||||
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/v1beta2"
|
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
|
||||||
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta2"
|
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta3"
|
||||||
"k8s.io/client-go/tools/cache"
|
"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"
|
||||||
"github.com/google/go-cmp/cmp/cmpopts"
|
"github.com/google/go-cmp/cmp/cmpopts"
|
||||||
@ -40,9 +40,9 @@ func TestEnsureFlowSchema(t *testing.T) {
|
|||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
strategy func(flowcontrolclient.FlowSchemaInterface, flowcontrollisters.FlowSchemaLister) FlowSchemaEnsurer
|
strategy func(flowcontrolclient.FlowSchemaInterface, flowcontrollisters.FlowSchemaLister) FlowSchemaEnsurer
|
||||||
current *flowcontrolv1beta2.FlowSchema
|
current *flowcontrolv1beta3.FlowSchema
|
||||||
bootstrap *flowcontrolv1beta2.FlowSchema
|
bootstrap *flowcontrolv1beta3.FlowSchema
|
||||||
expected *flowcontrolv1beta2.FlowSchema
|
expected *flowcontrolv1beta3.FlowSchema
|
||||||
}{
|
}{
|
||||||
// for suggested configurations
|
// for suggested configurations
|
||||||
{
|
{
|
||||||
@ -93,7 +93,7 @@ func TestEnsureFlowSchema(t *testing.T) {
|
|||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
client := fake.NewSimpleClientset().FlowcontrolV1beta2().FlowSchemas()
|
client := fake.NewSimpleClientset().FlowcontrolV1beta3().FlowSchemas()
|
||||||
indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
|
indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
|
||||||
if test.current != nil {
|
if test.current != nil {
|
||||||
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
|
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
|
||||||
@ -102,7 +102,7 @@ func TestEnsureFlowSchema(t *testing.T) {
|
|||||||
|
|
||||||
ensurer := test.strategy(client, flowcontrollisters.NewFlowSchemaLister(indexer))
|
ensurer := test.strategy(client, flowcontrollisters.NewFlowSchemaLister(indexer))
|
||||||
|
|
||||||
err := ensurer.Ensure([]*flowcontrolv1beta2.FlowSchema{test.bootstrap})
|
err := ensurer.Ensure([]*flowcontrolv1beta3.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)
|
||||||
}
|
}
|
||||||
@ -127,9 +127,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 *flowcontrolv1beta2.FlowSchema
|
current *flowcontrolv1beta3.FlowSchema
|
||||||
bootstrap *flowcontrolv1beta2.FlowSchema
|
bootstrap *flowcontrolv1beta3.FlowSchema
|
||||||
newObjectExpected *flowcontrolv1beta2.FlowSchema
|
newObjectExpected *flowcontrolv1beta3.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",
|
||||||
@ -234,23 +234,23 @@ func TestSuggestedFSEnsureStrategy_ShouldUpdate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFlowSchemaSpecChanged(t *testing.T) {
|
func TestFlowSchemaSpecChanged(t *testing.T) {
|
||||||
fs1 := &flowcontrolv1beta2.FlowSchema{
|
fs1 := &flowcontrolv1beta3.FlowSchema{
|
||||||
Spec: flowcontrolv1beta2.FlowSchemaSpec{},
|
Spec: flowcontrolv1beta3.FlowSchemaSpec{},
|
||||||
}
|
}
|
||||||
fs2 := &flowcontrolv1beta2.FlowSchema{
|
fs2 := &flowcontrolv1beta3.FlowSchema{
|
||||||
Spec: flowcontrolv1beta2.FlowSchemaSpec{
|
Spec: flowcontrolv1beta3.FlowSchemaSpec{
|
||||||
MatchingPrecedence: 1,
|
MatchingPrecedence: 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
fs1Defaulted := &flowcontrolv1beta2.FlowSchema{
|
fs1Defaulted := &flowcontrolv1beta3.FlowSchema{
|
||||||
Spec: flowcontrolv1beta2.FlowSchemaSpec{
|
Spec: flowcontrolv1beta3.FlowSchemaSpec{
|
||||||
MatchingPrecedence: flowcontrolapisv1beta2.FlowSchemaDefaultMatchingPrecedence,
|
MatchingPrecedence: flowcontrolapisv1beta3.FlowSchemaDefaultMatchingPrecedence,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
expected *flowcontrolv1beta2.FlowSchema
|
expected *flowcontrolv1beta3.FlowSchema
|
||||||
actual *flowcontrolv1beta2.FlowSchema
|
actual *flowcontrolv1beta3.FlowSchema
|
||||||
specChanged bool
|
specChanged bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
@ -283,7 +283,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 *flowcontrolv1beta2.FlowSchema
|
current *flowcontrolv1beta3.FlowSchema
|
||||||
bootstrapName string
|
bootstrapName string
|
||||||
removeExpected bool
|
removeExpected bool
|
||||||
}{
|
}{
|
||||||
@ -314,7 +314,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().FlowcontrolV1beta2().FlowSchemas()
|
client := fake.NewSimpleClientset().FlowcontrolV1beta3().FlowSchemas()
|
||||||
indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
|
indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
|
||||||
if test.current != nil {
|
if test.current != nil {
|
||||||
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
|
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
|
||||||
@ -348,18 +348,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 []*flowcontrolv1beta2.FlowSchema
|
current []*flowcontrolv1beta3.FlowSchema
|
||||||
bootstrap []*flowcontrolv1beta2.FlowSchema
|
bootstrap []*flowcontrolv1beta3.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: []*flowcontrolv1beta2.FlowSchema{
|
bootstrap: []*flowcontrolv1beta3.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: []*flowcontrolv1beta2.FlowSchema{
|
current: []*flowcontrolv1beta3.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(),
|
||||||
@ -368,8 +368,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: []*flowcontrolv1beta2.FlowSchema{},
|
bootstrap: []*flowcontrolv1beta3.FlowSchema{},
|
||||||
current: []*flowcontrolv1beta2.FlowSchema{
|
current: []*flowcontrolv1beta3.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(),
|
||||||
@ -378,10 +378,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: []*flowcontrolv1beta2.FlowSchema{
|
bootstrap: []*flowcontrolv1beta3.FlowSchema{
|
||||||
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
||||||
},
|
},
|
||||||
current: []*flowcontrolv1beta2.FlowSchema{
|
current: []*flowcontrolv1beta3.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(),
|
||||||
@ -390,10 +390,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: []*flowcontrolv1beta2.FlowSchema{
|
bootstrap: []*flowcontrolv1beta3.FlowSchema{
|
||||||
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
||||||
},
|
},
|
||||||
current: []*flowcontrolv1beta2.FlowSchema{
|
current: []*flowcontrolv1beta3.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(),
|
||||||
@ -425,17 +425,17 @@ func TestGetFlowSchemaRemoveCandidate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type fsBuilder struct {
|
type fsBuilder struct {
|
||||||
object *flowcontrolv1beta2.FlowSchema
|
object *flowcontrolv1beta3.FlowSchema
|
||||||
}
|
}
|
||||||
|
|
||||||
func newFlowSchema(name, plName string, matchingPrecedence int32) *fsBuilder {
|
func newFlowSchema(name, plName string, matchingPrecedence int32) *fsBuilder {
|
||||||
return &fsBuilder{
|
return &fsBuilder{
|
||||||
object: &flowcontrolv1beta2.FlowSchema{
|
object: &flowcontrolv1beta3.FlowSchema{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
},
|
},
|
||||||
Spec: flowcontrolv1beta2.FlowSchemaSpec{
|
Spec: flowcontrolv1beta3.FlowSchemaSpec{
|
||||||
PriorityLevelConfiguration: flowcontrolv1beta2.PriorityLevelConfigurationReference{
|
PriorityLevelConfiguration: flowcontrolv1beta3.PriorityLevelConfigurationReference{
|
||||||
Name: plName,
|
Name: plName,
|
||||||
},
|
},
|
||||||
MatchingPrecedence: matchingPrecedence,
|
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
|
return b.object
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,5 +463,5 @@ func setAnnotation(accessor metav1.Object, value string) {
|
|||||||
accessor.SetAnnotations(map[string]string{})
|
accessor.SetAnnotations(map[string]string{})
|
||||||
}
|
}
|
||||||
|
|
||||||
accessor.GetAnnotations()[flowcontrolv1beta2.AutoUpdateAnnotationKey] = value
|
accessor.GetAnnotations()[flowcontrolv1beta3.AutoUpdateAnnotationKey] = value
|
||||||
}
|
}
|
||||||
|
@ -21,15 +21,15 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2"
|
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3"
|
||||||
"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/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"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/v1beta2"
|
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
|
||||||
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta2"
|
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta3"
|
||||||
flowcontrolapisv1beta2 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta2"
|
flowcontrolapisv1beta3 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -38,7 +38,7 @@ var (
|
|||||||
|
|
||||||
// PriorityLevelEnsurer ensures the specified bootstrap configuration objects
|
// PriorityLevelEnsurer ensures the specified bootstrap configuration objects
|
||||||
type PriorityLevelEnsurer interface {
|
type PriorityLevelEnsurer interface {
|
||||||
Ensure([]*flowcontrolv1beta2.PriorityLevelConfiguration) error
|
Ensure([]*flowcontrolv1beta3.PriorityLevelConfiguration) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// PriorityLevelRemover is the interface that wraps the
|
// 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.
|
// 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 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())
|
plList, err := lister.List(labels.Everything())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to list PriorityLevelConfiguration - %w", err)
|
return nil, fmt.Errorf("failed to list PriorityLevelConfiguration - %w", err)
|
||||||
@ -117,7 +117,7 @@ type plEnsurer struct {
|
|||||||
wrapper configurationWrapper
|
wrapper configurationWrapper
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *plEnsurer) Ensure(priorityLevels []*flowcontrolv1beta2.PriorityLevelConfiguration) error {
|
func (e *plEnsurer) Ensure(priorityLevels []*flowcontrolv1beta3.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
|
||||||
@ -149,7 +149,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.(*flowcontrolv1beta2.PriorityLevelConfiguration)
|
plObject, ok := object.(*flowcontrolv1beta3.PriorityLevelConfiguration)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errObjectNotPriorityLevel
|
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) {
|
func (fs *priorityLevelConfigurationWrapper) Update(object runtime.Object) (runtime.Object, error) {
|
||||||
fsObject, ok := object.(*flowcontrolv1beta2.PriorityLevelConfiguration)
|
fsObject, ok := object.(*flowcontrolv1beta3.PriorityLevelConfiguration)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errObjectNotPriorityLevel
|
return nil, errObjectNotPriorityLevel
|
||||||
}
|
}
|
||||||
@ -175,11 +175,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.(*flowcontrolv1beta2.PriorityLevelConfiguration)
|
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta3.PriorityLevelConfiguration)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errObjectNotPriorityLevel
|
return errObjectNotPriorityLevel
|
||||||
}
|
}
|
||||||
currentFS, ok := current.(*flowcontrolv1beta2.PriorityLevelConfiguration)
|
currentFS, ok := current.(*flowcontrolv1beta3.PriorityLevelConfiguration)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errObjectNotPriorityLevel
|
return errObjectNotPriorityLevel
|
||||||
}
|
}
|
||||||
@ -190,11 +190,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.(*flowcontrolv1beta2.PriorityLevelConfiguration)
|
bootstrapFS, ok := bootstrap.(*flowcontrolv1beta3.PriorityLevelConfiguration)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, errObjectNotPriorityLevel
|
return false, errObjectNotPriorityLevel
|
||||||
}
|
}
|
||||||
currentFS, ok := current.(*flowcontrolv1beta2.PriorityLevelConfiguration)
|
currentFS, ok := current.(*flowcontrolv1beta3.PriorityLevelConfiguration)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, errObjectNotPriorityLevel
|
return false, errObjectNotPriorityLevel
|
||||||
}
|
}
|
||||||
@ -202,8 +202,8 @@ func (fs *priorityLevelConfigurationWrapper) HasSpecChanged(bootstrap, current r
|
|||||||
return priorityLevelSpecChanged(bootstrapFS, currentFS), nil
|
return priorityLevelSpecChanged(bootstrapFS, currentFS), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func priorityLevelSpecChanged(expected, actual *flowcontrolv1beta2.PriorityLevelConfiguration) bool {
|
func priorityLevelSpecChanged(expected, actual *flowcontrolv1beta3.PriorityLevelConfiguration) bool {
|
||||||
copiedExpectedPriorityLevel := expected.DeepCopy()
|
copiedExpectedPriorityLevel := expected.DeepCopy()
|
||||||
flowcontrolapisv1beta2.SetObjectDefaults_PriorityLevelConfiguration(copiedExpectedPriorityLevel)
|
flowcontrolapisv1beta3.SetObjectDefaults_PriorityLevelConfiguration(copiedExpectedPriorityLevel)
|
||||||
return !equality.Semantic.DeepEqual(copiedExpectedPriorityLevel.Spec, actual.Spec)
|
return !equality.Semantic.DeepEqual(copiedExpectedPriorityLevel.Spec, actual.Spec)
|
||||||
}
|
}
|
||||||
|
@ -21,15 +21,15 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2"
|
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3"
|
||||||
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/v1beta2"
|
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
|
||||||
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta2"
|
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta3"
|
||||||
"k8s.io/client-go/tools/cache"
|
"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"
|
||||||
"github.com/google/go-cmp/cmp/cmpopts"
|
"github.com/google/go-cmp/cmp/cmpopts"
|
||||||
@ -40,9 +40,9 @@ func TestEnsurePriorityLevel(t *testing.T) {
|
|||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
strategy func(flowcontrolclient.PriorityLevelConfigurationInterface, flowcontrollisters.PriorityLevelConfigurationLister) PriorityLevelEnsurer
|
strategy func(flowcontrolclient.PriorityLevelConfigurationInterface, flowcontrollisters.PriorityLevelConfigurationLister) PriorityLevelEnsurer
|
||||||
current *flowcontrolv1beta2.PriorityLevelConfiguration
|
current *flowcontrolv1beta3.PriorityLevelConfiguration
|
||||||
bootstrap *flowcontrolv1beta2.PriorityLevelConfiguration
|
bootstrap *flowcontrolv1beta3.PriorityLevelConfiguration
|
||||||
expected *flowcontrolv1beta2.PriorityLevelConfiguration
|
expected *flowcontrolv1beta3.PriorityLevelConfiguration
|
||||||
}{
|
}{
|
||||||
// for suggested configurations
|
// for suggested configurations
|
||||||
{
|
{
|
||||||
@ -93,7 +93,7 @@ func TestEnsurePriorityLevel(t *testing.T) {
|
|||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
client := fake.NewSimpleClientset().FlowcontrolV1beta2().PriorityLevelConfigurations()
|
client := fake.NewSimpleClientset().FlowcontrolV1beta3().PriorityLevelConfigurations()
|
||||||
indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
|
indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
|
||||||
if test.current != nil {
|
if test.current != nil {
|
||||||
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
|
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
|
||||||
@ -102,7 +102,7 @@ func TestEnsurePriorityLevel(t *testing.T) {
|
|||||||
|
|
||||||
ensurer := test.strategy(client, flowcontrollisters.NewPriorityLevelConfigurationLister(indexer))
|
ensurer := test.strategy(client, flowcontrollisters.NewPriorityLevelConfigurationLister(indexer))
|
||||||
|
|
||||||
err := ensurer.Ensure([]*flowcontrolv1beta2.PriorityLevelConfiguration{test.bootstrap})
|
err := ensurer.Ensure([]*flowcontrolv1beta3.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)
|
||||||
}
|
}
|
||||||
@ -127,9 +127,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 *flowcontrolv1beta2.PriorityLevelConfiguration
|
current *flowcontrolv1beta3.PriorityLevelConfiguration
|
||||||
bootstrap *flowcontrolv1beta2.PriorityLevelConfiguration
|
bootstrap *flowcontrolv1beta3.PriorityLevelConfiguration
|
||||||
newObjectExpected *flowcontrolv1beta2.PriorityLevelConfiguration
|
newObjectExpected *flowcontrolv1beta3.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",
|
||||||
@ -234,39 +234,39 @@ func TestSuggestedPLEnsureStrategy_ShouldUpdate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPriorityLevelSpecChanged(t *testing.T) {
|
func TestPriorityLevelSpecChanged(t *testing.T) {
|
||||||
pl1 := &flowcontrolv1beta2.PriorityLevelConfiguration{
|
pl1 := &flowcontrolv1beta3.PriorityLevelConfiguration{
|
||||||
Spec: flowcontrolv1beta2.PriorityLevelConfigurationSpec{
|
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{
|
||||||
Type: flowcontrolv1beta2.PriorityLevelEnablementLimited,
|
Type: flowcontrolv1beta3.PriorityLevelEnablementLimited,
|
||||||
Limited: &flowcontrolv1beta2.LimitedPriorityLevelConfiguration{
|
Limited: &flowcontrolv1beta3.LimitedPriorityLevelConfiguration{
|
||||||
LimitResponse: flowcontrolv1beta2.LimitResponse{
|
LimitResponse: flowcontrolv1beta3.LimitResponse{
|
||||||
Type: flowcontrolv1beta2.LimitResponseTypeReject,
|
Type: flowcontrolv1beta3.LimitResponseTypeReject,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
pl2 := &flowcontrolv1beta2.PriorityLevelConfiguration{
|
pl2 := &flowcontrolv1beta3.PriorityLevelConfiguration{
|
||||||
Spec: flowcontrolv1beta2.PriorityLevelConfigurationSpec{
|
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{
|
||||||
Type: flowcontrolv1beta2.PriorityLevelEnablementLimited,
|
Type: flowcontrolv1beta3.PriorityLevelEnablementLimited,
|
||||||
Limited: &flowcontrolv1beta2.LimitedPriorityLevelConfiguration{
|
Limited: &flowcontrolv1beta3.LimitedPriorityLevelConfiguration{
|
||||||
AssuredConcurrencyShares: 1,
|
AssuredConcurrencyShares: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
pl1Defaulted := &flowcontrolv1beta2.PriorityLevelConfiguration{
|
pl1Defaulted := &flowcontrolv1beta3.PriorityLevelConfiguration{
|
||||||
Spec: flowcontrolv1beta2.PriorityLevelConfigurationSpec{
|
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{
|
||||||
Type: flowcontrolv1beta2.PriorityLevelEnablementLimited,
|
Type: flowcontrolv1beta3.PriorityLevelEnablementLimited,
|
||||||
Limited: &flowcontrolv1beta2.LimitedPriorityLevelConfiguration{
|
Limited: &flowcontrolv1beta3.LimitedPriorityLevelConfiguration{
|
||||||
AssuredConcurrencyShares: flowcontrolapisv1beta2.PriorityLevelConfigurationDefaultAssuredConcurrencyShares,
|
AssuredConcurrencyShares: flowcontrolapisv1beta3.PriorityLevelConfigurationDefaultAssuredConcurrencyShares,
|
||||||
LimitResponse: flowcontrolv1beta2.LimitResponse{
|
LimitResponse: flowcontrolv1beta3.LimitResponse{
|
||||||
Type: flowcontrolv1beta2.LimitResponseTypeReject,
|
Type: flowcontrolv1beta3.LimitResponseTypeReject,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
expected *flowcontrolv1beta2.PriorityLevelConfiguration
|
expected *flowcontrolv1beta3.PriorityLevelConfiguration
|
||||||
actual *flowcontrolv1beta2.PriorityLevelConfiguration
|
actual *flowcontrolv1beta3.PriorityLevelConfiguration
|
||||||
specChanged bool
|
specChanged bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
@ -299,7 +299,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 *flowcontrolv1beta2.PriorityLevelConfiguration
|
current *flowcontrolv1beta3.PriorityLevelConfiguration
|
||||||
bootstrapName string
|
bootstrapName string
|
||||||
removeExpected bool
|
removeExpected bool
|
||||||
}{
|
}{
|
||||||
@ -330,7 +330,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().FlowcontrolV1beta2().PriorityLevelConfigurations()
|
client := fake.NewSimpleClientset().FlowcontrolV1beta3().PriorityLevelConfigurations()
|
||||||
indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
|
indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
|
||||||
if test.current != nil {
|
if test.current != nil {
|
||||||
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
|
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
|
||||||
@ -364,18 +364,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 []*flowcontrolv1beta2.PriorityLevelConfiguration
|
current []*flowcontrolv1beta3.PriorityLevelConfiguration
|
||||||
bootstrap []*flowcontrolv1beta2.PriorityLevelConfiguration
|
bootstrap []*flowcontrolv1beta3.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: []*flowcontrolv1beta2.PriorityLevelConfiguration{
|
bootstrap: []*flowcontrolv1beta3.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: []*flowcontrolv1beta2.PriorityLevelConfiguration{
|
current: []*flowcontrolv1beta3.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(),
|
||||||
@ -384,8 +384,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: []*flowcontrolv1beta2.PriorityLevelConfiguration{},
|
bootstrap: []*flowcontrolv1beta3.PriorityLevelConfiguration{},
|
||||||
current: []*flowcontrolv1beta2.PriorityLevelConfiguration{
|
current: []*flowcontrolv1beta3.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(),
|
||||||
@ -394,10 +394,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: []*flowcontrolv1beta2.PriorityLevelConfiguration{
|
bootstrap: []*flowcontrolv1beta3.PriorityLevelConfiguration{
|
||||||
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
|
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
|
||||||
},
|
},
|
||||||
current: []*flowcontrolv1beta2.PriorityLevelConfiguration{
|
current: []*flowcontrolv1beta3.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(),
|
||||||
@ -406,10 +406,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: []*flowcontrolv1beta2.PriorityLevelConfiguration{
|
bootstrap: []*flowcontrolv1beta3.PriorityLevelConfiguration{
|
||||||
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
|
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
|
||||||
},
|
},
|
||||||
current: []*flowcontrolv1beta2.PriorityLevelConfiguration{
|
current: []*flowcontrolv1beta3.PriorityLevelConfiguration{
|
||||||
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
|
newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").Object(),
|
||||||
newPLConfiguration("pl2").Object(),
|
newPLConfiguration("pl2").Object(),
|
||||||
newPLConfiguration("pl3").Object(),
|
newPLConfiguration("pl3").Object(),
|
||||||
@ -441,12 +441,12 @@ func TestGetPriorityLevelRemoveCandidate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type plBuilder struct {
|
type plBuilder struct {
|
||||||
object *flowcontrolv1beta2.PriorityLevelConfiguration
|
object *flowcontrolv1beta3.PriorityLevelConfiguration
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPLConfiguration(name string) *plBuilder {
|
func newPLConfiguration(name string) *plBuilder {
|
||||||
return &plBuilder{
|
return &plBuilder{
|
||||||
object: &flowcontrolv1beta2.PriorityLevelConfiguration{
|
object: &flowcontrolv1beta3.PriorityLevelConfiguration{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
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
|
return b.object
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,11 +469,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 = flowcontrolv1beta2.PriorityLevelEnablementLimited
|
b.object.Spec.Type = flowcontrolv1beta3.PriorityLevelEnablementLimited
|
||||||
b.object.Spec.Limited = &flowcontrolv1beta2.LimitedPriorityLevelConfiguration{
|
b.object.Spec.Limited = &flowcontrolv1beta3.LimitedPriorityLevelConfiguration{
|
||||||
AssuredConcurrencyShares: assuredConcurrencyShares,
|
AssuredConcurrencyShares: assuredConcurrencyShares,
|
||||||
LimitResponse: flowcontrolv1beta2.LimitResponse{
|
LimitResponse: flowcontrolv1beta3.LimitResponse{
|
||||||
Type: flowcontrolv1beta2.LimitResponseTypeReject,
|
Type: flowcontrolv1beta3.LimitResponseTypeReject,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return b
|
return b
|
||||||
@ -486,8 +486,8 @@ func (b *plBuilder) WithQueuing(queues, handSize, queueLengthLimit int32) *plBui
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
limited.LimitResponse.Type = flowcontrolv1beta2.LimitResponseTypeQueue
|
limited.LimitResponse.Type = flowcontrolv1beta3.LimitResponseTypeQueue
|
||||||
limited.LimitResponse.Queuing = &flowcontrolv1beta2.QueuingConfiguration{
|
limited.LimitResponse.Queuing = &flowcontrolv1beta3.QueuingConfiguration{
|
||||||
Queues: queues,
|
Queues: queues,
|
||||||
HandSize: handSize,
|
HandSize: handSize,
|
||||||
QueueLengthLimit: queueLengthLimit,
|
QueueLengthLimit: queueLengthLimit,
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
flowcontrolv1beta2 "k8s.io/api/flowcontrol/v1beta2"
|
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"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
|
// shouldUpdateSpec inspects the auto-update annotation key and generation field to determine
|
||||||
// whether the configurationWrapper object should be auto-updated.
|
// whether the configurationWrapper object should be auto-updated.
|
||||||
func shouldUpdateSpec(accessor metav1.Object) bool {
|
func shouldUpdateSpec(accessor metav1.Object) bool {
|
||||||
value, _ := accessor.GetAnnotations()[flowcontrolv1beta2.AutoUpdateAnnotationKey]
|
value, _ := accessor.GetAnnotations()[flowcontrolv1beta3.AutoUpdateAnnotationKey]
|
||||||
if autoUpdate, err := strconv.ParseBool(value); err == nil {
|
if autoUpdate, err := strconv.ParseBool(value); err == nil {
|
||||||
return autoUpdate
|
return autoUpdate
|
||||||
}
|
}
|
||||||
@ -197,7 +197,7 @@ func shouldUpdateSpec(accessor metav1.Object) bool {
|
|||||||
// shouldUpdateAnnotation determines whether the current value of the auto-update annotation
|
// shouldUpdateAnnotation determines whether the current value of the auto-update annotation
|
||||||
// key matches the desired value.
|
// key matches the desired value.
|
||||||
func shouldUpdateAnnotation(accessor metav1.Object, desired bool) bool {
|
func shouldUpdateAnnotation(accessor metav1.Object, desired bool) bool {
|
||||||
if value, ok := accessor.GetAnnotations()[flowcontrolv1beta2.AutoUpdateAnnotationKey]; ok {
|
if value, ok := accessor.GetAnnotations()[flowcontrolv1beta3.AutoUpdateAnnotationKey]; ok {
|
||||||
if current, err := strconv.ParseBool(value); err == nil && current == desired {
|
if current, err := strconv.ParseBool(value); err == nil && current == desired {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -212,7 +212,7 @@ func setAutoUpdateAnnotation(accessor metav1.Object, autoUpdate bool) {
|
|||||||
accessor.SetAnnotations(map[string]string{})
|
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.
|
// 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)
|
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)
|
autoUpdate, err := strconv.ParseBool(value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.ErrorS(err, fmt.Sprintf("Skipping deletion of the %s", wrapper.TypeName()), "name", name)
|
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)
|
candidates := make([]string, 0)
|
||||||
for i := range current {
|
for i := range current {
|
||||||
object := current[i]
|
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,
|
// the configuration object does not have the annotation key,
|
||||||
// it's probably a user defined configuration object,
|
// it's probably a user defined configuration object,
|
||||||
// so we can skip it.
|
// so we can skip it.
|
||||||
|
@ -29,8 +29,8 @@ import (
|
|||||||
genericapiserver "k8s.io/apiserver/pkg/server"
|
genericapiserver "k8s.io/apiserver/pkg/server"
|
||||||
serverstorage "k8s.io/apiserver/pkg/server/storage"
|
serverstorage "k8s.io/apiserver/pkg/server/storage"
|
||||||
"k8s.io/client-go/informers"
|
"k8s.io/client-go/informers"
|
||||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
|
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
|
||||||
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta2"
|
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta3"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
@ -120,11 +120,11 @@ func (p RESTStorageProvider) GroupName() string {
|
|||||||
func (p RESTStorageProvider) PostStartHook() (string, genericapiserver.PostStartHookFunc, error) {
|
func (p RESTStorageProvider) PostStartHook() (string, genericapiserver.PostStartHookFunc, error) {
|
||||||
bce := &bootstrapConfigurationEnsurer{
|
bce := &bootstrapConfigurationEnsurer{
|
||||||
informersSynced: []cache.InformerSynced{
|
informersSynced: []cache.InformerSynced{
|
||||||
p.InformerFactory.Flowcontrol().V1beta2().PriorityLevelConfigurations().Informer().HasSynced,
|
p.InformerFactory.Flowcontrol().V1beta3().PriorityLevelConfigurations().Informer().HasSynced,
|
||||||
p.InformerFactory.Flowcontrol().V1beta2().FlowSchemas().Informer().HasSynced,
|
p.InformerFactory.Flowcontrol().V1beta3().FlowSchemas().Informer().HasSynced,
|
||||||
},
|
},
|
||||||
fsLister: p.InformerFactory.Flowcontrol().V1beta2().FlowSchemas().Lister(),
|
fsLister: p.InformerFactory.Flowcontrol().V1beta3().FlowSchemas().Lister(),
|
||||||
plcLister: p.InformerFactory.Flowcontrol().V1beta2().PriorityLevelConfigurations().Lister(),
|
plcLister: p.InformerFactory.Flowcontrol().V1beta3().PriorityLevelConfigurations().Lister(),
|
||||||
}
|
}
|
||||||
return PostStartHookName, bce.ensureAPFBootstrapConfiguration, nil
|
return PostStartHookName, bce.ensureAPFBootstrapConfiguration, nil
|
||||||
}
|
}
|
||||||
@ -182,7 +182,7 @@ func (bce *bootstrapConfigurationEnsurer) ensureAPFBootstrapConfiguration(hookCo
|
|||||||
return nil
|
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 {
|
if err := ensureSuggestedConfiguration(clientset, fsLister, plcLister); err != nil {
|
||||||
// We should not attempt creation of mandatory objects if ensuring the suggested
|
// We should not attempt creation of mandatory objects if ensuring the suggested
|
||||||
// configuration resulted in an error.
|
// configuration resulted in an error.
|
||||||
@ -201,7 +201,7 @@ func ensure(clientset flowcontrolclient.FlowcontrolV1beta2Interface, fsLister fl
|
|||||||
return nil
|
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)
|
plEnsurer := ensurer.NewSuggestedPriorityLevelEnsurerEnsurer(clientset.PriorityLevelConfigurations(), plcLister)
|
||||||
if err := plEnsurer.Ensure(flowcontrolbootstrap.SuggestedPriorityLevelConfigurations); err != nil {
|
if err := plEnsurer.Ensure(flowcontrolbootstrap.SuggestedPriorityLevelConfigurations); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -211,7 +211,7 @@ func ensureSuggestedConfiguration(clientset flowcontrolclient.FlowcontrolV1beta2
|
|||||||
return fsEnsurer.Ensure(flowcontrolbootstrap.SuggestedFlowSchemas)
|
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)
|
fsEnsurer := ensurer.NewMandatoryFlowSchemaEnsurer(clientset.FlowSchemas(), fsLister)
|
||||||
if err := fsEnsurer.Ensure(flowcontrolbootstrap.MandatoryFlowSchemas); err != nil {
|
if err := fsEnsurer.Ensure(flowcontrolbootstrap.MandatoryFlowSchemas); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -221,7 +221,7 @@ func ensureMandatoryConfiguration(clientset flowcontrolclient.FlowcontrolV1beta2
|
|||||||
return plEnsurer.Ensure(flowcontrolbootstrap.MandatoryPriorityLevelConfigurations)
|
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 {
|
if err := removeDanglingBootstrapFlowSchema(clientset.FlowSchemas(), fsLister); 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/v1beta2"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||||
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"
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||||
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/v1beta2"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||||
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"
|
||||||
@ -1090,7 +1090,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.FlowcontrolV1beta2(), serverConcurrency, requestWaitLimit)
|
controller := utilflowcontrol.New(factory, clientset.FlowcontrolV1beta3(), serverConcurrency, requestWaitLimit)
|
||||||
|
|
||||||
factory.Start(stopCh)
|
factory.Start(stopCh)
|
||||||
|
|
||||||
|
@ -141,7 +141,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).FlowcontrolV1beta2(),
|
kubernetes.NewForConfigOrDie(config.ClientConfig).FlowcontrolV1beta3(),
|
||||||
config.MaxRequestsInFlight+config.MaxMutatingRequestsInFlight,
|
config.MaxRequestsInFlight+config.MaxMutatingRequestsInFlight,
|
||||||
config.RequestTimeout/4,
|
config.RequestTimeout/4,
|
||||||
)
|
)
|
||||||
|
@ -52,9 +52,9 @@ import (
|
|||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
"k8s.io/utils/clock"
|
"k8s.io/utils/clock"
|
||||||
|
|
||||||
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
|
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
|
||||||
flowcontrollister "k8s.io/client-go/listers/flowcontrol/v1beta2"
|
flowcontrollister "k8s.io/client-go/listers/flowcontrol/v1beta3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const timeFmt = "2006-01-02T15:04:05.999"
|
const timeFmt = "2006-01-02T15:04:05.999"
|
||||||
@ -123,7 +123,7 @@ type configController struct {
|
|||||||
fsLister flowcontrollister.FlowSchemaLister
|
fsLister flowcontrollister.FlowSchemaLister
|
||||||
fsInformerSynced cache.InformerSynced
|
fsInformerSynced cache.InformerSynced
|
||||||
|
|
||||||
flowcontrolClient flowcontrolclient.FlowcontrolV1beta2Interface
|
flowcontrolClient flowcontrolclient.FlowcontrolV1beta3Interface
|
||||||
|
|
||||||
// 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
|
||||||
@ -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")
|
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().V1beta2()
|
fci := config.InformerFactory.Flowcontrol().V1beta3()
|
||||||
pli := fci.PriorityLevelConfigurations()
|
pli := fci.PriorityLevelConfigurations()
|
||||||
fsi := fci.FlowSchemas()
|
fsi := fci.FlowSchemas()
|
||||||
cfgCtlr.plLister = pli.Lister()
|
cfgCtlr.plLister = pli.Lister()
|
||||||
|
@ -32,8 +32,8 @@ import (
|
|||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
"k8s.io/utils/clock"
|
"k8s.io/utils/clock"
|
||||||
|
|
||||||
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
|
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConfigConsumerAsFieldManager is how the config consuminng
|
// ConfigConsumerAsFieldManager is how the config consuminng
|
||||||
@ -83,7 +83,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.FlowcontrolV1beta2Interface,
|
flowcontrolClient flowcontrolclient.FlowcontrolV1beta3Interface,
|
||||||
serverConcurrencyLimit int,
|
serverConcurrencyLimit int,
|
||||||
requestWaitLimit time.Duration,
|
requestWaitLimit time.Duration,
|
||||||
) Interface {
|
) Interface {
|
||||||
@ -129,7 +129,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.FlowcontrolV1beta2Interface
|
FlowcontrolClient flowcontrolclient.FlowcontrolV1beta3Interface
|
||||||
|
|
||||||
// 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/v1beta2"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
@ -38,7 +38,7 @@ import (
|
|||||||
fcrequest "k8s.io/apiserver/pkg/util/flowcontrol/request"
|
fcrequest "k8s.io/apiserver/pkg/util/flowcontrol/request"
|
||||||
"k8s.io/client-go/informers"
|
"k8s.io/client-go/informers"
|
||||||
clientsetfake "k8s.io/client-go/kubernetes/fake"
|
clientsetfake "k8s.io/client-go/kubernetes/fake"
|
||||||
fcclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2"
|
fcclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
"k8s.io/utils/clock"
|
"k8s.io/utils/clock"
|
||||||
)
|
)
|
||||||
@ -70,7 +70,7 @@ func (cfgCtlr *configController) hasPriorityLevelState(plName string) bool {
|
|||||||
type ctlrTestState struct {
|
type ctlrTestState struct {
|
||||||
t *testing.T
|
t *testing.T
|
||||||
cfgCtlr *configController
|
cfgCtlr *configController
|
||||||
fcIfc fcclient.FlowcontrolV1beta2Interface
|
fcIfc fcclient.FlowcontrolV1beta3Interface
|
||||||
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
|
||||||
@ -241,7 +241,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.FlowcontrolV1beta2()
|
flowcontrolClient := clientset.FlowcontrolV1beta3()
|
||||||
cts := &ctlrTestState{t: t,
|
cts := &ctlrTestState{t: t,
|
||||||
fcIfc: flowcontrolClient,
|
fcIfc: flowcontrolClient,
|
||||||
existingFSs: map[string]*flowcontrol.FlowSchema{},
|
existingFSs: map[string]*flowcontrol.FlowSchema{},
|
||||||
@ -373,7 +373,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.FlowcontrolV1beta2()
|
flowcontrolClient := clientset.FlowcontrolV1beta3()
|
||||||
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/v1beta2"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||||
"k8s.io/apiserver/pkg/authentication/user"
|
"k8s.io/apiserver/pkg/authentication/user"
|
||||||
"k8s.io/apiserver/pkg/endpoints/request"
|
"k8s.io/apiserver/pkg/endpoints/request"
|
||||||
)
|
)
|
||||||
@ -93,7 +93,7 @@ func FmtPriorityLevelConfiguration(pl *flowcontrol.PriorityLevelConfiguration) s
|
|||||||
return "nil"
|
return "nil"
|
||||||
}
|
}
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
buf.WriteString(fmt.Sprintf("&flowcontrolv1beta1.PriorityLevelConfiguration{ObjectMeta: %#+v, Spec: ",
|
buf.WriteString(fmt.Sprintf("&flowcontrolv1beta3.PriorityLevelConfiguration{ObjectMeta: %#+v, Spec: ",
|
||||||
pl.ObjectMeta))
|
pl.ObjectMeta))
|
||||||
BufferPriorityLevelConfigurationSpec(&buf, &pl.Spec)
|
BufferPriorityLevelConfigurationSpec(&buf, &pl.Spec)
|
||||||
buf.WriteString(fmt.Sprintf(", Status: %#+v}", pl.Status))
|
buf.WriteString(fmt.Sprintf(", Status: %#+v}", pl.Status))
|
||||||
@ -111,7 +111,7 @@ func FmtPriorityLevelConfigurationSpec(plSpec *flowcontrol.PriorityLevelConfigur
|
|||||||
// BufferPriorityLevelConfigurationSpec writes a golang source
|
// BufferPriorityLevelConfigurationSpec writes a golang source
|
||||||
// expression for the given value to the given buffer
|
// expression for the given value to the given buffer
|
||||||
func BufferPriorityLevelConfigurationSpec(buf *bytes.Buffer, plSpec *flowcontrol.PriorityLevelConfigurationSpec) {
|
func BufferPriorityLevelConfigurationSpec(buf *bytes.Buffer, plSpec *flowcontrol.PriorityLevelConfigurationSpec) {
|
||||||
buf.WriteString(fmt.Sprintf("flowcontrolv1beta1.PriorityLevelConfigurationSpec{Type: %#v", plSpec.Type))
|
buf.WriteString(fmt.Sprintf("flowcontrolv1beta3.PriorityLevelConfigurationSpec{Type: %#v", plSpec.Type))
|
||||||
if plSpec.Limited != nil {
|
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))
|
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 {
|
if plSpec.Limited.LimitResponse.Queuing != nil {
|
||||||
@ -128,7 +128,7 @@ func FmtFlowSchema(fs *flowcontrol.FlowSchema) string {
|
|||||||
return "nil"
|
return "nil"
|
||||||
}
|
}
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
buf.WriteString(fmt.Sprintf("&flowcontrolv1beta1.FlowSchema{ObjectMeta: %#+v, Spec: ",
|
buf.WriteString(fmt.Sprintf("&flowcontrolv1beta3.FlowSchema{ObjectMeta: %#+v, Spec: ",
|
||||||
fs.ObjectMeta))
|
fs.ObjectMeta))
|
||||||
BufferFlowSchemaSpec(&buf, &fs.Spec)
|
BufferFlowSchemaSpec(&buf, &fs.Spec)
|
||||||
buf.WriteString(fmt.Sprintf(", Status: %#+v}", fs.Status))
|
buf.WriteString(fmt.Sprintf(", Status: %#+v}", fs.Status))
|
||||||
@ -146,7 +146,7 @@ func FmtFlowSchemaSpec(fsSpec *flowcontrol.FlowSchemaSpec) string {
|
|||||||
// BufferFlowSchemaSpec writes a golang source expression for the
|
// BufferFlowSchemaSpec writes a golang source expression for the
|
||||||
// given value to the given buffer
|
// given value to the given buffer
|
||||||
func BufferFlowSchemaSpec(buf *bytes.Buffer, fsSpec *flowcontrol.FlowSchemaSpec) {
|
func BufferFlowSchemaSpec(buf *bytes.Buffer, fsSpec *flowcontrol.FlowSchemaSpec) {
|
||||||
buf.WriteString(fmt.Sprintf("flowcontrolv1beta1.FlowSchemaSpec{PriorityLevelConfiguration: %#+v, MatchingPrecedence: %d, DistinguisherMethod: ",
|
buf.WriteString(fmt.Sprintf("flowcontrolv1beta3.FlowSchemaSpec{PriorityLevelConfiguration: %#+v, MatchingPrecedence: %d, DistinguisherMethod: ",
|
||||||
fsSpec.PriorityLevelConfiguration,
|
fsSpec.PriorityLevelConfiguration,
|
||||||
fsSpec.MatchingPrecedence))
|
fsSpec.MatchingPrecedence))
|
||||||
if fsSpec.DistinguisherMethod == nil {
|
if fsSpec.DistinguisherMethod == nil {
|
||||||
@ -166,7 +166,7 @@ func BufferFlowSchemaSpec(buf *bytes.Buffer, fsSpec *flowcontrol.FlowSchemaSpec)
|
|||||||
|
|
||||||
// FmtPolicyRulesWithSubjects produces a golang source expression of the value.
|
// FmtPolicyRulesWithSubjects produces a golang source expression of the value.
|
||||||
func FmtPolicyRulesWithSubjects(rule flowcontrol.PolicyRulesWithSubjects) string {
|
func FmtPolicyRulesWithSubjects(rule flowcontrol.PolicyRulesWithSubjects) string {
|
||||||
return "flowcontrolv1beta1.PolicyRulesWithSubjects" + FmtPolicyRulesWithSubjectsSlim(rule)
|
return "flowcontrolv1beta3.PolicyRulesWithSubjects" + FmtPolicyRulesWithSubjectsSlim(rule)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FmtPolicyRulesWithSubjectsSlim produces a golang source expression
|
// FmtPolicyRulesWithSubjectsSlim produces a golang source expression
|
||||||
@ -182,7 +182,7 @@ func FmtPolicyRulesWithSubjectsSlim(rule flowcontrol.PolicyRulesWithSubjects) st
|
|||||||
// expression for the given value to the given buffer but excludes the
|
// expression for the given value to the given buffer but excludes the
|
||||||
// leading type name
|
// leading type name
|
||||||
func BufferFmtPolicyRulesWithSubjectsSlim(buf *bytes.Buffer, rule flowcontrol.PolicyRulesWithSubjects) {
|
func BufferFmtPolicyRulesWithSubjectsSlim(buf *bytes.Buffer, rule flowcontrol.PolicyRulesWithSubjects) {
|
||||||
buf.WriteString("{Subjects: []flowcontrolv1beta1.Subject{")
|
buf.WriteString("{Subjects: []flowcontrolv1beta3.Subject{")
|
||||||
for jdx, subj := range rule.Subjects {
|
for jdx, subj := range rule.Subjects {
|
||||||
if jdx > 0 {
|
if jdx > 0 {
|
||||||
buf.WriteString(", ")
|
buf.WriteString(", ")
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
flowcontrol "k8s.io/api/flowcontrol/v1beta2"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||||
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/v1beta2"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||||
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/v1beta2"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||||
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/v1beta2"
|
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||||
"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"
|
||||||
|
Loading…
Reference in New Issue
Block a user