Skip to content

Commit e883e5f

Browse files
committed
feat(limits): add limits plan support
1 parent 6d75b6d commit e883e5f

39 files changed

Lines changed: 3282 additions & 915 deletions

charts/controller/Chart.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dependencies:
2+
- name: common
3+
repository: oci://registry.drycc.cc/charts
4+
version: 1.1.3
5+
digest: sha256:4928b76b9f4927f43702c2617b139b2fe7298055b9b6d0c363a7a94530985595
6+
generated: "2024-03-11T13:01:11.599897382+08:00"

charts/controller/a.yaml

Lines changed: 2210 additions & 0 deletions
Large diffs are not rendered by default.
10.4 KB
Binary file not shown.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: controller-config
5+
labels:
6+
heritage: drycc
7+
data:
8+
limit-specs.json: |
9+
[{
10+
"model": "api.limitspec",
11+
"pk": "std1",
12+
"fields": {
13+
"cpu": {
14+
"name": "Unknown CPU",
15+
"cores": 32,
16+
"clock": "3100MHZ",
17+
"boost": "3700MHZ",
18+
"threads": 64
19+
},
20+
"memory": {
21+
"size": "64GB",
22+
"type": "DDR4-ECC"
23+
},
24+
"features": {
25+
"gpu": {
26+
"name": "Unknown Integrated GPU",
27+
"tmus": 1,
28+
"rops": 1,
29+
"cores": 128,
30+
"memory": {
31+
"size": "shared",
32+
"type": "shared"
33+
}
34+
},
35+
"network": "10G"
36+
},
37+
"keywords": ["unknown"],
38+
"disabled": false,
39+
"created": "{{ now | date "2006-01-02T15:04:05.000Z" }}",
40+
"updated": "{{ now | date "2006-01-02T15:04:05.000Z" }}"
41+
}
42+
}]
43+
# Given a name SPEC.NETWORK.PLAN(eg: std1.xlarge.c1m1), increment the:
44+
# * SPEC different specification families can be selected based on business and usage scenarios.
45+
# * NETWORK
46+
# * PLAN Specific CPU configuration, such as c1m1 representing one CPU and 1GB of memory.
47+
limit-plans.json: |
48+
[
49+
{{- $items := tuple "1/1/10" "1/2/10" "1/4/20" "2/2/20" "2/4/30" "2/8/30" }}
50+
{{- range $index, $item := $items }}
51+
{{- $cpu := index (splitList "/" $item) 0 }}
52+
{{- $memory := index (splitList "/" $item) 1 }}
53+
{{- $network := index (splitList "/" $item) 2 }}
54+
{
55+
"model": "api.limitplan",
56+
"pk": "std1.large.c{{ $cpu }}m{{ $memory }}",
57+
"fields": {
58+
"spec_id": "std1",
59+
"cpu": {{ $cpu }},
60+
"memory": {{ $memory }},
61+
"features": {
62+
"gpu": 1,
63+
"network": 1
64+
},
65+
"disabled": false,
66+
"priority": {{ add 100 $index }},
67+
"limits": {
68+
"cpu": {{ $cpu }},
69+
"memory": "{{ $memory }}Gi",
70+
"ephemeral-storage": "2Gi"
71+
},
72+
"requests": {
73+
"cpu": {{ divf $cpu 2 }},
74+
"memory": "{{ divf $memory 2 }}Gi",
75+
"ephemeral-storage": "2Gi"
76+
},
77+
"annotations": {
78+
"kubernetes.io/egress-bandwidth": "{{ $network }}M",
79+
"kubernetes.io/ingress-bandwidth": "{{ $network }}M"
80+
},
81+
"node_selector": {},
82+
"pod_security_context": {},
83+
"container_security_context": {},
84+
"created": "{{ now | date "2006-01-02T15:04:05.000Z" }}",
85+
"updated": "{{ now | date "2006-01-02T15:04:05.000Z" }}"
86+
}
87+
}{{ if not (eq $item ($items|last)) }},{{ end }}
88+
{{- end }}
89+
]

rootfs/api/exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def custom_exception_handler(exc, context):
4343
# No response means DRF couldn't handle it
4444
# Output a generic 500 in a JSON format
4545
if response is None:
46+
raise exc
4647
logging.exception('Uncaught Exception', exc_info=exc)
4748
set_rollback()
4849
return Response({'detail': 'Server Error'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)

rootfs/api/fixtures/tests.json

Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,243 @@
8888
"email": "autotest4@drycc.cc",
8989
"date_joined": "2013-05-10T16:08:09.357Z"
9090
}
91+
},
92+
{
93+
"model": "api.limitspec",
94+
"pk": "std1",
95+
"fields": {
96+
"cpu": {
97+
"name": "Unknown CPU",
98+
"cores": 32,
99+
"clock": "3100MHZ",
100+
"boost": "3700MHZ",
101+
"threads": 64
102+
},
103+
"memory": {
104+
"size": "64GB",
105+
"type": "DDR4-ECC"
106+
},
107+
"features": {
108+
"gpu": {
109+
"name": "Unknown Integrated GPU",
110+
"tmus": 1,
111+
"rops": 1,
112+
"cores": 128,
113+
"memory": {
114+
"size": "shared",
115+
"type": "shared"
116+
}
117+
},
118+
"network": "10G"
119+
},
120+
"keywords": ["amd", "intel", "unknown"],
121+
"disabled": false,
122+
"created": "2024-03-13T10:49:49.773Z",
123+
"updated": "2024-03-13T10:49:49.773Z"
124+
}
125+
},
126+
{
127+
"model": "api.limitplan",
128+
"pk": "std1.large.c1m1",
129+
"fields": {
130+
"spec_id": "std1",
131+
"cpu": 1,
132+
"memory": 1,
133+
"features": {
134+
"gpu": 1,
135+
"network": 1
136+
},
137+
"disabled": false,
138+
"priority": 100,
139+
"limits": {
140+
"cpu": 1,
141+
"memory": "1Gi",
142+
"ephemeral-storage": "2Gi"
143+
},
144+
"requests": {
145+
"cpu": 0.5,
146+
"memory": "0.5Gi",
147+
"ephemeral-storage": "2Gi"
148+
},
149+
"annotations": {
150+
"kubernetes.io/egress-bandwidth": "10M",
151+
"kubernetes.io/ingress-bandwidth": "10M"
152+
},
153+
"node_selector": {},
154+
"pod_security_context": {},
155+
"container_security_context": {},
156+
"created": "2024-03-13T11:08:07.681Z",
157+
"updated": "2024-03-13T11:08:07.681Z"
158+
}
159+
},
160+
{
161+
"model": "api.limitplan",
162+
"pk": "std1.large.c1m2",
163+
"fields": {
164+
"spec_id": "std1",
165+
"cpu": 1,
166+
"memory": 2,
167+
"features": {
168+
"gpu": 1,
169+
"network": 1
170+
},
171+
"disabled": false,
172+
"priority": 101,
173+
"limits": {
174+
"cpu": 1,
175+
"memory": "2Gi",
176+
"ephemeral-storage": "2Gi"
177+
},
178+
"requests": {
179+
"cpu": 0.5,
180+
"memory": "1Gi",
181+
"ephemeral-storage": "2Gi"
182+
},
183+
"annotations": {
184+
"kubernetes.io/egress-bandwidth": "10M",
185+
"kubernetes.io/ingress-bandwidth": "10M"
186+
},
187+
"node_selector": {},
188+
"pod_security_context": {},
189+
"container_security_context": {},
190+
"created": "2024-03-13T11:08:07.681Z",
191+
"updated": "2024-03-13T11:08:07.681Z"
192+
}
193+
},
194+
{
195+
"model": "api.limitplan",
196+
"pk": "std1.large.c1m4",
197+
"fields": {
198+
"spec_id": "std1",
199+
"cpu": 1,
200+
"memory": 4,
201+
"features": {
202+
"gpu": 1,
203+
"network": 1
204+
},
205+
"disabled": false,
206+
"priority": 102,
207+
"limits": {
208+
"cpu": 1,
209+
"memory": "4Gi",
210+
"ephemeral-storage": "2Gi"
211+
},
212+
"requests": {
213+
"cpu": 0.5,
214+
"memory": "2Gi",
215+
"ephemeral-storage": "2Gi"
216+
},
217+
"annotations": {
218+
"kubernetes.io/egress-bandwidth": "20M",
219+
"kubernetes.io/ingress-bandwidth": "20M"
220+
},
221+
"node_selector": {},
222+
"pod_security_context": {},
223+
"container_security_context": {},
224+
"created": "2024-03-13T11:08:07.681Z",
225+
"updated": "2024-03-13T11:08:07.681Z"
226+
}
227+
},
228+
{
229+
"model": "api.limitplan",
230+
"pk": "std1.large.c2m2",
231+
"fields": {
232+
"spec_id": "std1",
233+
"cpu": 2,
234+
"memory": 2,
235+
"features": {
236+
"gpu": 1,
237+
"network": 1
238+
},
239+
"disabled": false,
240+
"priority": 103,
241+
"limits": {
242+
"cpu": 2,
243+
"memory": "2Gi",
244+
"ephemeral-storage": "2Gi"
245+
},
246+
"requests": {
247+
"cpu": 1,
248+
"memory": "1Gi",
249+
"ephemeral-storage": "2Gi"
250+
},
251+
"annotations": {
252+
"kubernetes.io/egress-bandwidth": "20M",
253+
"kubernetes.io/ingress-bandwidth": "20M"
254+
},
255+
"node_selector": {},
256+
"pod_security_context": {},
257+
"container_security_context": {},
258+
"created": "2024-03-13T11:08:07.681Z",
259+
"updated": "2024-03-13T11:08:07.681Z"
260+
}
261+
},
262+
{
263+
"model": "api.limitplan",
264+
"pk": "std1.large.c2m4",
265+
"fields": {
266+
"spec_id": "std1",
267+
"cpu": 2,
268+
"memory": 4,
269+
"features": {
270+
"gpu": 1,
271+
"network": 1
272+
},
273+
"disabled": false,
274+
"priority": 104,
275+
"limits": {
276+
"cpu": 2,
277+
"memory": "4Gi",
278+
"ephemeral-storage": "2Gi"
279+
},
280+
"requests": {
281+
"cpu": 1,
282+
"memory": "2Gi",
283+
"ephemeral-storage": "2Gi"
284+
},
285+
"annotations": {
286+
"kubernetes.io/egress-bandwidth": "30M",
287+
"kubernetes.io/ingress-bandwidth": "30M"
288+
},
289+
"node_selector": {},
290+
"pod_security_context": {},
291+
"container_security_context": {},
292+
"created": "2024-03-13T11:08:07.681Z",
293+
"updated": "2024-03-13T11:08:07.681Z"
294+
}
295+
},
296+
{
297+
"model": "api.limitplan",
298+
"pk": "std1.large.c2m8",
299+
"fields": {
300+
"spec_id": "std1",
301+
"cpu": 2,
302+
"memory": 8,
303+
"features": {
304+
"gpu": 1,
305+
"network": 1
306+
},
307+
"disabled": false,
308+
"priority": 105,
309+
"limits": {
310+
"cpu": 2,
311+
"memory": "8Gi",
312+
"ephemeral-storage": "2Gi"
313+
},
314+
"requests": {
315+
"cpu": 1,
316+
"memory": "4Gi",
317+
"ephemeral-storage": "2Gi"
318+
},
319+
"annotations": {
320+
"kubernetes.io/egress-bandwidth": "30M",
321+
"kubernetes.io/ingress-bandwidth": "30M"
322+
},
323+
"node_selector": {},
324+
"pod_security_context": {},
325+
"container_security_context": {},
326+
"created": "2024-03-13T11:08:07.681Z",
327+
"updated": "2024-03-13T11:08:07.681Z"
328+
}
91329
}
92330
]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from django.core.management.commands import loaddata
2+
from api.models.limit import LimitSpec, LimitPlan
3+
4+
5+
class Command(loaddata.Command):
6+
7+
def save_obj(self, obj):
8+
if obj.__class__ in (LimitSpec, LimitPlan):
9+
obj.__class__.objects.filter(id=obj.id).delete()
10+
return super().save_obj(obj)
11+
return False

0 commit comments

Comments
 (0)