generated: run refactor
This commit is contained in:
@@ -47,6 +47,7 @@ go_test(
|
||||
deps = [
|
||||
"//pkg/apis/flowcontrol/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/api/flowcontrol/v1alpha1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/fake:go_default_library",
|
||||
"//vendor/github.com/stretchr/testify/assert:go_default_library",
|
||||
|
@@ -154,7 +154,7 @@ func lastMandatoryExists(flowcontrolClientSet flowcontrolclient.FlowcontrolV1alp
|
||||
|
||||
func ensure(flowcontrolClientSet flowcontrolclient.FlowcontrolV1alpha1Interface, flowSchemas []*flowcontrolv1alpha1.FlowSchema, priorityLevels []*flowcontrolv1alpha1.PriorityLevelConfiguration) error {
|
||||
for _, flowSchema := range flowSchemas {
|
||||
_, err := flowcontrolClientSet.FlowSchemas().Create(context.TODO(), flowSchema)
|
||||
_, err := flowcontrolClientSet.FlowSchemas().Create(context.TODO(), flowSchema, metav1.CreateOptions{})
|
||||
if apierrors.IsAlreadyExists(err) {
|
||||
klog.V(3).Infof("system preset FlowSchema %s already exists, skipping creating", flowSchema.Name)
|
||||
continue
|
||||
@@ -165,7 +165,7 @@ func ensure(flowcontrolClientSet flowcontrolclient.FlowcontrolV1alpha1Interface,
|
||||
klog.V(3).Infof("created system preset FlowSchema %s", flowSchema.Name)
|
||||
}
|
||||
for _, priorityLevelConfiguration := range priorityLevels {
|
||||
_, err := flowcontrolClientSet.PriorityLevelConfigurations().Create(context.TODO(), priorityLevelConfiguration)
|
||||
_, err := flowcontrolClientSet.PriorityLevelConfigurations().Create(context.TODO(), priorityLevelConfiguration, metav1.CreateOptions{})
|
||||
if apierrors.IsAlreadyExists(err) {
|
||||
klog.V(3).Infof("system preset PriorityLevelConfiguration %s already exists, skipping creating", priorityLevelConfiguration.Name)
|
||||
continue
|
||||
@@ -189,7 +189,7 @@ func upgrade(flowcontrolClientSet flowcontrolclient.FlowcontrolV1alpha1Interface
|
||||
return fmt.Errorf("failed checking if mandatory FlowSchema %s is up-to-date due to %v, will retry later", expectedFlowSchema.Name, err)
|
||||
}
|
||||
if !identical {
|
||||
if _, err := flowcontrolClientSet.FlowSchemas().Update(context.TODO(), expectedFlowSchema); err != nil {
|
||||
if _, err := flowcontrolClientSet.FlowSchemas().Update(context.TODO(), expectedFlowSchema, metav1.UpdateOptions{}); err != nil {
|
||||
return fmt.Errorf("failed upgrading mandatory FlowSchema %s due to %v, will retry later", expectedFlowSchema.Name, err)
|
||||
}
|
||||
}
|
||||
@@ -198,7 +198,7 @@ func upgrade(flowcontrolClientSet flowcontrolclient.FlowcontrolV1alpha1Interface
|
||||
if !apierrors.IsNotFound(err) {
|
||||
return fmt.Errorf("failed getting FlowSchema %s due to %v, will retry later", expectedFlowSchema.Name, err)
|
||||
}
|
||||
_, err = flowcontrolClientSet.FlowSchemas().Create(context.TODO(), expectedFlowSchema)
|
||||
_, err = flowcontrolClientSet.FlowSchemas().Create(context.TODO(), expectedFlowSchema, metav1.CreateOptions{})
|
||||
if apierrors.IsAlreadyExists(err) {
|
||||
klog.V(3).Infof("system preset FlowSchema %s already exists, skipping creating", expectedFlowSchema.Name)
|
||||
continue
|
||||
@@ -218,7 +218,7 @@ func upgrade(flowcontrolClientSet flowcontrolclient.FlowcontrolV1alpha1Interface
|
||||
return fmt.Errorf("failed checking if mandatory PriorityLevelConfiguration %s is up-to-date due to %v, will retry later", expectedPriorityLevelConfiguration.Name, err)
|
||||
}
|
||||
if !identical {
|
||||
if _, err := flowcontrolClientSet.PriorityLevelConfigurations().Update(context.TODO(), expectedPriorityLevelConfiguration); err != nil {
|
||||
if _, err := flowcontrolClientSet.PriorityLevelConfigurations().Update(context.TODO(), expectedPriorityLevelConfiguration, metav1.UpdateOptions{}); err != nil {
|
||||
return fmt.Errorf("failed upgrading mandatory PriorityLevelConfiguration %s due to %v, will retry later", expectedPriorityLevelConfiguration.Name, err)
|
||||
}
|
||||
}
|
||||
@@ -227,7 +227,7 @@ func upgrade(flowcontrolClientSet flowcontrolclient.FlowcontrolV1alpha1Interface
|
||||
if !apierrors.IsNotFound(err) {
|
||||
return fmt.Errorf("failed getting PriorityLevelConfiguration %s due to %v, will retry later", expectedPriorityLevelConfiguration.Name, err)
|
||||
}
|
||||
_, err = flowcontrolClientSet.PriorityLevelConfigurations().Create(context.TODO(), expectedPriorityLevelConfiguration)
|
||||
_, err = flowcontrolClientSet.PriorityLevelConfigurations().Create(context.TODO(), expectedPriorityLevelConfiguration, metav1.CreateOptions{})
|
||||
if apierrors.IsAlreadyExists(err) {
|
||||
klog.V(3).Infof("system preset PriorityLevelConfiguration %s already exists, skipping creating", expectedPriorityLevelConfiguration.Name)
|
||||
continue
|
||||
|
@@ -23,6 +23,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
flowcontrolv1alpha1 "k8s.io/api/flowcontrol/v1alpha1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
|
||||
"k8s.io/client-go/kubernetes/fake"
|
||||
flowcontrolapisv1alpha1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1alpha1"
|
||||
@@ -50,7 +51,7 @@ func TestShouldEnsurePredefinedSettings(t *testing.T) {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
c := fake.NewSimpleClientset()
|
||||
if testCase.existingPriorityLevel != nil {
|
||||
c.FlowcontrolV1alpha1().PriorityLevelConfigurations().Create(context.TODO(), testCase.existingPriorityLevel)
|
||||
c.FlowcontrolV1alpha1().PriorityLevelConfigurations().Create(context.TODO(), testCase.existingPriorityLevel, metav1.CreateOptions{})
|
||||
}
|
||||
should, err := lastMandatoryExists(c.FlowcontrolV1alpha1())
|
||||
assert.NoError(t, err)
|
||||
|
Reference in New Issue
Block a user