-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113485 from MikeSpreitzer/apf-borrowing
Add borrowing between priority levels in APF
- Loading branch information
Showing
72 changed files
with
2,226 additions
and
459 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
Copyright 2022 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package fuzzer | ||
|
||
import ( | ||
fuzz "github.com/google/gofuzz" | ||
|
||
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" | ||
"k8s.io/kubernetes/pkg/apis/flowcontrol" | ||
) | ||
|
||
// Funcs returns the fuzzer functions for the flowcontrol api group. | ||
var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { | ||
return []interface{}{ | ||
func(obj *flowcontrol.LimitedPriorityLevelConfiguration, c fuzz.Continue) { | ||
c.FuzzNoCustom(obj) // fuzz self without calling this function again | ||
if obj.LendablePercent == nil { | ||
i := int32(0) | ||
obj.LendablePercent = &i | ||
} | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
Copyright 2022 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
|
||
flowcontrolv1alpha1 "k8s.io/api/flowcontrol/v1alpha1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/utils/pointer" | ||
) | ||
|
||
func TestDefaultWithPriorityLevelConfiguration(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
original runtime.Object | ||
expected runtime.Object | ||
}{ | ||
{ | ||
name: "LendablePercent is not specified, should default to zero", | ||
original: &flowcontrolv1alpha1.PriorityLevelConfiguration{ | ||
Spec: flowcontrolv1alpha1.PriorityLevelConfigurationSpec{ | ||
Type: flowcontrolv1alpha1.PriorityLevelEnablementLimited, | ||
Limited: &flowcontrolv1alpha1.LimitedPriorityLevelConfiguration{ | ||
AssuredConcurrencyShares: 5, | ||
LimitResponse: flowcontrolv1alpha1.LimitResponse{ | ||
Type: flowcontrolv1alpha1.LimitResponseTypeReject, | ||
}, | ||
}, | ||
}, | ||
}, | ||
expected: &flowcontrolv1alpha1.PriorityLevelConfiguration{ | ||
Spec: flowcontrolv1alpha1.PriorityLevelConfigurationSpec{ | ||
Type: flowcontrolv1alpha1.PriorityLevelEnablementLimited, | ||
Limited: &flowcontrolv1alpha1.LimitedPriorityLevelConfiguration{ | ||
AssuredConcurrencyShares: 5, | ||
LendablePercent: pointer.Int32(0), | ||
LimitResponse: flowcontrolv1alpha1.LimitResponse{ | ||
Type: flowcontrolv1alpha1.LimitResponseTypeReject, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
scheme := runtime.NewScheme() | ||
if err := AddToScheme(scheme); err != nil { | ||
t.Fatalf("Failed to add to scheme: %v", err) | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
original := test.original | ||
expected := test.expected | ||
|
||
scheme.Default(original) | ||
if !reflect.DeepEqual(expected, original) { | ||
t.Errorf("Expected defaulting to work - diff: %s", cmp.Diff(expected, original)) | ||
} | ||
}) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.