Skip to content

Commit 2fb7e07

Browse files
committed
fix(celery): task not execute
1 parent 18957f1 commit 2fb7e07

6 files changed

Lines changed: 99 additions & 42 deletions

File tree

charts/helmbroker/templates/_helpers.tpl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,16 @@ env:
3030
{{- end }}
3131
{{- end }}
3232

33-
3433
{{/* Generate helmbroker deployment limits */}}
3534
{{- define "helmbroker.limits" -}}
36-
{{- if or (.Values.limits_cpu) (.Values.limits_memory) }}
35+
{{- if or (.Values.limitsCpu) (.Values.limitsMemory) }}
3736
resources:
3837
limits:
39-
{{- if (.Values.limits_cpu) }}
40-
cpu: {{.Values.limits_cpu}}
38+
{{- if (.Values.limitsCpu) }}
39+
cpu: {{.Values.limitsCpu}}
4140
{{- end }}
42-
{{- if (.Values.limits_memory) }}
43-
memory: {{.Values.limits_memory}}
41+
{{- if (.Values.limitsMemory) }}
42+
memory: {{.Values.limitsMemory}}
4443
{{- end }}
4544
{{- end }}
4645
{{- end }}

charts/helmbroker/templates/helmbroker-celery-deployment.yaml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,19 @@ spec:
3737
- $(DRYCC_HELMBROKER_SERVICE_HOST):$(DRYCC_HELMBROKER_SERVICE_PORT)
3838
{{- include "helmbroker.envs" . | indent 10 }}
3939
containers:
40-
- name: drycc-helmbroker-celery
41-
image: {{.Values.imageRegistry}}/{{.Values.imageOrg}}/helmbroker:{{.Values.imageTag}}
42-
imagePullPolicy: {{.Values.imagePullPolicy}}
43-
args:
44-
- /bin/bash
45-
- -c
46-
- celery -A helmbroker worker --autoscale=32,1 --loglevel=info
47-
{{- include "helmbroker.limits" . | indent 10 }}
48-
{{- include "helmbroker.envs" . | indent 10 }}
49-
{{- include "helmbroker.volumeMounts" . | indent 10 }}
40+
- name: drycc-helmbroker-celery
41+
image: {{$.Values.imageRegistry}}/{{$.Values.imageOrg}}/helmbroker:{{$.Values.imageTag}}
42+
imagePullPolicy: {{$.Values.imagePullPolicy}}
43+
{{- if $.Values.diagnosticMode.enabled }}
44+
command: {{- include "common.tplvalues.render" (dict "value" $.Values.diagnosticMode.command "context" $) | nindent 8 }}
45+
args: {{- include "common.tplvalues.render" (dict "value" $.Values.diagnosticMode.args "context" $) | nindent 8 }}
46+
{{- else }}
47+
args:
48+
- /bin/bash
49+
- -c
50+
- celery --app helmbroker worker --queues helmbroker.low,helmbroker.middle,helmbroker.high --autoscale=32,1 --loglevel=WARNING
51+
{{- end }}
52+
{{- include "helmbroker.limits" $ | indent 8 }}
53+
{{- include "helmbroker.envs" $ | indent 8 }}
54+
{{- include "helmbroker.volumeMounts" $ | indent 8 }}
5055
{{- include "helmbroker.volumes" . | indent 6 }}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@ spec:
2121
- image: {{.Values.imageRegistry}}/{{.Values.imageOrg}}/helmbroker:{{.Values.imageTag}}
2222
imagePullPolicy: {{.Values.imagePullPolicy}}
2323
name: drycc-helmbroker-cleaner
24+
{{- if .Values.diagnosticMode.enabled }}
25+
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 14 }}
26+
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 14 }}
27+
{{- else }}
2428
args:
2529
- /bin/bash
2630
- -c
2731
- python -m helmbroker.cleaner
32+
{{- end }}
2833
{{- include "helmbroker.envs" . | indent 12 }}
2934
{{- include "helmbroker.volumeMounts" . | indent 12 }}
3035
{{- include "helmbroker.volumes" . | indent 10 }}

charts/helmbroker/templates/helmbroker-deployment.yaml

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,32 @@ spec:
4646
- $(DRYCC_RABBITMQ_URL)
4747
{{- include "helmbroker.envs" . | indent 10 }}
4848
containers:
49-
- name: drycc-helmbroker
50-
image: {{.Values.imageRegistry}}/{{.Values.imageOrg}}/helmbroker:{{.Values.imageTag}}
51-
imagePullPolicy: {{.Values.imagePullPolicy}}
52-
livenessProbe:
53-
httpGet:
54-
path: /healthz
55-
port: 8000
56-
initialDelaySeconds: 30
57-
timeoutSeconds: 10
58-
readinessProbe:
59-
httpGet:
60-
path: /readiness
61-
port: 8000
62-
initialDelaySeconds: 30
63-
timeoutSeconds: 10
64-
periodSeconds: 5
65-
ports:
66-
- containerPort: 8000
67-
name: http
68-
{{- include "helmbroker.limits" . | indent 10 }}
69-
{{- include "helmbroker.envs" . | indent 10 }}
70-
{{- include "helmbroker.volumeMounts" . | indent 10 }}
49+
- name: drycc-helmbroker
50+
image: {{.Values.imageRegistry}}/{{.Values.imageOrg}}/helmbroker:{{.Values.imageTag}}
51+
imagePullPolicy: {{.Values.imagePullPolicy}}
52+
{{- if .Values.diagnosticMode.enabled }}
53+
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 8 }}
54+
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 8 }}
55+
{{- end }}
56+
{{- if not .Values.diagnosticMode.enabled }}
57+
livenessProbe:
58+
httpGet:
59+
path: /healthz
60+
port: 8000
61+
initialDelaySeconds: 30
62+
timeoutSeconds: 10
63+
readinessProbe:
64+
httpGet:
65+
path: /readiness
66+
port: 8000
67+
initialDelaySeconds: 30
68+
timeoutSeconds: 10
69+
periodSeconds: 5
70+
{{- end }}
71+
ports:
72+
- containerPort: 8000
73+
name: http
74+
{{- include "helmbroker.limits" . | indent 8 }}
75+
{{- include "helmbroker.envs" . | indent 8 }}
76+
{{- include "helmbroker.volumeMounts" . | indent 8 }}
7177
{{- include "helmbroker.volumes" . | indent 6 }}

charts/helmbroker/values.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ replicas: 1
66
# limitsCpu: "100m"
77
# limitsMemory: "50Mi"
88

9+
## Enable diagnostic mode
10+
##
11+
diagnosticMode:
12+
## @param diagnosticMode.enabled Enable diagnostic mode (all probes will be disabled and the command will be overridden)
13+
##
14+
enabled: false
15+
## @param diagnosticMode.command Command to override all containers
16+
##
17+
command:
18+
- sleep
19+
## @param diagnosticMode.args Args to override all containers
20+
##
21+
args:
22+
- infinity
23+
924
## config the helm-broker repositories
1025
repositories:
1126
- name: drycc-helm-broker

rootfs/helmbroker/celery.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Config(object):
2020
result_expires = 24 * 60 * 60
2121
broker_url = os.environ.get("DRYCC_RABBITMQ_URL", 'amqp://guest:guest@127.0.0.1:5672/') # noqa
2222
broker_connection_retry_on_startup = True
23-
task_default_queue = 'low'
23+
task_default_queue = 'helmbroker.low'
2424
task_default_exchange = 'helmbroker.priority'
2525
task_default_routing_key = 'helmbroker.priority.low'
2626
broker_connection_retry_on_startup = True
@@ -31,19 +31,46 @@ class Config(object):
3131
app.config_from_object(Config())
3232
app.conf.update(
3333
task_routes={
34-
'helmbroker.tasks': {
35-
'queue': 'low',
34+
'helmbroker.tasks.provision': {
35+
'queue': 'helmbroker.high',
3636
'exchange': 'helmbroker.priority',
3737
'routing_key': 'helmbroker.priority.high',
3838
},
39+
'helmbroker.tasks.update': {
40+
'queue': 'helmbroker.high',
41+
'exchange': 'helmbroker.priority',
42+
'routing_key': 'helmbroker.priority.high',
43+
},
44+
'helmbroker.tasks.bind': {
45+
'queue': 'helmbroker.high',
46+
'exchange': 'helmbroker.priority',
47+
'routing_key': 'helmbroker.priority.high',
48+
},
49+
'helmbroker.tasks.deprovision': {
50+
'queue': 'helmbroker.middle',
51+
'exchange': 'helmbroker.priority',
52+
'routing_key': 'helmbroker.priority.middle',
53+
},
3954
},
4055
task_queues=(
4156
Queue(
42-
'low',
57+
'helmbroker.low',
4358
exchange=Exchange('helmbroker.priority', type="direct"),
4459
routing_key='helmbroker.priority.low',
4560
queue_arguments={'x-max-priority': 16},
4661
),
62+
Queue(
63+
'helmbroker.high',
64+
exchange=Exchange('helmbroker.priority', type="direct"),
65+
routing_key='helmbroker.priority.high',
66+
queue_arguments={'x-max-priority': 64},
67+
),
68+
Queue(
69+
'helmbroker.middle',
70+
exchange=Exchange('helmbroker.priority', type="direct"),
71+
routing_key='helmbroker.priority.middle',
72+
queue_arguments={'x-max-priority': 32},
73+
),
4774
),
4875
)
4976
app.autodiscover_tasks(("helmbroker.tasks",))

0 commit comments

Comments
 (0)