Skip to content

Commit 3e67e97

Browse files
authored
* : allow to warmup on AKS (#146)
* introduce `--core-warmup-ready-threshold` flag for warmup subcmd * update `custom-system` PLC if it exists * switch to v1 for flowschema --------- Signed-off-by: Wei Fu <weifu@microsoft.com>
1 parent a22803d commit 3e67e97

File tree

4 files changed

+33
-17
lines changed

4 files changed

+33
-17
lines changed

cmd/kperf/commands/utils/helper.go

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import (
1010
"path/filepath"
1111
"strings"
1212

13-
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3"
13+
flowcontrolv1 "k8s.io/api/flowcontrol/v1"
14+
apierrors "k8s.io/apimachinery/pkg/api/errors"
1415
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1516
"k8s.io/client-go/kubernetes"
1617
"k8s.io/client-go/tools/clientcmd"
@@ -82,21 +83,21 @@ func ApplyPriorityLevelConfiguration(kubeconfigPath string) error {
8283

8384
// Define the PriorityLevelConfiguration
8485
lendablePercent := int32(30)
85-
plc := &flowcontrolv1beta3.PriorityLevelConfiguration{
86+
plc := &flowcontrolv1.PriorityLevelConfiguration{
8687
TypeMeta: metav1.TypeMeta{
87-
APIVersion: "flowcontrol.apiserver.k8s.io/v1beta3",
88+
APIVersion: "flowcontrol.apiserver.k8s.io/v1",
8889
Kind: "PriorityLevelConfiguration",
8990
},
9091
ObjectMeta: metav1.ObjectMeta{
9192
Name: "custom-system",
9293
},
93-
Spec: flowcontrolv1beta3.PriorityLevelConfigurationSpec{
94-
Type: flowcontrolv1beta3.PriorityLevelEnablementLimited,
95-
Limited: &flowcontrolv1beta3.LimitedPriorityLevelConfiguration{
94+
Spec: flowcontrolv1.PriorityLevelConfigurationSpec{
95+
Type: flowcontrolv1.PriorityLevelEnablementLimited,
96+
Limited: &flowcontrolv1.LimitedPriorityLevelConfiguration{
9697
LendablePercent: &lendablePercent,
97-
LimitResponse: flowcontrolv1beta3.LimitResponse{
98-
Type: flowcontrolv1beta3.LimitResponseTypeQueue,
99-
Queuing: &flowcontrolv1beta3.QueuingConfiguration{
98+
LimitResponse: flowcontrolv1.LimitResponse{
99+
Type: flowcontrolv1.LimitResponseTypeQueue,
100+
Queuing: &flowcontrolv1.QueuingConfiguration{
100101
Queues: 64,
101102
HandSize: 6,
102103
QueueLengthLimit: 50,
@@ -106,8 +107,15 @@ func ApplyPriorityLevelConfiguration(kubeconfigPath string) error {
106107
},
107108
}
108109

110+
plcCli := clientset.FlowcontrolV1().PriorityLevelConfigurations()
111+
109112
// Apply the PriorityLevelConfiguration
110-
_, err = clientset.FlowcontrolV1beta3().PriorityLevelConfigurations().Create(context.TODO(), plc, metav1.CreateOptions{})
113+
_, err = plcCli.Create(context.TODO(), plc, metav1.CreateOptions{})
114+
if err != nil {
115+
if apierrors.IsAlreadyExists(err) {
116+
_, err = plcCli.Update(context.TODO(), plc, metav1.UpdateOptions{})
117+
}
118+
}
111119
if err != nil {
112120
return fmt.Errorf("failed to apply PriorityLevelConfiguration: %v", err)
113121
}

contrib/cmd/runkperf/commands/warmup/command.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ var Command = cli.Command{
6666
Usage: "Deploy runner group with a specific labels (FORMAT: KEY=VALUE[,VALUE])",
6767
Value: "node.kubernetes.io/instance-type=Standard_D16s_v3,m4.4xlarge,n1-standard-16",
6868
},
69+
cli.IntFlag{
70+
Name: "core-warmup-ready-threshold",
71+
Usage: "Indicates the threshold for core during warm-up",
72+
Value: 8,
73+
},
6974
cli.BoolFlag{
7075
Name: "eks",
7176
Usage: "Indicates the target kubernetes cluster is EKS",
@@ -121,7 +126,7 @@ var Command = cli.Command{
121126

122127
cores, ferr := utils.FetchAPIServerCores(ctx, kubeCfgPath)
123128
if ferr == nil {
124-
if isReady(cores) {
129+
if isReady(cliCtx, cores) {
125130
klog.V(0).Infof("apiserver resource is ready: %v", cores)
126131
return nil
127132
}
@@ -162,7 +167,7 @@ var Command = cli.Command{
162167

163168
cores, ferr = utils.FetchAPIServerCores(ctx, kubeCfgPath)
164169
if ferr == nil {
165-
if isReady(cores) {
170+
if isReady(cliCtx, cores) {
166171
klog.V(0).Infof("apiserver resource is ready: %v", cores)
167172
return nil
168173
}
@@ -172,14 +177,17 @@ var Command = cli.Command{
172177
}
173178

174179
// isReady returns true if there are more than two instances using 8 cores.
175-
func isReady(cores map[string]int) bool {
180+
func isReady(cliCtx *cli.Context, cores map[string]int) bool {
181+
target := cliCtx.Int("core-warmup-ready-threshold")
182+
isEKS := cliCtx.Bool("eks")
183+
176184
n := 0
177185
for _, c := range cores {
178-
if c >= 8 {
186+
if c >= target {
179187
n++
180188
}
181189
}
182-
return n >= 2
190+
return (isEKS && n >= 2) || (!isEKS && n >= 1)
183191
}
184192

185193
// deployWarmupVirtualNodepool deploys virtual nodepool.

manifests/runnergroup/server/templates/flowcontrol.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: flowcontrol.apiserver.k8s.io/v1beta3
1+
apiVersion: flowcontrol.apiserver.k8s.io/v1
22
kind: FlowSchema
33
metadata:
44
name: {{ .Values.name }}

manifests/virtualcluster/nodecontrollers/templates/flowcontrol.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: flowcontrol.apiserver.k8s.io/v1beta3
1+
apiVersion: flowcontrol.apiserver.k8s.io/v1
22
kind: FlowSchema
33
metadata:
44
name: {{ .Values.name }}

0 commit comments

Comments
 (0)