Skip to content

Commit 6d388e9

Browse files
lijianguoduanhongyi
authored andcommitted
fix(controller): fix update resources bug
1 parent 097ac2f commit 6d388e9

5 files changed

Lines changed: 102 additions & 64 deletions

File tree

charts/controller/templates/controller-celery.yaml

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,47 @@ spec:
2222
app: drycc-controller-celery
2323
spec:
2424
serviceAccount: drycc-controller
25+
initContainers:
26+
- name: drycc-controller-init
27+
image: docker.io/drycc/python-dev:latest
28+
imagePullPolicy: {{.Values.image_pull_policy}}
29+
command:
30+
- netcat
31+
- -v
32+
- -u
33+
- $(DRYCC_DATABASE_URL),$(DRYCC_RABBITMQ_URL)
34+
- -a
35+
- $(DRYCC_REDIS_ADDRS)
36+
{{- include "controller.envs" . | indent 8 }}
2537
containers:
26-
- name: drycc-controller-celery-high
27-
image: {{.Values.image_registry}}/{{.Values.image_org}}/controller:{{.Values.image_tag}}
28-
imagePullPolicy: {{.Values.image_pull_policy}}
29-
command:
30-
- /bin/bash
31-
- -c
32-
args:
33-
- celery -A api worker -Q priority.high --autoscale=32,1 --loglevel=WARNING
34-
{{- include "controller.limits" . | indent 10 }}
35-
{{- include "controller.envs" . | indent 10 }}
36-
- name: drycc-controller-celery-middle
37-
image: {{.Values.image_registry}}/{{.Values.image_org}}/controller:{{.Values.image_tag}}
38-
imagePullPolicy: {{.Values.image_pull_policy}}
39-
command:
40-
- /bin/bash
41-
- -c
42-
args:
43-
- celery -A api worker -Q priority.middle --autoscale=16,1 --loglevel=WARNING
44-
{{- include "controller.limits" . | indent 10 }}
45-
{{- include "controller.envs" . | indent 10 }}
46-
- name: drycc-controller-celery-low
47-
image: {{.Values.image_registry}}/{{.Values.image_org}}/controller:{{.Values.image_tag}}
48-
imagePullPolicy: {{.Values.image_pull_policy}}
49-
command:
50-
- /bin/bash
51-
- -c
52-
args:
53-
- celery -A api worker -Q priority.low --autoscale=8,1 --loglevel=WARNING
54-
{{- include "controller.limits" . | indent 10 }}
55-
{{- include "controller.envs" . | indent 10 }}
38+
- name: drycc-controller-celery-high
39+
image: {{.Values.image_registry}}/{{.Values.image_org}}/controller:{{.Values.image_tag}}
40+
imagePullPolicy: {{.Values.image_pull_policy}}
41+
command:
42+
- /bin/bash
43+
- -c
44+
args:
45+
- celery -A api worker -Q priority.high --autoscale=32,1 --loglevel=WARNING
46+
{{- include "controller.limits" . | indent 8 }}
47+
{{- include "controller.envs" . | indent 8 }}
48+
- name: drycc-controller-celery-middle
49+
image: {{.Values.image_registry}}/{{.Values.image_org}}/controller:{{.Values.image_tag}}
50+
imagePullPolicy: {{.Values.image_pull_policy}}
51+
command:
52+
- /bin/bash
53+
- -c
54+
args:
55+
- celery -A api worker -Q priority.middle --autoscale=16,1 --loglevel=WARNING
56+
{{- include "controller.limits" . | indent 8 }}
57+
{{- include "controller.envs" . | indent 8 }}
58+
- name: drycc-controller-celery-low
59+
image: {{.Values.image_registry}}/{{.Values.image_org}}/controller:{{.Values.image_tag}}
60+
imagePullPolicy: {{.Values.image_pull_policy}}
61+
command:
62+
- /bin/bash
63+
- -c
64+
args:
65+
- celery -A api worker -Q priority.low --autoscale=8,1 --loglevel=WARNING
66+
{{- include "controller.limits" . | indent 8 }}
67+
{{- include "controller.envs" . | indent 8 }}
68+

charts/controller/templates/controller-cronjob-daily.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ spec:
1717
spec:
1818
restartPolicy: OnFailure
1919
serviceAccount: drycc-controller
20+
initContainers:
21+
- name: drycc-controller-cronjob-daily-init
22+
image: docker.io/drycc/python-dev:latest
23+
imagePullPolicy: {{.Values.image_pull_policy}}
24+
command:
25+
- netcat
26+
- -v
27+
- -u
28+
- $(DRYCC_DATABASE_URL),$(DRYCC_RABBITMQ_URL)
29+
- -a
30+
- $(DRYCC_REDIS_ADDRS)
31+
{{- include "controller.envs" . | indent 12 }}
2032
containers:
2133
- image: {{.Values.image_registry}}/{{.Values.image_org}}/controller:{{.Values.image_tag}}
2234
imagePullPolicy: {{.Values.image_pull_policy}}
@@ -63,3 +75,4 @@ spec:
6375
args:
6476
- python -u /app/manage.py measure_volumes
6577
{{- include "controller.envs" . | indent 12 }}
78+

charts/controller/templates/controller-cronjob-hourly.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ spec:
1717
spec:
1818
restartPolicy: OnFailure
1919
serviceAccount: drycc-controller
20+
initContainers:
21+
- name: drycc-controller-init
22+
image: docker.io/drycc/python-dev:latest
23+
imagePullPolicy: {{.Values.image_pull_policy}}
24+
command:
25+
- netcat
26+
- -v
27+
- -u
28+
- $(DRYCC_DATABASE_URL),$(DRYCC_RABBITMQ_URL)
29+
- -a
30+
- $(DRYCC_REDIS_ADDRS)
31+
{{- include "controller.envs" . | indent 12 }}
2032
containers:
2133
- image: {{.Values.image_registry}}/{{.Values.image_org}}/controller:{{.Values.image_tag}}
2234
imagePullPolicy: {{.Values.pull_policy}}
@@ -27,3 +39,4 @@ spec:
2739
args:
2840
- python -u /app/manage.py measure_app
2941
{{- include "controller.envs" . | indent 12 }}
42+

charts/controller/templates/controller-deployment.yaml

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,37 +23,36 @@ spec:
2323
spec:
2424
serviceAccount: drycc-controller
2525
initContainers:
26-
- name: drycc-controller-init
27-
image: {{.Values.image_registry}}/{{.Values.image_org}}/python-dev:latest
28-
imagePullPolicy: {{.Values.image_pull_policy}}
29-
command:
30-
- netcat
31-
- -v
32-
- -s
33-
- ,
34-
- -u
35-
- $(DRYCC_DATABASE_URL),$(DRYCC_RABBITMQ_URL),$(DRYCC_REDIS_ADDRS)
36-
{{- include "controller.limits" . | indent 10 }}
37-
{{- include "controller.envs" . | indent 10 }}
26+
- name: drycc-controller-init
27+
image: docker.io/drycc/python-dev:latest
28+
imagePullPolicy: {{.Values.image_pull_policy}}
29+
command:
30+
- netcat
31+
- -v
32+
- -u
33+
- $(DRYCC_DATABASE_URL),$(DRYCC_RABBITMQ_URL)
34+
- -a
35+
- $(DRYCC_REDIS_ADDRS)
36+
{{- include "controller.envs" . | indent 8 }}
3837
containers:
39-
- name: drycc-controller
40-
image: {{.Values.image_registry}}/{{.Values.image_org}}/controller:{{.Values.image_tag}}
41-
imagePullPolicy: {{.Values.image_pull_policy}}
42-
livenessProbe:
43-
httpGet:
44-
path: /healthz
45-
port: 8000
46-
initialDelaySeconds: 30
47-
timeoutSeconds: 10
48-
readinessProbe:
49-
httpGet:
50-
path: /readiness
51-
port: 8000
52-
initialDelaySeconds: 30
53-
timeoutSeconds: 10
54-
periodSeconds: 5
55-
ports:
56-
- containerPort: 8000
57-
name: http
58-
{{- include "controller.limits" . | indent 10 }}
59-
{{- include "controller.envs" . | indent 10 }}
38+
- name: drycc-controller
39+
image: {{.Values.image_registry}}/{{.Values.image_org}}/controller:{{.Values.image_tag}}
40+
imagePullPolicy: {{.Values.image_pull_policy}}
41+
livenessProbe:
42+
httpGet:
43+
path: /healthz
44+
port: 8000
45+
initialDelaySeconds: 30
46+
timeoutSeconds: 10
47+
readinessProbe:
48+
httpGet:
49+
path: /readiness
50+
port: 8000
51+
initialDelaySeconds: 30
52+
timeoutSeconds: 10
53+
periodSeconds: 5
54+
ports:
55+
- containerPort: 8000
56+
name: http
57+
{{- include "controller.limits" . | indent 8 }}
58+
{{- include "controller.envs" . | indent 8 }}

rootfs/api/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ def update(self, instance, validated_data):
735735
if instance.plan.split(':')[0] != validated_data.get('plan', '').split(':')[0]: # noqa
736736
raise DryccException("the resource cann't changed")
737737
instance.plan = validated_data.get('plan')
738-
instance.options = validated_data.get('options')
738+
instance.options.update(validated_data.get('options', {}))
739739
instance.attach_update()
740740
instance.save()
741741
return instance

0 commit comments

Comments
 (0)