mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
apiserver: apf controller, bootstrap, tests should use flowcontrol v1 API
This commit is contained in:
parent
25aebca8d5
commit
17bda3c3e0
@ -17,7 +17,7 @@ limitations under the License.
|
||||
package internalbootstrap
|
||||
|
||||
import (
|
||||
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrolv1 "k8s.io/api/flowcontrol/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
|
||||
"k8s.io/kubernetes/pkg/apis/flowcontrol"
|
||||
@ -46,7 +46,7 @@ func NewAPFScheme() *runtime.Scheme {
|
||||
return scheme
|
||||
}
|
||||
|
||||
func internalizeFSes(exts []*flowcontrolv1beta3.FlowSchema) map[string]*flowcontrol.FlowSchema {
|
||||
func internalizeFSes(exts []*flowcontrolv1.FlowSchema) map[string]*flowcontrol.FlowSchema {
|
||||
ans := make(map[string]*flowcontrol.FlowSchema, len(exts))
|
||||
scheme := NewAPFScheme()
|
||||
for _, ext := range exts {
|
||||
@ -59,7 +59,7 @@ func internalizeFSes(exts []*flowcontrolv1beta3.FlowSchema) map[string]*flowcont
|
||||
return ans
|
||||
}
|
||||
|
||||
func internalizePLs(exts []*flowcontrolv1beta3.PriorityLevelConfiguration) map[string]*flowcontrol.PriorityLevelConfiguration {
|
||||
func internalizePLs(exts []*flowcontrolv1.PriorityLevelConfiguration) map[string]*flowcontrol.PriorityLevelConfiguration {
|
||||
ans := make(map[string]*flowcontrol.PriorityLevelConfiguration, len(exts))
|
||||
scheme := NewAPFScheme()
|
||||
for _, ext := range exts {
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1"
|
||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||
"k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
|
||||
)
|
||||
|
@ -17,25 +17,25 @@ limitations under the License.
|
||||
package ensurer
|
||||
|
||||
import (
|
||||
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrolv1 "k8s.io/api/flowcontrol/v1"
|
||||
"k8s.io/apimachinery/pkg/api/equality"
|
||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
|
||||
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta3"
|
||||
flowcontrolapisv1beta3 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta3"
|
||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1"
|
||||
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1"
|
||||
flowcontrolapisv1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1"
|
||||
)
|
||||
|
||||
func NewFlowSchemaOps(client flowcontrolclient.FlowSchemaInterface, cache flowcontrollisters.FlowSchemaLister) ObjectOps[*flowcontrolv1beta3.FlowSchema] {
|
||||
return NewObjectOps[*flowcontrolv1beta3.FlowSchema](client, cache, (*flowcontrolv1beta3.FlowSchema).DeepCopy, flowSchemaReplaceSpec, flowSchemaSpecEqual)
|
||||
func NewFlowSchemaOps(client flowcontrolclient.FlowSchemaInterface, cache flowcontrollisters.FlowSchemaLister) ObjectOps[*flowcontrolv1.FlowSchema] {
|
||||
return NewObjectOps[*flowcontrolv1.FlowSchema](client, cache, (*flowcontrolv1.FlowSchema).DeepCopy, flowSchemaReplaceSpec, flowSchemaSpecEqual)
|
||||
}
|
||||
|
||||
func flowSchemaReplaceSpec(into, from *flowcontrolv1beta3.FlowSchema) *flowcontrolv1beta3.FlowSchema {
|
||||
func flowSchemaReplaceSpec(into, from *flowcontrolv1.FlowSchema) *flowcontrolv1.FlowSchema {
|
||||
copy := into.DeepCopy()
|
||||
copy.Spec = *from.Spec.DeepCopy()
|
||||
return copy
|
||||
}
|
||||
|
||||
func flowSchemaSpecEqual(expected, actual *flowcontrolv1beta3.FlowSchema) bool {
|
||||
func flowSchemaSpecEqual(expected, actual *flowcontrolv1.FlowSchema) bool {
|
||||
copiedExpectedSpec := expected.Spec.DeepCopy()
|
||||
flowcontrolapisv1beta3.SetDefaults_FlowSchemaSpec(copiedExpectedSpec)
|
||||
flowcontrolapisv1.SetDefaults_FlowSchemaSpec(copiedExpectedSpec)
|
||||
return equality.Semantic.DeepEqual(copiedExpectedSpec, &actual.Spec)
|
||||
}
|
||||
|
@ -21,15 +21,15 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrolv1 "k8s.io/api/flowcontrol/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
|
||||
"k8s.io/client-go/kubernetes/fake"
|
||||
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta3"
|
||||
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1"
|
||||
toolscache "k8s.io/client-go/tools/cache"
|
||||
"k8s.io/klog/v2"
|
||||
flowcontrolapisv1beta3 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta3"
|
||||
flowcontrolapisv1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -42,29 +42,29 @@ func init() {
|
||||
func TestEnsureFlowSchema(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
strategy func() EnsureStrategy[*flowcontrolv1beta3.FlowSchema]
|
||||
current *flowcontrolv1beta3.FlowSchema
|
||||
bootstrap *flowcontrolv1beta3.FlowSchema
|
||||
expected *flowcontrolv1beta3.FlowSchema
|
||||
strategy func() EnsureStrategy[*flowcontrolv1.FlowSchema]
|
||||
current *flowcontrolv1.FlowSchema
|
||||
bootstrap *flowcontrolv1.FlowSchema
|
||||
expected *flowcontrolv1.FlowSchema
|
||||
}{
|
||||
// for suggested configurations
|
||||
{
|
||||
name: "suggested flow schema does not exist - the object should always be re-created",
|
||||
strategy: NewSuggestedEnsureStrategy[*flowcontrolv1beta3.FlowSchema],
|
||||
strategy: NewSuggestedEnsureStrategy[*flowcontrolv1.FlowSchema],
|
||||
bootstrap: newFlowSchema("fs1", "pl1", 100).Object(),
|
||||
current: nil,
|
||||
expected: newFlowSchema("fs1", "pl1", 100).Object(),
|
||||
},
|
||||
{
|
||||
name: "suggested flow schema exists, auto update is enabled, spec does not match - current object should be updated",
|
||||
strategy: NewSuggestedEnsureStrategy[*flowcontrolv1beta3.FlowSchema],
|
||||
strategy: NewSuggestedEnsureStrategy[*flowcontrolv1.FlowSchema],
|
||||
bootstrap: newFlowSchema("fs1", "pl1", 100).Object(),
|
||||
current: newFlowSchema("fs1", "pl1", 200).WithAutoUpdateAnnotation("true").Object(),
|
||||
expected: newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
||||
},
|
||||
{
|
||||
name: "suggested flow schema exists, auto update is disabled, spec does not match - current object should not be updated",
|
||||
strategy: NewSuggestedEnsureStrategy[*flowcontrolv1beta3.FlowSchema],
|
||||
strategy: NewSuggestedEnsureStrategy[*flowcontrolv1.FlowSchema],
|
||||
bootstrap: newFlowSchema("fs1", "pl1", 100).Object(),
|
||||
current: newFlowSchema("fs1", "pl1", 200).WithAutoUpdateAnnotation("false").Object(),
|
||||
expected: newFlowSchema("fs1", "pl1", 200).WithAutoUpdateAnnotation("false").Object(),
|
||||
@ -73,21 +73,21 @@ func TestEnsureFlowSchema(t *testing.T) {
|
||||
// for mandatory configurations
|
||||
{
|
||||
name: "mandatory flow schema does not exist - new object should be created",
|
||||
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1beta3.FlowSchema],
|
||||
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1.FlowSchema],
|
||||
bootstrap: newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
||||
current: nil,
|
||||
expected: newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
||||
},
|
||||
{
|
||||
name: "mandatory flow schema exists, annotation is missing - annotation should be added",
|
||||
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1beta3.FlowSchema],
|
||||
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1.FlowSchema],
|
||||
bootstrap: newFlowSchema("fs1", "pl1", 100).Object(),
|
||||
current: newFlowSchema("fs1", "pl1", 100).Object(),
|
||||
expected: newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
||||
},
|
||||
{
|
||||
name: "mandatory flow schema exists, auto update is disabled, spec does not match - current object should be updated",
|
||||
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1beta3.FlowSchema],
|
||||
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1.FlowSchema],
|
||||
bootstrap: newFlowSchema("fs1", "pl1", 100).Object(),
|
||||
current: newFlowSchema("fs1", "pl1", 200).WithAutoUpdateAnnotation("false").Object(),
|
||||
expected: newFlowSchema("fs1", "pl1", 100).WithAutoUpdateAnnotation("true").Object(),
|
||||
@ -96,7 +96,7 @@ func TestEnsureFlowSchema(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
client := fake.NewSimpleClientset().FlowcontrolV1beta3().FlowSchemas()
|
||||
client := fake.NewSimpleClientset().FlowcontrolV1().FlowSchemas()
|
||||
indexer := toolscache.NewIndexer(toolscache.MetaNamespaceKeyFunc, toolscache.Indexers{})
|
||||
if test.current != nil {
|
||||
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
|
||||
@ -104,7 +104,7 @@ func TestEnsureFlowSchema(t *testing.T) {
|
||||
}
|
||||
|
||||
ops := NewFlowSchemaOps(client, flowcontrollisters.NewFlowSchemaLister(indexer))
|
||||
boots := []*flowcontrolv1beta3.FlowSchema{test.bootstrap}
|
||||
boots := []*flowcontrolv1.FlowSchema{test.bootstrap}
|
||||
strategy := test.strategy()
|
||||
err := EnsureConfigurations(context.Background(), ops, boots, strategy)
|
||||
if err != nil {
|
||||
@ -131,9 +131,9 @@ func TestEnsureFlowSchema(t *testing.T) {
|
||||
func TestSuggestedFSEnsureStrategy_ShouldUpdate(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
current *flowcontrolv1beta3.FlowSchema
|
||||
bootstrap *flowcontrolv1beta3.FlowSchema
|
||||
newObjectExpected *flowcontrolv1beta3.FlowSchema
|
||||
current *flowcontrolv1.FlowSchema
|
||||
bootstrap *flowcontrolv1.FlowSchema
|
||||
newObjectExpected *flowcontrolv1.FlowSchema
|
||||
}{
|
||||
{
|
||||
name: "auto update is enabled, first generation, spec does not match - spec update expected",
|
||||
@ -212,7 +212,7 @@ func TestSuggestedFSEnsureStrategy_ShouldUpdate(t *testing.T) {
|
||||
ops := NewFlowSchemaOps(nil, nil)
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
strategy := NewSuggestedEnsureStrategy[*flowcontrolv1beta3.FlowSchema]()
|
||||
strategy := NewSuggestedEnsureStrategy[*flowcontrolv1.FlowSchema]()
|
||||
updatableGot, updateGot, err := strategy.ReviseIfNeeded(ops, test.current, test.bootstrap)
|
||||
if err != nil {
|
||||
t.Errorf("Expected no error, but got: %v", err)
|
||||
@ -238,23 +238,23 @@ func TestSuggestedFSEnsureStrategy_ShouldUpdate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFlowSchemaSpecChanged(t *testing.T) {
|
||||
fs1 := &flowcontrolv1beta3.FlowSchema{
|
||||
Spec: flowcontrolv1beta3.FlowSchemaSpec{},
|
||||
fs1 := &flowcontrolv1.FlowSchema{
|
||||
Spec: flowcontrolv1.FlowSchemaSpec{},
|
||||
}
|
||||
fs2 := &flowcontrolv1beta3.FlowSchema{
|
||||
Spec: flowcontrolv1beta3.FlowSchemaSpec{
|
||||
fs2 := &flowcontrolv1.FlowSchema{
|
||||
Spec: flowcontrolv1.FlowSchemaSpec{
|
||||
MatchingPrecedence: 1,
|
||||
},
|
||||
}
|
||||
fs1Defaulted := &flowcontrolv1beta3.FlowSchema{
|
||||
Spec: flowcontrolv1beta3.FlowSchemaSpec{
|
||||
MatchingPrecedence: flowcontrolapisv1beta3.FlowSchemaDefaultMatchingPrecedence,
|
||||
fs1Defaulted := &flowcontrolv1.FlowSchema{
|
||||
Spec: flowcontrolv1.FlowSchemaSpec{
|
||||
MatchingPrecedence: flowcontrolapisv1.FlowSchemaDefaultMatchingPrecedence,
|
||||
},
|
||||
}
|
||||
testCases := []struct {
|
||||
name string
|
||||
expected *flowcontrolv1beta3.FlowSchema
|
||||
actual *flowcontrolv1beta3.FlowSchema
|
||||
expected *flowcontrolv1.FlowSchema
|
||||
actual *flowcontrolv1.FlowSchema
|
||||
specChanged bool
|
||||
}{
|
||||
{
|
||||
@ -287,7 +287,7 @@ func TestFlowSchemaSpecChanged(t *testing.T) {
|
||||
func TestRemoveFlowSchema(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
current *flowcontrolv1beta3.FlowSchema
|
||||
current *flowcontrolv1.FlowSchema
|
||||
bootstrapName string
|
||||
removeExpected bool
|
||||
}{
|
||||
@ -336,7 +336,7 @@ func TestRemoveFlowSchema(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
client := fake.NewSimpleClientset().FlowcontrolV1beta3().FlowSchemas()
|
||||
client := fake.NewSimpleClientset().FlowcontrolV1().FlowSchemas()
|
||||
indexer := toolscache.NewIndexer(toolscache.MetaNamespaceKeyFunc, toolscache.Indexers{})
|
||||
if test.current != nil {
|
||||
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
|
||||
@ -344,7 +344,7 @@ func TestRemoveFlowSchema(t *testing.T) {
|
||||
}
|
||||
bootFS := newFlowSchema(test.bootstrapName, "pl", 100).Object()
|
||||
ops := NewFlowSchemaOps(client, flowcontrollisters.NewFlowSchemaLister(indexer))
|
||||
boots := []*flowcontrolv1beta3.FlowSchema{bootFS}
|
||||
boots := []*flowcontrolv1.FlowSchema{bootFS}
|
||||
err := RemoveUnwantedObjects(context.Background(), ops, boots)
|
||||
|
||||
if err != nil {
|
||||
@ -370,17 +370,17 @@ func TestRemoveFlowSchema(t *testing.T) {
|
||||
}
|
||||
|
||||
type fsBuilder struct {
|
||||
object *flowcontrolv1beta3.FlowSchema
|
||||
object *flowcontrolv1.FlowSchema
|
||||
}
|
||||
|
||||
func newFlowSchema(name, plName string, matchingPrecedence int32) *fsBuilder {
|
||||
return &fsBuilder{
|
||||
object: &flowcontrolv1beta3.FlowSchema{
|
||||
object: &flowcontrolv1.FlowSchema{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
},
|
||||
Spec: flowcontrolv1beta3.FlowSchemaSpec{
|
||||
PriorityLevelConfiguration: flowcontrolv1beta3.PriorityLevelConfigurationReference{
|
||||
Spec: flowcontrolv1.FlowSchemaSpec{
|
||||
PriorityLevelConfiguration: flowcontrolv1.PriorityLevelConfigurationReference{
|
||||
Name: plName,
|
||||
},
|
||||
MatchingPrecedence: matchingPrecedence,
|
||||
@ -389,7 +389,7 @@ func newFlowSchema(name, plName string, matchingPrecedence int32) *fsBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
func (b *fsBuilder) Object() *flowcontrolv1beta3.FlowSchema {
|
||||
func (b *fsBuilder) Object() *flowcontrolv1.FlowSchema {
|
||||
return b.object
|
||||
}
|
||||
|
||||
@ -408,5 +408,5 @@ func setAnnotation(accessor metav1.Object, value string) {
|
||||
accessor.SetAnnotations(map[string]string{})
|
||||
}
|
||||
|
||||
accessor.GetAnnotations()[flowcontrolv1beta3.AutoUpdateAnnotationKey] = value
|
||||
accessor.GetAnnotations()[flowcontrolv1.AutoUpdateAnnotationKey] = value
|
||||
}
|
||||
|
@ -17,28 +17,28 @@ limitations under the License.
|
||||
package ensurer
|
||||
|
||||
import (
|
||||
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrolv1 "k8s.io/api/flowcontrol/v1"
|
||||
"k8s.io/apimachinery/pkg/api/equality"
|
||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
|
||||
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta3"
|
||||
flowcontrolapisv1beta3 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta3"
|
||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1"
|
||||
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1"
|
||||
flowcontrolapisv1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1"
|
||||
)
|
||||
|
||||
func NewPriorityLevelConfigurationOps(client flowcontrolclient.PriorityLevelConfigurationInterface, lister flowcontrollisters.PriorityLevelConfigurationLister) ObjectOps[*flowcontrolv1beta3.PriorityLevelConfiguration] {
|
||||
return NewObjectOps[*flowcontrolv1beta3.PriorityLevelConfiguration](client, lister, (*flowcontrolv1beta3.PriorityLevelConfiguration).DeepCopy,
|
||||
func NewPriorityLevelConfigurationOps(client flowcontrolclient.PriorityLevelConfigurationInterface, lister flowcontrollisters.PriorityLevelConfigurationLister) ObjectOps[*flowcontrolv1.PriorityLevelConfiguration] {
|
||||
return NewObjectOps[*flowcontrolv1.PriorityLevelConfiguration](client, lister, (*flowcontrolv1.PriorityLevelConfiguration).DeepCopy,
|
||||
plcReplaceSpec, plcSpecEqualish)
|
||||
}
|
||||
|
||||
func plcReplaceSpec(into, from *flowcontrolv1beta3.PriorityLevelConfiguration) *flowcontrolv1beta3.PriorityLevelConfiguration {
|
||||
func plcReplaceSpec(into, from *flowcontrolv1.PriorityLevelConfiguration) *flowcontrolv1.PriorityLevelConfiguration {
|
||||
copy := into.DeepCopy()
|
||||
copy.Spec = *from.Spec.DeepCopy()
|
||||
return copy
|
||||
}
|
||||
|
||||
func plcSpecEqualish(expected, actual *flowcontrolv1beta3.PriorityLevelConfiguration) bool {
|
||||
func plcSpecEqualish(expected, actual *flowcontrolv1.PriorityLevelConfiguration) bool {
|
||||
copiedExpected := expected.DeepCopy()
|
||||
flowcontrolapisv1beta3.SetObjectDefaults_PriorityLevelConfiguration(copiedExpected)
|
||||
if expected.Name == flowcontrolv1beta3.PriorityLevelConfigurationNameExempt {
|
||||
flowcontrolapisv1.SetObjectDefaults_PriorityLevelConfiguration(copiedExpected)
|
||||
if expected.Name == flowcontrolv1.PriorityLevelConfigurationNameExempt {
|
||||
if actual.Spec.Exempt == nil {
|
||||
return false
|
||||
}
|
||||
|
@ -21,23 +21,23 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrolv1 "k8s.io/api/flowcontrol/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
|
||||
"k8s.io/client-go/kubernetes/fake"
|
||||
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta3"
|
||||
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1"
|
||||
toolscache "k8s.io/client-go/tools/cache"
|
||||
flowcontrolapisv1beta3 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1beta3"
|
||||
flowcontrolapisv1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1"
|
||||
"k8s.io/utils/pointer"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
)
|
||||
|
||||
func TestEnsurePriorityLevel(t *testing.T) {
|
||||
validExemptPL := func() *flowcontrolv1beta3.PriorityLevelConfiguration {
|
||||
validExemptPL := func() *flowcontrolv1.PriorityLevelConfiguration {
|
||||
copy := bootstrap.MandatoryPriorityLevelConfigurationExempt.DeepCopy()
|
||||
copy.Annotations[flowcontrolv1beta3.AutoUpdateAnnotationKey] = "true"
|
||||
copy.Annotations[flowcontrolv1.AutoUpdateAnnotationKey] = "true"
|
||||
copy.Spec.Exempt.NominalConcurrencyShares = pointer.Int32(10)
|
||||
copy.Spec.Exempt.LendablePercent = pointer.Int32(50)
|
||||
return copy
|
||||
@ -45,29 +45,29 @@ func TestEnsurePriorityLevel(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
strategy func() EnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration]
|
||||
current *flowcontrolv1beta3.PriorityLevelConfiguration
|
||||
bootstrap *flowcontrolv1beta3.PriorityLevelConfiguration
|
||||
expected *flowcontrolv1beta3.PriorityLevelConfiguration
|
||||
strategy func() EnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration]
|
||||
current *flowcontrolv1.PriorityLevelConfiguration
|
||||
bootstrap *flowcontrolv1.PriorityLevelConfiguration
|
||||
expected *flowcontrolv1.PriorityLevelConfiguration
|
||||
}{
|
||||
// for suggested configurations
|
||||
{
|
||||
name: "suggested priority level configuration does not exist - the object should always be re-created",
|
||||
strategy: NewSuggestedEnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration],
|
||||
strategy: NewSuggestedEnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration],
|
||||
bootstrap: newPLConfiguration("pl1").WithLimited(10).Object(),
|
||||
current: nil,
|
||||
expected: newPLConfiguration("pl1").WithLimited(10).Object(),
|
||||
},
|
||||
{
|
||||
name: "suggested priority level configuration exists, auto update is enabled, spec does not match - current object should be updated",
|
||||
strategy: NewSuggestedEnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration],
|
||||
strategy: NewSuggestedEnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration],
|
||||
bootstrap: newPLConfiguration("pl1").WithLimited(20).Object(),
|
||||
current: newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").WithLimited(10).Object(),
|
||||
expected: newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").WithLimited(20).Object(),
|
||||
},
|
||||
{
|
||||
name: "suggested priority level configuration exists, auto update is disabled, spec does not match - current object should not be updated",
|
||||
strategy: NewSuggestedEnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration],
|
||||
strategy: NewSuggestedEnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration],
|
||||
bootstrap: newPLConfiguration("pl1").WithLimited(20).Object(),
|
||||
current: newPLConfiguration("pl1").WithAutoUpdateAnnotation("false").WithLimited(10).Object(),
|
||||
expected: newPLConfiguration("pl1").WithAutoUpdateAnnotation("false").WithLimited(10).Object(),
|
||||
@ -76,29 +76,29 @@ func TestEnsurePriorityLevel(t *testing.T) {
|
||||
// for mandatory configurations
|
||||
{
|
||||
name: "mandatory priority level configuration does not exist - new object should be created",
|
||||
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration],
|
||||
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration],
|
||||
bootstrap: newPLConfiguration("pl1").WithLimited(10).WithAutoUpdateAnnotation("true").Object(),
|
||||
current: nil,
|
||||
expected: newPLConfiguration("pl1").WithLimited(10).WithAutoUpdateAnnotation("true").Object(),
|
||||
},
|
||||
{
|
||||
name: "mandatory priority level configuration exists, annotation is missing - annotation is added",
|
||||
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration],
|
||||
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration],
|
||||
bootstrap: newPLConfiguration("pl1").WithLimited(20).Object(),
|
||||
current: newPLConfiguration("pl1").WithLimited(20).Object(),
|
||||
expected: newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").WithLimited(20).Object(),
|
||||
},
|
||||
{
|
||||
name: "mandatory priority level configuration exists, auto update is disabled, spec does not match - current object should be updated",
|
||||
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration],
|
||||
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration],
|
||||
bootstrap: newPLConfiguration("pl1").WithLimited(20).Object(),
|
||||
current: newPLConfiguration("pl1").WithAutoUpdateAnnotation("false").WithLimited(10).Object(),
|
||||
expected: newPLConfiguration("pl1").WithAutoUpdateAnnotation("true").WithLimited(20).Object(),
|
||||
},
|
||||
{
|
||||
name: "admin changes the Exempt field of the exempt priority level configuration",
|
||||
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration],
|
||||
bootstrap: func() *flowcontrolv1beta3.PriorityLevelConfiguration {
|
||||
strategy: NewMandatoryEnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration],
|
||||
bootstrap: func() *flowcontrolv1.PriorityLevelConfiguration {
|
||||
return bootstrap.MandatoryPriorityLevelConfigurationExempt
|
||||
}(),
|
||||
current: validExemptPL,
|
||||
@ -108,7 +108,7 @@ func TestEnsurePriorityLevel(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
client := fake.NewSimpleClientset().FlowcontrolV1beta3().PriorityLevelConfigurations()
|
||||
client := fake.NewSimpleClientset().FlowcontrolV1().PriorityLevelConfigurations()
|
||||
indexer := toolscache.NewIndexer(toolscache.MetaNamespaceKeyFunc, toolscache.Indexers{})
|
||||
if test.current != nil {
|
||||
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
|
||||
@ -116,7 +116,7 @@ func TestEnsurePriorityLevel(t *testing.T) {
|
||||
}
|
||||
|
||||
ops := NewPriorityLevelConfigurationOps(client, flowcontrollisters.NewPriorityLevelConfigurationLister(indexer))
|
||||
boots := []*flowcontrolv1beta3.PriorityLevelConfiguration{test.bootstrap}
|
||||
boots := []*flowcontrolv1.PriorityLevelConfiguration{test.bootstrap}
|
||||
strategy := test.strategy()
|
||||
|
||||
err := EnsureConfigurations(context.Background(), ops, boots, strategy)
|
||||
@ -144,9 +144,9 @@ func TestEnsurePriorityLevel(t *testing.T) {
|
||||
func TestSuggestedPLEnsureStrategy_ShouldUpdate(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
current *flowcontrolv1beta3.PriorityLevelConfiguration
|
||||
bootstrap *flowcontrolv1beta3.PriorityLevelConfiguration
|
||||
newObjectExpected *flowcontrolv1beta3.PriorityLevelConfiguration
|
||||
current *flowcontrolv1.PriorityLevelConfiguration
|
||||
bootstrap *flowcontrolv1.PriorityLevelConfiguration
|
||||
newObjectExpected *flowcontrolv1.PriorityLevelConfiguration
|
||||
}{
|
||||
{
|
||||
name: "auto update is enabled, first generation, spec does not match - spec update expected",
|
||||
@ -225,7 +225,7 @@ func TestSuggestedPLEnsureStrategy_ShouldUpdate(t *testing.T) {
|
||||
ops := NewPriorityLevelConfigurationOps(nil, nil)
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
strategy := NewSuggestedEnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration]()
|
||||
strategy := NewSuggestedEnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration]()
|
||||
updatableGot, updateGot, err := strategy.ReviseIfNeeded(ops, test.current, test.bootstrap)
|
||||
if err != nil {
|
||||
t.Errorf("Expected no error, but got: %v", err)
|
||||
@ -251,75 +251,75 @@ func TestSuggestedPLEnsureStrategy_ShouldUpdate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPriorityLevelSpecChanged(t *testing.T) {
|
||||
pl1 := &flowcontrolv1beta3.PriorityLevelConfiguration{
|
||||
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{
|
||||
Type: flowcontrolv1beta3.PriorityLevelEnablementLimited,
|
||||
Limited: &flowcontrolv1beta3.LimitedPriorityLevelConfiguration{
|
||||
LimitResponse: flowcontrolv1beta3.LimitResponse{
|
||||
Type: flowcontrolv1beta3.LimitResponseTypeReject,
|
||||
pl1 := &flowcontrolv1.PriorityLevelConfiguration{
|
||||
Spec: flowcontrolv1.PriorityLevelConfigurationSpec{
|
||||
Type: flowcontrolv1.PriorityLevelEnablementLimited,
|
||||
Limited: &flowcontrolv1.LimitedPriorityLevelConfiguration{
|
||||
LimitResponse: flowcontrolv1.LimitResponse{
|
||||
Type: flowcontrolv1.LimitResponseTypeReject,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
pl2 := &flowcontrolv1beta3.PriorityLevelConfiguration{
|
||||
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{
|
||||
Type: flowcontrolv1beta3.PriorityLevelEnablementLimited,
|
||||
Limited: &flowcontrolv1beta3.LimitedPriorityLevelConfiguration{
|
||||
pl2 := &flowcontrolv1.PriorityLevelConfiguration{
|
||||
Spec: flowcontrolv1.PriorityLevelConfigurationSpec{
|
||||
Type: flowcontrolv1.PriorityLevelEnablementLimited,
|
||||
Limited: &flowcontrolv1.LimitedPriorityLevelConfiguration{
|
||||
NominalConcurrencyShares: 1,
|
||||
},
|
||||
},
|
||||
}
|
||||
pl1Defaulted := &flowcontrolv1beta3.PriorityLevelConfiguration{
|
||||
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{
|
||||
Type: flowcontrolv1beta3.PriorityLevelEnablementLimited,
|
||||
Limited: &flowcontrolv1beta3.LimitedPriorityLevelConfiguration{
|
||||
NominalConcurrencyShares: flowcontrolapisv1beta3.PriorityLevelConfigurationDefaultNominalConcurrencyShares,
|
||||
pl1Defaulted := &flowcontrolv1.PriorityLevelConfiguration{
|
||||
Spec: flowcontrolv1.PriorityLevelConfigurationSpec{
|
||||
Type: flowcontrolv1.PriorityLevelEnablementLimited,
|
||||
Limited: &flowcontrolv1.LimitedPriorityLevelConfiguration{
|
||||
NominalConcurrencyShares: flowcontrolapisv1.PriorityLevelConfigurationDefaultNominalConcurrencyShares,
|
||||
LendablePercent: pointer.Int32(0),
|
||||
LimitResponse: flowcontrolv1beta3.LimitResponse{
|
||||
Type: flowcontrolv1beta3.LimitResponseTypeReject,
|
||||
LimitResponse: flowcontrolv1.LimitResponse{
|
||||
Type: flowcontrolv1.LimitResponseTypeReject,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
ple1 := &flowcontrolv1beta3.PriorityLevelConfiguration{
|
||||
ple1 := &flowcontrolv1.PriorityLevelConfiguration{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "exempt"},
|
||||
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{
|
||||
Type: flowcontrolv1beta3.PriorityLevelEnablementExempt,
|
||||
Exempt: &flowcontrolv1beta3.ExemptPriorityLevelConfiguration{
|
||||
Spec: flowcontrolv1.PriorityLevelConfigurationSpec{
|
||||
Type: flowcontrolv1.PriorityLevelEnablementExempt,
|
||||
Exempt: &flowcontrolv1.ExemptPriorityLevelConfiguration{
|
||||
NominalConcurrencyShares: pointer.Int32(42),
|
||||
LendablePercent: pointer.Int32(33),
|
||||
},
|
||||
},
|
||||
}
|
||||
ple2 := &flowcontrolv1beta3.PriorityLevelConfiguration{
|
||||
ple2 := &flowcontrolv1.PriorityLevelConfiguration{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "exempt"},
|
||||
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{
|
||||
Type: flowcontrolv1beta3.PriorityLevelEnablementExempt,
|
||||
Exempt: &flowcontrolv1beta3.ExemptPriorityLevelConfiguration{
|
||||
Spec: flowcontrolv1.PriorityLevelConfigurationSpec{
|
||||
Type: flowcontrolv1.PriorityLevelEnablementExempt,
|
||||
Exempt: &flowcontrolv1.ExemptPriorityLevelConfiguration{
|
||||
NominalConcurrencyShares: pointer.Int32(24),
|
||||
LendablePercent: pointer.Int32(86),
|
||||
},
|
||||
},
|
||||
}
|
||||
pleWrong := &flowcontrolv1beta3.PriorityLevelConfiguration{
|
||||
pleWrong := &flowcontrolv1.PriorityLevelConfiguration{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "exempt"},
|
||||
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{
|
||||
Type: flowcontrolv1beta3.PriorityLevelEnablementLimited,
|
||||
Limited: &flowcontrolv1beta3.LimitedPriorityLevelConfiguration{
|
||||
Spec: flowcontrolv1.PriorityLevelConfigurationSpec{
|
||||
Type: flowcontrolv1.PriorityLevelEnablementLimited,
|
||||
Limited: &flowcontrolv1.LimitedPriorityLevelConfiguration{
|
||||
NominalConcurrencyShares: 1,
|
||||
},
|
||||
},
|
||||
}
|
||||
pleInvalid := &flowcontrolv1beta3.PriorityLevelConfiguration{
|
||||
pleInvalid := &flowcontrolv1.PriorityLevelConfiguration{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "exempt"},
|
||||
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{
|
||||
Spec: flowcontrolv1.PriorityLevelConfigurationSpec{
|
||||
Type: "widget",
|
||||
},
|
||||
}
|
||||
testCases := []struct {
|
||||
name string
|
||||
expected *flowcontrolv1beta3.PriorityLevelConfiguration
|
||||
actual *flowcontrolv1beta3.PriorityLevelConfiguration
|
||||
expected *flowcontrolv1.PriorityLevelConfiguration
|
||||
actual *flowcontrolv1.PriorityLevelConfiguration
|
||||
specChanged bool
|
||||
}{
|
||||
{
|
||||
@ -373,7 +373,7 @@ func TestPriorityLevelSpecChanged(t *testing.T) {
|
||||
func TestRemovePriorityLevelConfiguration(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
current *flowcontrolv1beta3.PriorityLevelConfiguration
|
||||
current *flowcontrolv1.PriorityLevelConfiguration
|
||||
bootstrapName string
|
||||
removeExpected bool
|
||||
}{
|
||||
@ -422,7 +422,7 @@ func TestRemovePriorityLevelConfiguration(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
client := fake.NewSimpleClientset().FlowcontrolV1beta3().PriorityLevelConfigurations()
|
||||
client := fake.NewSimpleClientset().FlowcontrolV1().PriorityLevelConfigurations()
|
||||
indexer := toolscache.NewIndexer(toolscache.MetaNamespaceKeyFunc, toolscache.Indexers{})
|
||||
if test.current != nil {
|
||||
client.Create(context.TODO(), test.current, metav1.CreateOptions{})
|
||||
@ -430,7 +430,7 @@ func TestRemovePriorityLevelConfiguration(t *testing.T) {
|
||||
}
|
||||
|
||||
boot := newPLConfiguration(test.bootstrapName).Object()
|
||||
boots := []*flowcontrolv1beta3.PriorityLevelConfiguration{boot}
|
||||
boots := []*flowcontrolv1.PriorityLevelConfiguration{boot}
|
||||
ops := NewPriorityLevelConfigurationOps(client, flowcontrollisters.NewPriorityLevelConfigurationLister(indexer))
|
||||
err := RemoveUnwantedObjects(context.Background(), ops, boots)
|
||||
if err != nil {
|
||||
@ -456,12 +456,12 @@ func TestRemovePriorityLevelConfiguration(t *testing.T) {
|
||||
}
|
||||
|
||||
type plBuilder struct {
|
||||
object *flowcontrolv1beta3.PriorityLevelConfiguration
|
||||
object *flowcontrolv1.PriorityLevelConfiguration
|
||||
}
|
||||
|
||||
func newPLConfiguration(name string) *plBuilder {
|
||||
return &plBuilder{
|
||||
object: &flowcontrolv1beta3.PriorityLevelConfiguration{
|
||||
object: &flowcontrolv1.PriorityLevelConfiguration{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
},
|
||||
@ -469,7 +469,7 @@ func newPLConfiguration(name string) *plBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
func (b *plBuilder) Object() *flowcontrolv1beta3.PriorityLevelConfiguration {
|
||||
func (b *plBuilder) Object() *flowcontrolv1.PriorityLevelConfiguration {
|
||||
return b.object
|
||||
}
|
||||
|
||||
@ -484,12 +484,12 @@ func (b *plBuilder) WithAutoUpdateAnnotation(value string) *plBuilder {
|
||||
}
|
||||
|
||||
func (b *plBuilder) WithLimited(nominalConcurrencyShares int32) *plBuilder {
|
||||
b.object.Spec.Type = flowcontrolv1beta3.PriorityLevelEnablementLimited
|
||||
b.object.Spec.Limited = &flowcontrolv1beta3.LimitedPriorityLevelConfiguration{
|
||||
b.object.Spec.Type = flowcontrolv1.PriorityLevelEnablementLimited
|
||||
b.object.Spec.Limited = &flowcontrolv1.LimitedPriorityLevelConfiguration{
|
||||
NominalConcurrencyShares: nominalConcurrencyShares,
|
||||
LendablePercent: pointer.Int32(0),
|
||||
LimitResponse: flowcontrolv1beta3.LimitResponse{
|
||||
Type: flowcontrolv1beta3.LimitResponseTypeReject,
|
||||
LimitResponse: flowcontrolv1.LimitResponse{
|
||||
Type: flowcontrolv1.LimitResponseTypeReject,
|
||||
},
|
||||
}
|
||||
return b
|
||||
@ -502,8 +502,8 @@ func (b *plBuilder) WithQueuing(queues, handSize, queueLengthLimit int32) *plBui
|
||||
return b
|
||||
}
|
||||
|
||||
limited.LimitResponse.Type = flowcontrolv1beta3.LimitResponseTypeQueue
|
||||
limited.LimitResponse.Queuing = &flowcontrolv1beta3.QueuingConfiguration{
|
||||
limited.LimitResponse.Type = flowcontrolv1.LimitResponseTypeQueue
|
||||
limited.LimitResponse.Queuing = &flowcontrolv1.QueuingConfiguration{
|
||||
Queues: queues,
|
||||
HandSize: handSize,
|
||||
QueueLengthLimit: queueLengthLimit,
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrolv1 "k8s.io/api/flowcontrol/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
@ -199,7 +199,7 @@ func (s *strategy[ObjectType]) ReviseIfNeeded(objectOps objectLocalOps[ObjectTyp
|
||||
// shouldUpdateSpec inspects the auto-update annotation key and generation field to determine
|
||||
// whether the config object should be auto-updated.
|
||||
func shouldUpdateSpec(accessor metav1.Object) bool {
|
||||
value, _ := accessor.GetAnnotations()[flowcontrolv1beta3.AutoUpdateAnnotationKey]
|
||||
value, _ := accessor.GetAnnotations()[flowcontrolv1.AutoUpdateAnnotationKey]
|
||||
if autoUpdate, err := strconv.ParseBool(value); err == nil {
|
||||
return autoUpdate
|
||||
}
|
||||
@ -219,7 +219,7 @@ func shouldUpdateSpec(accessor metav1.Object) bool {
|
||||
// shouldUpdateAnnotation determines whether the current value of the auto-update annotation
|
||||
// key matches the desired value.
|
||||
func shouldUpdateAnnotation(accessor metav1.Object, desired bool) bool {
|
||||
if value, ok := accessor.GetAnnotations()[flowcontrolv1beta3.AutoUpdateAnnotationKey]; ok {
|
||||
if value, ok := accessor.GetAnnotations()[flowcontrolv1.AutoUpdateAnnotationKey]; ok {
|
||||
if current, err := strconv.ParseBool(value); err == nil && current == desired {
|
||||
return false
|
||||
}
|
||||
@ -234,7 +234,7 @@ func setAutoUpdateAnnotation(accessor metav1.Object, autoUpdate bool) {
|
||||
accessor.SetAnnotations(map[string]string{})
|
||||
}
|
||||
|
||||
accessor.GetAnnotations()[flowcontrolv1beta3.AutoUpdateAnnotationKey] = strconv.FormatBool(autoUpdate)
|
||||
accessor.GetAnnotations()[flowcontrolv1.AutoUpdateAnnotationKey] = strconv.FormatBool(autoUpdate)
|
||||
}
|
||||
|
||||
// EnsureConfigurations applies the given maintenance strategy to the given objects.
|
||||
@ -321,21 +321,21 @@ func RemoveUnwantedObjects[ObjectType configurationObjectType](ctx context.Conte
|
||||
var value string
|
||||
var ok, autoUpdate bool
|
||||
var err error
|
||||
if value, ok = object.GetAnnotations()[flowcontrolv1beta3.AutoUpdateAnnotationKey]; !ok {
|
||||
if value, ok = object.GetAnnotations()[flowcontrolv1.AutoUpdateAnnotationKey]; !ok {
|
||||
// the configuration object does not have the annotation key,
|
||||
// it's probably a user defined configuration object,
|
||||
// so we can skip it.
|
||||
klog.V(5).InfoS("Skipping deletion of APF object with no "+flowcontrolv1beta3.AutoUpdateAnnotationKey+" annotation", "name", name)
|
||||
klog.V(5).InfoS("Skipping deletion of APF object with no "+flowcontrolv1.AutoUpdateAnnotationKey+" annotation", "name", name)
|
||||
continue
|
||||
}
|
||||
autoUpdate, err = strconv.ParseBool(value)
|
||||
if err != nil {
|
||||
// Log this because it is not an expected situation.
|
||||
klog.V(4).InfoS("Skipping deletion of APF object with malformed "+flowcontrolv1beta3.AutoUpdateAnnotationKey+" annotation", "name", name, "annotationValue", value, "parseError", err)
|
||||
klog.V(4).InfoS("Skipping deletion of APF object with malformed "+flowcontrolv1.AutoUpdateAnnotationKey+" annotation", "name", name, "annotationValue", value, "parseError", err)
|
||||
continue
|
||||
}
|
||||
if !autoUpdate {
|
||||
klog.V(5).InfoS("Skipping deletion of APF object with "+flowcontrolv1beta3.AutoUpdateAnnotationKey+"=false annotation", "name", name)
|
||||
klog.V(5).InfoS("Skipping deletion of APF object with "+flowcontrolv1.AutoUpdateAnnotationKey+"=false annotation", "name", name)
|
||||
continue
|
||||
}
|
||||
// TODO: expectedResourceVersion := object.GetResourceVersion()
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrolv1 "k8s.io/api/flowcontrol/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
flowcontrolbootstrap "k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
|
||||
@ -30,8 +30,8 @@ import (
|
||||
genericapiserver "k8s.io/apiserver/pkg/server"
|
||||
serverstorage "k8s.io/apiserver/pkg/server/storage"
|
||||
"k8s.io/client-go/informers"
|
||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
|
||||
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1beta3"
|
||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1"
|
||||
flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
@ -121,11 +121,11 @@ func (p RESTStorageProvider) GroupName() string {
|
||||
func (p RESTStorageProvider) PostStartHook() (string, genericapiserver.PostStartHookFunc, error) {
|
||||
bce := &bootstrapConfigurationEnsurer{
|
||||
informersSynced: []cache.InformerSynced{
|
||||
p.InformerFactory.Flowcontrol().V1beta3().PriorityLevelConfigurations().Informer().HasSynced,
|
||||
p.InformerFactory.Flowcontrol().V1beta3().FlowSchemas().Informer().HasSynced,
|
||||
p.InformerFactory.Flowcontrol().V1().PriorityLevelConfigurations().Informer().HasSynced,
|
||||
p.InformerFactory.Flowcontrol().V1().FlowSchemas().Informer().HasSynced,
|
||||
},
|
||||
fsLister: p.InformerFactory.Flowcontrol().V1beta3().FlowSchemas().Lister(),
|
||||
plcLister: p.InformerFactory.Flowcontrol().V1beta3().PriorityLevelConfigurations().Lister(),
|
||||
fsLister: p.InformerFactory.Flowcontrol().V1().FlowSchemas().Lister(),
|
||||
plcLister: p.InformerFactory.Flowcontrol().V1().PriorityLevelConfigurations().Lister(),
|
||||
}
|
||||
return PostStartHookName, bce.ensureAPFBootstrapConfiguration, nil
|
||||
}
|
||||
@ -190,7 +190,7 @@ func (bce *bootstrapConfigurationEnsurer) ensureAPFBootstrapConfiguration(hookCo
|
||||
return nil
|
||||
}
|
||||
|
||||
func ensure(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1beta3Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
|
||||
func ensure(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
|
||||
|
||||
if err := ensureSuggestedConfiguration(ctx, clientset, fsLister, plcLister); err != nil {
|
||||
// We should not attempt creation of mandatory objects if ensuring the suggested
|
||||
@ -210,27 +210,27 @@ func ensure(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1beta3I
|
||||
return nil
|
||||
}
|
||||
|
||||
func ensureSuggestedConfiguration(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1beta3Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
|
||||
func ensureSuggestedConfiguration(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
|
||||
plcOps := ensurer.NewPriorityLevelConfigurationOps(clientset.PriorityLevelConfigurations(), plcLister)
|
||||
if err := ensurer.EnsureConfigurations(ctx, plcOps, flowcontrolbootstrap.SuggestedPriorityLevelConfigurations, ensurer.NewSuggestedEnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration]()); err != nil {
|
||||
if err := ensurer.EnsureConfigurations(ctx, plcOps, flowcontrolbootstrap.SuggestedPriorityLevelConfigurations, ensurer.NewSuggestedEnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration]()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fsOps := ensurer.NewFlowSchemaOps(clientset.FlowSchemas(), fsLister)
|
||||
return ensurer.EnsureConfigurations(ctx, fsOps, flowcontrolbootstrap.SuggestedFlowSchemas, ensurer.NewSuggestedEnsureStrategy[*flowcontrolv1beta3.FlowSchema]())
|
||||
return ensurer.EnsureConfigurations(ctx, fsOps, flowcontrolbootstrap.SuggestedFlowSchemas, ensurer.NewSuggestedEnsureStrategy[*flowcontrolv1.FlowSchema]())
|
||||
}
|
||||
|
||||
func ensureMandatoryConfiguration(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1beta3Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
|
||||
func ensureMandatoryConfiguration(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
|
||||
plcOps := ensurer.NewPriorityLevelConfigurationOps(clientset.PriorityLevelConfigurations(), plcLister)
|
||||
if err := ensurer.EnsureConfigurations(ctx, plcOps, flowcontrolbootstrap.MandatoryPriorityLevelConfigurations, ensurer.NewMandatoryEnsureStrategy[*flowcontrolv1beta3.PriorityLevelConfiguration]()); err != nil {
|
||||
if err := ensurer.EnsureConfigurations(ctx, plcOps, flowcontrolbootstrap.MandatoryPriorityLevelConfigurations, ensurer.NewMandatoryEnsureStrategy[*flowcontrolv1.PriorityLevelConfiguration]()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fsOps := ensurer.NewFlowSchemaOps(clientset.FlowSchemas(), fsLister)
|
||||
return ensurer.EnsureConfigurations(ctx, fsOps, flowcontrolbootstrap.MandatoryFlowSchemas, ensurer.NewMandatoryEnsureStrategy[*flowcontrolv1beta3.FlowSchema]())
|
||||
return ensurer.EnsureConfigurations(ctx, fsOps, flowcontrolbootstrap.MandatoryFlowSchemas, ensurer.NewMandatoryEnsureStrategy[*flowcontrolv1.FlowSchema]())
|
||||
}
|
||||
|
||||
func removeDanglingBootstrapConfiguration(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1beta3Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
|
||||
func removeDanglingBootstrapConfiguration(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1Interface, fsLister flowcontrollisters.FlowSchemaLister, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
|
||||
if err := removeDanglingBootstrapFlowSchema(ctx, clientset, fsLister); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -238,13 +238,13 @@ func removeDanglingBootstrapConfiguration(ctx context.Context, clientset flowcon
|
||||
return removeDanglingBootstrapPriorityLevel(ctx, clientset, plcLister)
|
||||
}
|
||||
|
||||
func removeDanglingBootstrapFlowSchema(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1beta3Interface, fsLister flowcontrollisters.FlowSchemaLister) error {
|
||||
func removeDanglingBootstrapFlowSchema(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1Interface, fsLister flowcontrollisters.FlowSchemaLister) error {
|
||||
bootstrap := append(flowcontrolbootstrap.MandatoryFlowSchemas, flowcontrolbootstrap.SuggestedFlowSchemas...)
|
||||
fsOps := ensurer.NewFlowSchemaOps(clientset.FlowSchemas(), fsLister)
|
||||
return ensurer.RemoveUnwantedObjects(ctx, fsOps, bootstrap)
|
||||
}
|
||||
|
||||
func removeDanglingBootstrapPriorityLevel(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1beta3Interface, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
|
||||
func removeDanglingBootstrapPriorityLevel(ctx context.Context, clientset flowcontrolclient.FlowcontrolV1Interface, plcLister flowcontrollisters.PriorityLevelConfigurationLister) error {
|
||||
bootstrap := append(flowcontrolbootstrap.MandatoryPriorityLevelConfigurations, flowcontrolbootstrap.SuggestedPriorityLevelConfigurations...)
|
||||
plcOps := ensurer.NewPriorityLevelConfigurationOps(clientset.PriorityLevelConfigurations(), plcLister)
|
||||
return ensurer.RemoveUnwantedObjects(ctx, plcOps, bootstrap)
|
||||
|
@ -19,7 +19,7 @@ package bootstrap
|
||||
import (
|
||||
coordinationv1 "k8s.io/api/coordination/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apiserver/pkg/authentication/serviceaccount"
|
||||
"k8s.io/apiserver/pkg/authentication/user"
|
||||
|
@ -19,7 +19,7 @@ package bootstrap
|
||||
import (
|
||||
"testing"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1"
|
||||
)
|
||||
|
||||
func TestBootstrapPriorityLevelConfigurationWithBorrowing(t *testing.T) {
|
||||
|
@ -26,7 +26,7 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1"
|
||||
apitypes "k8s.io/apimachinery/pkg/types"
|
||||
epmetrics "k8s.io/apiserver/pkg/endpoints/metrics"
|
||||
apirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||
|
@ -29,7 +29,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
@ -1119,7 +1119,7 @@ func startAPFController(t *testing.T, stopCh <-chan struct{}, apfConfiguration [
|
||||
clientset := newClientset(t, apfConfiguration...)
|
||||
// this test does not rely on resync, so resync period is set to zero
|
||||
factory := informers.NewSharedInformerFactory(clientset, 0)
|
||||
controller := utilflowcontrol.New(factory, clientset.FlowcontrolV1beta3(), serverConcurrency)
|
||||
controller := utilflowcontrol.New(factory, clientset.FlowcontrolV1(), serverConcurrency)
|
||||
|
||||
factory.Start(stopCh)
|
||||
|
||||
|
@ -79,7 +79,7 @@ func (o *FeatureOptions) ApplyTo(c *server.Config, clientset kubernetes.Interfac
|
||||
}
|
||||
c.FlowControl = utilflowcontrol.New(
|
||||
informers,
|
||||
clientset.FlowcontrolV1beta3(),
|
||||
clientset.FlowcontrolV1(),
|
||||
c.MaxRequestsInFlight+c.MaxMutatingRequestsInFlight,
|
||||
)
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ package apihelpers
|
||||
import (
|
||||
"sort"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1"
|
||||
)
|
||||
|
||||
// SetFlowSchemaCondition sets conditions.
|
||||
|
@ -50,10 +50,10 @@ import (
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/utils/clock"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrolapplyconfiguration "k8s.io/client-go/applyconfigurations/flowcontrol/v1beta3"
|
||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
|
||||
flowcontrollister "k8s.io/client-go/listers/flowcontrol/v1beta3"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1"
|
||||
flowcontrolapplyconfiguration "k8s.io/client-go/applyconfigurations/flowcontrol/v1"
|
||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1"
|
||||
flowcontrollister "k8s.io/client-go/listers/flowcontrol/v1"
|
||||
)
|
||||
|
||||
const timeFmt = "2006-01-02T15:04:05.999"
|
||||
@ -143,7 +143,7 @@ type configController struct {
|
||||
fsLister flowcontrollister.FlowSchemaLister
|
||||
fsInformerSynced cache.InformerSynced
|
||||
|
||||
flowcontrolClient flowcontrolclient.FlowcontrolV1beta3Interface
|
||||
flowcontrolClient flowcontrolclient.FlowcontrolV1Interface
|
||||
|
||||
// serverConcurrencyLimit is the limit on the server's total
|
||||
// number of non-exempt requests being served at once. This comes
|
||||
@ -295,7 +295,7 @@ func newTestableController(config TestableConfig) *configController {
|
||||
cfgCtlr.configQueue = workqueue.NewNamedRateLimitingQueue(workqueue.NewItemExponentialFailureRateLimiter(200*time.Millisecond, 8*time.Hour), "priority_and_fairness_config_queue")
|
||||
// ensure the data structure reflects the mandatory config
|
||||
cfgCtlr.lockAndDigestConfigObjects(nil, nil)
|
||||
fci := config.InformerFactory.Flowcontrol().V1beta3()
|
||||
fci := config.InformerFactory.Flowcontrol().V1()
|
||||
pli := fci.PriorityLevelConfigurations()
|
||||
fsi := fci.FlowSchemas()
|
||||
cfgCtlr.plLister = pli.Lister()
|
||||
|
@ -33,8 +33,8 @@ import (
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/utils/clock"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1"
|
||||
flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1"
|
||||
)
|
||||
|
||||
// ConfigConsumerAsFieldManager is how the config consuminng
|
||||
@ -88,7 +88,7 @@ type Interface interface {
|
||||
// New creates a new instance to implement API priority and fairness
|
||||
func New(
|
||||
informerFactory kubeinformers.SharedInformerFactory,
|
||||
flowcontrolClient flowcontrolclient.FlowcontrolV1beta3Interface,
|
||||
flowcontrolClient flowcontrolclient.FlowcontrolV1Interface,
|
||||
serverConcurrencyLimit int,
|
||||
) Interface {
|
||||
clk := eventclock.Real{}
|
||||
@ -132,7 +132,7 @@ type TestableConfig struct {
|
||||
InformerFactory kubeinformers.SharedInformerFactory
|
||||
|
||||
// FlowcontrolClient to use for manipulating config objects
|
||||
FlowcontrolClient flowcontrolclient.FlowcontrolV1beta3Interface
|
||||
FlowcontrolClient flowcontrolclient.FlowcontrolV1Interface
|
||||
|
||||
// ServerConcurrencyLimit for the controller to enforce
|
||||
ServerConcurrencyLimit int
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
@ -98,7 +98,7 @@ func TestQueueWaitTimeLatencyTracker(t *testing.T) {
|
||||
|
||||
clientset := clientsetfake.NewSimpleClientset(cfgObjs...)
|
||||
informerFactory := informers.NewSharedInformerFactory(clientset, time.Second)
|
||||
flowcontrolClient := clientset.FlowcontrolV1beta3()
|
||||
flowcontrolClient := clientset.FlowcontrolV1()
|
||||
startTime := time.Now()
|
||||
clk, _ := eventclock.NewFake(startTime, 0, nil)
|
||||
controller := newTestableController(TestableConfig{
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
@ -133,7 +133,7 @@ func TestBorrowing(t *testing.T) {
|
||||
}
|
||||
clientset := clientsetfake.NewSimpleClientset(cfgObjs...)
|
||||
informerFactory := informers.NewSharedInformerFactory(clientset, time.Second)
|
||||
flowcontrolClient := clientset.FlowcontrolV1beta3()
|
||||
flowcontrolClient := clientset.FlowcontrolV1()
|
||||
clk := eventclock.Real{}
|
||||
controller := newTestableController(TestableConfig{
|
||||
Name: "Controller",
|
||||
|
@ -26,7 +26,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
@ -38,7 +38,7 @@ import (
|
||||
fcrequest "k8s.io/apiserver/pkg/util/flowcontrol/request"
|
||||
"k8s.io/client-go/informers"
|
||||
clientsetfake "k8s.io/client-go/kubernetes/fake"
|
||||
fcclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3"
|
||||
fcclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/utils/clock"
|
||||
)
|
||||
@ -70,7 +70,7 @@ func (cfgCtlr *configController) hasPriorityLevelState(plName string) bool {
|
||||
type ctlrTestState struct {
|
||||
t *testing.T
|
||||
cfgCtlr *configController
|
||||
fcIfc fcclient.FlowcontrolV1beta3Interface
|
||||
fcIfc fcclient.FlowcontrolV1Interface
|
||||
existingPLs map[string]*flowcontrol.PriorityLevelConfiguration
|
||||
existingFSs map[string]*flowcontrol.FlowSchema
|
||||
heldRequestsMap map[string][]heldRequest
|
||||
@ -236,7 +236,7 @@ func TestConfigConsumer(t *testing.T) {
|
||||
t.Run(fmt.Sprintf("trial%d:", i), func(t *testing.T) {
|
||||
clientset := clientsetfake.NewSimpleClientset()
|
||||
informerFactory := informers.NewSharedInformerFactory(clientset, 0)
|
||||
flowcontrolClient := clientset.FlowcontrolV1beta3()
|
||||
flowcontrolClient := clientset.FlowcontrolV1()
|
||||
cts := &ctlrTestState{t: t,
|
||||
fcIfc: flowcontrolClient,
|
||||
existingFSs: map[string]*flowcontrol.FlowSchema{},
|
||||
@ -367,7 +367,7 @@ func TestAPFControllerWithGracefulShutdown(t *testing.T) {
|
||||
|
||||
clientset := clientsetfake.NewSimpleClientset(fs, pl)
|
||||
informerFactory := informers.NewSharedInformerFactory(clientset, time.Second)
|
||||
flowcontrolClient := clientset.FlowcontrolV1beta3()
|
||||
flowcontrolClient := clientset.FlowcontrolV1()
|
||||
cts := &ctlrTestState{t: t,
|
||||
fcIfc: flowcontrolClient,
|
||||
existingFSs: map[string]*flowcontrol.FlowSchema{},
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1"
|
||||
"k8s.io/apiserver/pkg/authentication/user"
|
||||
"k8s.io/apiserver/pkg/endpoints/request"
|
||||
)
|
||||
@ -93,7 +93,7 @@ func FmtPriorityLevelConfiguration(pl *flowcontrol.PriorityLevelConfiguration) s
|
||||
return "nil"
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
buf.WriteString(fmt.Sprintf("&flowcontrolv1beta3.PriorityLevelConfiguration{ObjectMeta: %#+v, Spec: ",
|
||||
buf.WriteString(fmt.Sprintf("&flowcontrolv1.PriorityLevelConfiguration{ObjectMeta: %#+v, Spec: ",
|
||||
pl.ObjectMeta))
|
||||
BufferPriorityLevelConfigurationSpec(&buf, &pl.Spec)
|
||||
buf.WriteString(fmt.Sprintf(", Status: %#+v}", pl.Status))
|
||||
@ -111,7 +111,7 @@ func FmtPriorityLevelConfigurationSpec(plSpec *flowcontrol.PriorityLevelConfigur
|
||||
// BufferPriorityLevelConfigurationSpec writes a golang source
|
||||
// expression for the given value to the given buffer
|
||||
func BufferPriorityLevelConfigurationSpec(buf *bytes.Buffer, plSpec *flowcontrol.PriorityLevelConfigurationSpec) {
|
||||
buf.WriteString(fmt.Sprintf("flowcontrolv1beta3.PriorityLevelConfigurationSpec{Type: %#v", plSpec.Type))
|
||||
buf.WriteString(fmt.Sprintf("flowcontrolv1.PriorityLevelConfigurationSpec{Type: %#v", plSpec.Type))
|
||||
if plSpec.Limited != nil {
|
||||
buf.WriteString(fmt.Sprintf(", Limited: &flowcontrol.LimitedPriorityLevelConfiguration{NominalConcurrencyShares:%d, LimitResponse:flowcontrol.LimitResponse{Type:%#v", plSpec.Limited.NominalConcurrencyShares, plSpec.Limited.LimitResponse.Type))
|
||||
if plSpec.Limited.LimitResponse.Queuing != nil {
|
||||
@ -128,7 +128,7 @@ func FmtFlowSchema(fs *flowcontrol.FlowSchema) string {
|
||||
return "nil"
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
buf.WriteString(fmt.Sprintf("&flowcontrolv1beta3.FlowSchema{ObjectMeta: %#+v, Spec: ",
|
||||
buf.WriteString(fmt.Sprintf("&flowcontrolv1.FlowSchema{ObjectMeta: %#+v, Spec: ",
|
||||
fs.ObjectMeta))
|
||||
BufferFlowSchemaSpec(&buf, &fs.Spec)
|
||||
buf.WriteString(fmt.Sprintf(", Status: %#+v}", fs.Status))
|
||||
@ -146,7 +146,7 @@ func FmtFlowSchemaSpec(fsSpec *flowcontrol.FlowSchemaSpec) string {
|
||||
// BufferFlowSchemaSpec writes a golang source expression for the
|
||||
// given value to the given buffer
|
||||
func BufferFlowSchemaSpec(buf *bytes.Buffer, fsSpec *flowcontrol.FlowSchemaSpec) {
|
||||
buf.WriteString(fmt.Sprintf("flowcontrolv1beta3.FlowSchemaSpec{PriorityLevelConfiguration: %#+v, MatchingPrecedence: %d, DistinguisherMethod: ",
|
||||
buf.WriteString(fmt.Sprintf("flowcontrolv1.FlowSchemaSpec{PriorityLevelConfiguration: %#+v, MatchingPrecedence: %d, DistinguisherMethod: ",
|
||||
fsSpec.PriorityLevelConfiguration,
|
||||
fsSpec.MatchingPrecedence))
|
||||
if fsSpec.DistinguisherMethod == nil {
|
||||
@ -166,7 +166,7 @@ func BufferFlowSchemaSpec(buf *bytes.Buffer, fsSpec *flowcontrol.FlowSchemaSpec)
|
||||
|
||||
// FmtPolicyRulesWithSubjects produces a golang source expression of the value.
|
||||
func FmtPolicyRulesWithSubjects(rule flowcontrol.PolicyRulesWithSubjects) string {
|
||||
return "flowcontrolv1beta3.PolicyRulesWithSubjects" + FmtPolicyRulesWithSubjectsSlim(rule)
|
||||
return "flowcontrolv1.PolicyRulesWithSubjects" + FmtPolicyRulesWithSubjectsSlim(rule)
|
||||
}
|
||||
|
||||
// FmtPolicyRulesWithSubjectsSlim produces a golang source expression
|
||||
@ -182,7 +182,7 @@ func FmtPolicyRulesWithSubjectsSlim(rule flowcontrol.PolicyRulesWithSubjects) st
|
||||
// expression for the given value to the given buffer but excludes the
|
||||
// leading type name
|
||||
func BufferFmtPolicyRulesWithSubjectsSlim(buf *bytes.Buffer, rule flowcontrol.PolicyRulesWithSubjects) {
|
||||
buf.WriteString("{Subjects: []flowcontrolv1beta3.Subject{")
|
||||
buf.WriteString("{Subjects: []flowcontrolv1.Subject{")
|
||||
for jdx, subj := range rule.Subjects {
|
||||
if jdx > 0 {
|
||||
buf.WriteString(", ")
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
|
||||
"k8s.io/utils/clock"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
fcboot "k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"math/rand"
|
||||
"testing"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/apiserver/pkg/authentication/user"
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrolv1 "k8s.io/api/flowcontrol/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
fqs "k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/queueset"
|
||||
"k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/testing/eventclock"
|
||||
@ -97,7 +97,7 @@ func Test_GetMaxSeats(t *testing.T) {
|
||||
t.Run(testcase.name, func(t *testing.T) {
|
||||
clientset := clientsetfake.NewSimpleClientset()
|
||||
informerFactory := informers.NewSharedInformerFactory(clientset, time.Second)
|
||||
flowcontrolClient := clientset.FlowcontrolV1beta3()
|
||||
flowcontrolClient := clientset.FlowcontrolV1()
|
||||
startTime := time.Now()
|
||||
clk, _ := eventclock.NewFake(startTime, 0, nil)
|
||||
c := newTestableController(TestableConfig{
|
||||
@ -113,23 +113,23 @@ func Test_GetMaxSeats(t *testing.T) {
|
||||
QueueSetFactory: fqs.NewQueueSetFactory(clk),
|
||||
})
|
||||
|
||||
testPriorityLevel := &v1beta3.PriorityLevelConfiguration{
|
||||
testPriorityLevel := &flowcontrolv1.PriorityLevelConfiguration{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test-pl",
|
||||
},
|
||||
Spec: v1beta3.PriorityLevelConfigurationSpec{
|
||||
Type: v1beta3.PriorityLevelEnablementLimited,
|
||||
Limited: &v1beta3.LimitedPriorityLevelConfiguration{
|
||||
Spec: flowcontrolv1.PriorityLevelConfigurationSpec{
|
||||
Type: flowcontrolv1.PriorityLevelEnablementLimited,
|
||||
Limited: &flowcontrolv1.LimitedPriorityLevelConfiguration{
|
||||
NominalConcurrencyShares: 10000,
|
||||
LimitResponse: v1beta3.LimitResponse{
|
||||
Queuing: &v1beta3.QueuingConfiguration{
|
||||
LimitResponse: flowcontrolv1.LimitResponse{
|
||||
Queuing: &flowcontrolv1.QueuingConfiguration{
|
||||
HandSize: testcase.handSize,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
c.digestConfigObjects([]*v1beta3.PriorityLevelConfiguration{testPriorityLevel}, nil)
|
||||
c.digestConfigObjects([]*flowcontrolv1.PriorityLevelConfiguration{testPriorityLevel}, nil)
|
||||
maxSeats := c.GetMaxSeats("test-pl")
|
||||
if maxSeats != testcase.expectedMaxSeats {
|
||||
t.Errorf("unexpected max seats, got=%d, want=%d", maxSeats, testcase.expectedMaxSeats)
|
||||
|
@ -19,7 +19,7 @@ package flowcontrol
|
||||
import (
|
||||
"strings"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1"
|
||||
"k8s.io/apiserver/pkg/authentication/serviceaccount"
|
||||
"k8s.io/apiserver/pkg/authentication/user"
|
||||
"k8s.io/apiserver/pkg/endpoints/request"
|
||||
|
@ -31,7 +31,7 @@ import (
|
||||
"github.com/prometheus/common/expfmt"
|
||||
"github.com/prometheus/common/model"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/apiserver/pkg/util/apihelpers"
|
||||
@ -251,7 +251,7 @@ var _ = SIGDescribe("API priority and fairness", func() {
|
||||
// createPriorityLevel creates a priority level with the provided assured
|
||||
// concurrency share.
|
||||
func createPriorityLevel(ctx context.Context, f *framework.Framework, priorityLevelName string, nominalConcurrencyShares int32) *flowcontrol.PriorityLevelConfiguration {
|
||||
createdPriorityLevel, err := f.ClientSet.FlowcontrolV1beta3().PriorityLevelConfigurations().Create(
|
||||
createdPriorityLevel, err := f.ClientSet.FlowcontrolV1().PriorityLevelConfigurations().Create(
|
||||
ctx,
|
||||
&flowcontrol.PriorityLevelConfiguration{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
@ -269,7 +269,7 @@ func createPriorityLevel(ctx context.Context, f *framework.Framework, priorityLe
|
||||
},
|
||||
metav1.CreateOptions{})
|
||||
framework.ExpectNoError(err)
|
||||
ginkgo.DeferCleanup(f.ClientSet.FlowcontrolV1beta3().PriorityLevelConfigurations().Delete, priorityLevelName, metav1.DeleteOptions{})
|
||||
ginkgo.DeferCleanup(f.ClientSet.FlowcontrolV1().PriorityLevelConfigurations().Delete, priorityLevelName, metav1.DeleteOptions{})
|
||||
return createdPriorityLevel
|
||||
}
|
||||
|
||||
@ -318,7 +318,7 @@ func createFlowSchema(ctx context.Context, f *framework.Framework, flowSchemaNam
|
||||
})
|
||||
}
|
||||
|
||||
createdFlowSchema, err := f.ClientSet.FlowcontrolV1beta3().FlowSchemas().Create(
|
||||
createdFlowSchema, err := f.ClientSet.FlowcontrolV1().FlowSchemas().Create(
|
||||
ctx,
|
||||
&flowcontrol.FlowSchema{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
@ -347,7 +347,7 @@ func createFlowSchema(ctx context.Context, f *framework.Framework, flowSchemaNam
|
||||
},
|
||||
metav1.CreateOptions{})
|
||||
framework.ExpectNoError(err)
|
||||
ginkgo.DeferCleanup(f.ClientSet.FlowcontrolV1beta3().FlowSchemas().Delete, flowSchemaName, metav1.DeleteOptions{})
|
||||
ginkgo.DeferCleanup(f.ClientSet.FlowcontrolV1().FlowSchemas().Delete, flowSchemaName, metav1.DeleteOptions{})
|
||||
return createdFlowSchema
|
||||
}
|
||||
|
||||
@ -357,7 +357,7 @@ func createFlowSchema(ctx context.Context, f *framework.Framework, flowSchemaNam
|
||||
// schema status, and (2) metrics. The function times out after 30 seconds.
|
||||
func waitForSteadyState(ctx context.Context, f *framework.Framework, flowSchemaName string, priorityLevelName string) {
|
||||
framework.ExpectNoError(wait.PollWithContext(ctx, time.Second, 30*time.Second, func(ctx context.Context) (bool, error) {
|
||||
fs, err := f.ClientSet.FlowcontrolV1beta3().FlowSchemas().Get(ctx, flowSchemaName, metav1.GetOptions{})
|
||||
fs, err := f.ClientSet.FlowcontrolV1().FlowSchemas().Get(ctx, flowSchemaName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
"github.com/prometheus/common/expfmt"
|
||||
"github.com/prometheus/common/model"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
genericfeatures "k8s.io/apiserver/pkg/features"
|
||||
@ -240,7 +240,7 @@ func getRequestCountOfPriorityLevel(c clientset.Interface) (map[string]int, map[
|
||||
|
||||
func createPriorityLevelAndBindingFlowSchemaForUser(c clientset.Interface, username string, concurrencyShares, queuelength int) (*flowcontrol.PriorityLevelConfiguration, *flowcontrol.FlowSchema, error) {
|
||||
i0 := int32(0)
|
||||
pl, err := c.FlowcontrolV1beta3().PriorityLevelConfigurations().Create(context.Background(), &flowcontrol.PriorityLevelConfiguration{
|
||||
pl, err := c.FlowcontrolV1().PriorityLevelConfigurations().Create(context.Background(), &flowcontrol.PriorityLevelConfiguration{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: username,
|
||||
},
|
||||
@ -263,7 +263,7 @@ func createPriorityLevelAndBindingFlowSchemaForUser(c clientset.Interface, usern
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
fs, err := c.FlowcontrolV1beta3().FlowSchemas().Create(context.TODO(), &flowcontrol.FlowSchema{
|
||||
fs, err := c.FlowcontrolV1().FlowSchemas().Create(context.TODO(), &flowcontrol.FlowSchema{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: username,
|
||||
},
|
||||
@ -303,7 +303,7 @@ func createPriorityLevelAndBindingFlowSchemaForUser(c clientset.Interface, usern
|
||||
}
|
||||
|
||||
return pl, fs, wait.Poll(time.Second, timeout, func() (bool, error) {
|
||||
fs, err := c.FlowcontrolV1beta3().FlowSchemas().Get(context.TODO(), username, metav1.GetOptions{})
|
||||
fs, err := c.FlowcontrolV1().FlowSchemas().Get(context.TODO(), username, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1"
|
||||
genericfeatures "k8s.io/apiserver/pkg/features"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
utilfc "k8s.io/apiserver/pkg/util/flowcontrol"
|
||||
@ -98,7 +98,7 @@ func (ft *fightTest) createMainInformer() {
|
||||
myConfig = rest.AddUserAgent(myConfig, "audience")
|
||||
myClientset := clientset.NewForConfigOrDie(myConfig)
|
||||
informerFactory := informers.NewSharedInformerFactory(myClientset, 0)
|
||||
inf := informerFactory.Flowcontrol().V1beta3().FlowSchemas().Informer()
|
||||
inf := informerFactory.Flowcontrol().V1().FlowSchemas().Informer()
|
||||
inf.AddEventHandler(cache.ResourceEventHandlerFuncs{
|
||||
AddFunc: func(obj interface{}) {
|
||||
fs := obj.(*flowcontrol.FlowSchema)
|
||||
@ -126,7 +126,7 @@ func (ft *fightTest) createController(invert bool, i int) {
|
||||
myConfig := rest.CopyConfig(ft.loopbackConfig)
|
||||
myConfig = rest.AddUserAgent(myConfig, fieldMgr)
|
||||
myClientset := clientset.NewForConfigOrDie(myConfig)
|
||||
fcIfc := myClientset.FlowcontrolV1beta3()
|
||||
fcIfc := myClientset.FlowcontrolV1()
|
||||
informerFactory := informers.NewSharedInformerFactory(myClientset, 0)
|
||||
foundToDangling := func(found bool) bool { return !found }
|
||||
if invert {
|
||||
|
@ -21,14 +21,14 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1beta3"
|
||||
flowcontrol "k8s.io/api/flowcontrol/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
machinerytypes "k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
fcboot "k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
|
||||
genericfeatures "k8s.io/apiserver/pkg/features"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
flowcontrolapply "k8s.io/client-go/applyconfigurations/flowcontrol/v1beta3"
|
||||
flowcontrolapply "k8s.io/client-go/applyconfigurations/flowcontrol/v1"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||
"k8s.io/klog/v2"
|
||||
@ -44,7 +44,7 @@ func TestConditionIsolation(t *testing.T) {
|
||||
|
||||
fsOrig := fcboot.SuggestedFlowSchemas[0]
|
||||
t.Logf("Testing Status Condition isolation in FlowSchema %q", fsOrig.Name)
|
||||
fsClient := loopbackClient.FlowcontrolV1beta3().FlowSchemas()
|
||||
fsClient := loopbackClient.FlowcontrolV1().FlowSchemas()
|
||||
var dangleOrig *flowcontrol.FlowSchemaCondition
|
||||
|
||||
wait.PollUntil(time.Second, func() (bool, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user