Skip to content

Commit cbebbd6

Browse files
feat(api,ui,sdk): Make CPU limits configurable (caraml-dev#381)
* Update swagger docs * Update sdk autogenerated openapi classes * Refactor knativeServiceConfig and make it an attribute of the service builder * Add cpu limit to resource requests and refactor knative service struct * Simplify diff reporting steps in unit test helper function * Fix k8s service unit test * Refactor how cpu and memory limits are set for fluentd stateful set * Simplify if else-block in cpu limit helper function * Update openapi specs * Update python unit tests * Add cpu limit form group component * Refactor cpu limit as nullable field * Add default values for cpu limit in all router components * Fix tooltip description * Rename cpu limit section * Update docs * Replace env var append function with merge with replace function * Add codecov config file that adds a threshold to allow random code coverage decreases * Replace outdated comment with more detailed on describing the flow of setting resource requirement values * Simplify if/else conditions in getCPULimit
1 parent 0d6f578 commit cbebbd6

38 files changed

+748
-428
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
coverage:
2+
status:
3+
patch:
4+
default:
5+
threshold: 0.03%

.github/workflows/sdk.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jobs:
5858
flags: sdk-test-${{ matrix.python-version }}
5959
name: sdk-test-${{ matrix.python-version }}
6060
token: ${{ secrets.CODECOV_TOKEN }}
61+
codecov_yml_path: ./.github/workflows/codecov-config/codecov.yml
6162

6263
release-rules:
6364
runs-on: ubuntu-latest

.github/workflows/turing.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ jobs:
282282
name: api-test
283283
token: ${{ secrets.CODECOV_TOKEN }}
284284
working-directory: api
285+
codecov_yml_path: ../.github/workflows/codecov-config/codecov.yml
285286

286287
test-engines-router:
287288
runs-on: ubuntu-latest

api/api/openapi.bundle.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -2125,6 +2125,7 @@ components:
21252125
port: 5
21262126
created_at: 2000-01-23T04:56:07.000+00:00
21272127
resource_request:
2128+
cpu_limit: cpu_limit
21282129
min_replica: 0
21292130
max_replica: 6
21302131
memory_request: memory_request
@@ -2161,6 +2162,7 @@ components:
21612162
updated_at: 2000-01-23T04:56:07.000+00:00
21622163
default_route_id: default_route_id
21632164
resource_request:
2165+
cpu_limit: cpu_limit
21642166
min_replica: 0
21652167
max_replica: 6
21662168
memory_request: memory_request
@@ -2174,6 +2176,7 @@ components:
21742176
project_id: 7
21752177
ensembler_id: 9
21762178
resource_request:
2179+
cpu_limit: cpu_limit
21772180
min_replica: 0
21782181
max_replica: 6
21792182
memory_request: memory_request
@@ -2207,6 +2210,7 @@ components:
22072210
target: target
22082211
port: 2
22092212
resource_request:
2213+
cpu_limit: cpu_limit
22102214
min_replica: 0
22112215
max_replica: 6
22122216
memory_request: memory_request
@@ -2311,6 +2315,7 @@ components:
23112315
type: object
23122316
ResourceRequest:
23132317
example:
2318+
cpu_limit: cpu_limit
23142319
min_replica: 0
23152320
max_replica: 6
23162321
memory_request: memory_request
@@ -2323,6 +2328,10 @@ components:
23232328
cpu_request:
23242329
pattern: ^(\d{1,3}(\.\d{1,3})?)$|^(\d{2,5}m)$
23252330
type: string
2331+
cpu_limit:
2332+
nullable: true
2333+
pattern: ^(\d{1,3}(\.\d{1,3})?)$|^(\d{2,5}m)$
2334+
type: string
23262335
memory_request:
23272336
pattern: ^\d+(Ei?|Pi?|Ti?|Gi?|Mi?|Ki?)?$
23282337
type: string
@@ -2419,6 +2428,7 @@ components:
24192428
port: 5
24202429
created_at: 2000-01-23T04:56:07.000+00:00
24212430
resource_request:
2431+
cpu_limit: cpu_limit
24222432
min_replica: 0
24232433
max_replica: 6
24242434
memory_request: memory_request
@@ -2481,6 +2491,7 @@ components:
24812491
project_id: 7
24822492
ensembler_id: 9
24832493
resource_request:
2494+
cpu_limit: cpu_limit
24842495
min_replica: 0
24852496
max_replica: 6
24862497
memory_request: memory_request
@@ -2514,6 +2525,7 @@ components:
25142525
target: target
25152526
port: 2
25162527
resource_request:
2528+
cpu_limit: cpu_limit
25172529
min_replica: 0
25182530
max_replica: 6
25192531
memory_request: memory_request
@@ -2588,6 +2600,7 @@ components:
25882600
target: target
25892601
port: 2
25902602
resource_request:
2603+
cpu_limit: cpu_limit
25912604
min_replica: 0
25922605
max_replica: 6
25932606
memory_request: memory_request
@@ -2640,6 +2653,7 @@ components:
26402653
project_id: 7
26412654
ensembler_id: 9
26422655
resource_request:
2656+
cpu_limit: cpu_limit
26432657
min_replica: 0
26442658
max_replica: 6
26452659
memory_request: memory_request
@@ -2770,6 +2784,7 @@ components:
27702784
port: 5
27712785
created_at: 2000-01-23T04:56:07.000+00:00
27722786
resource_request:
2787+
cpu_limit: cpu_limit
27732788
min_replica: 0
27742789
max_replica: 6
27752790
memory_request: memory_request
@@ -2830,6 +2845,7 @@ components:
28302845
- values
28312846
operator: in
28322847
resource_request:
2848+
cpu_limit: cpu_limit
28332849
min_replica: 0
28342850
max_replica: 6
28352851
memory_request: memory_request
@@ -2842,6 +2858,7 @@ components:
28422858
project_id: 7
28432859
ensembler_id: 9
28442860
resource_request:
2861+
cpu_limit: cpu_limit
28452862
min_replica: 0
28462863
max_replica: 6
28472864
memory_request: memory_request
@@ -2875,6 +2892,7 @@ components:
28752892
target: target
28762893
port: 2
28772894
resource_request:
2895+
cpu_limit: cpu_limit
28782896
min_replica: 0
28792897
max_replica: 6
28802898
memory_request: memory_request
@@ -2929,6 +2947,7 @@ components:
29292947
port: 5
29302948
created_at: 2000-01-23T04:56:07.000+00:00
29312949
resource_request:
2950+
cpu_limit: cpu_limit
29322951
min_replica: 0
29332952
max_replica: 6
29342953
memory_request: memory_request
@@ -2989,6 +3008,7 @@ components:
29893008
- values
29903009
operator: in
29913010
resource_request:
3011+
cpu_limit: cpu_limit
29923012
min_replica: 0
29933013
max_replica: 6
29943014
memory_request: memory_request
@@ -3001,6 +3021,7 @@ components:
30013021
project_id: 7
30023022
ensembler_id: 9
30033023
resource_request:
3024+
cpu_limit: cpu_limit
30043025
min_replica: 0
30053026
max_replica: 6
30063027
memory_request: memory_request
@@ -3034,6 +3055,7 @@ components:
30343055
target: target
30353056
port: 2
30363057
resource_request:
3058+
cpu_limit: cpu_limit
30373059
min_replica: 0
30383060
max_replica: 6
30393061
memory_request: memory_request

api/api/specs/routers.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,10 @@ components:
949949
cpu_request:
950950
type: "string"
951951
pattern: '^(\d{1,3}(\.\d{1,3})?)$|^(\d{2,5}m)$'
952+
cpu_limit:
953+
type: "string"
954+
pattern: '^(\d{1,3}(\.\d{1,3})?)$|^(\d{2,5}m)$'
955+
nullable: true
952956
memory_request:
953957
type: "string"
954958
pattern: '^\d+(Ei?|Pi?|Ti?|Gi?|Mi?|Ki?)?$'

api/turing/cluster/knative_service.go

+2-10
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ type KnativeService struct {
5050
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints"`
5151

5252
// Resource properties
53-
QueueProxyResourcePercentage int `json:"queueProxyResourcePercentage"`
54-
UserContainerCPULimitRequestFactor float64 `json:"userContainerLimitCPURequestFactor"`
55-
UserContainerMemoryLimitRequestFactor float64 `json:"userContainerLimitMemoryRequestFactor"`
53+
QueueProxyResourcePercentage int `json:"queueProxyResourcePercentage"`
5654
}
5755

5856
// Creates a new config object compatible with the knative serving API, from
@@ -131,12 +129,6 @@ func (cfg *KnativeService) buildSvcSpec(
131129
// Revision name
132130
revisionName := getDefaultRevisionName(cfg.Name)
133131

134-
// Build resource requirements for the user container
135-
resourceReqs := cfg.buildResourceReqs(
136-
cfg.UserContainerCPULimitRequestFactor,
137-
cfg.UserContainerMemoryLimitRequestFactor,
138-
)
139-
140132
// Build container spec
141133
var portName string
142134
// If protocol is using GRPC, add "h2c" which is required for grpc knative
@@ -151,7 +143,7 @@ func (cfg *KnativeService) buildSvcSpec(
151143
ContainerPort: cfg.ContainerPort,
152144
},
153145
},
154-
Resources: resourceReqs,
146+
Resources: cfg.buildResourceReqs(),
155147
VolumeMounts: cfg.VolumeMounts,
156148
Env: cfg.Envs,
157149
}

0 commit comments

Comments
 (0)