Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 28ead87

Browse files
committed
k8s: qareports-extra-settings: enable health-check
The idea of extra settings is to have a file that gets evaluated right in the end of squad.settings.py file. The extra settings contains additional django-health-check imports. Keep in mind that it always try to load ldap config, but that one is available only in the frontend pod. Signed-off-by: Charles Oliveira <charles.oliveira@linaro.org>
1 parent 9c6b457 commit 28ead87

5 files changed

+75
-1
lines changed

k8s/qareports-extra-settings.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# Defines file to be passed to SQUAD_EXTRA_SETTINGS
3+
#
4+
apiVersion: v1
5+
kind: ConfigMap
6+
metadata:
7+
name: qareports-extra-settings
8+
data:
9+
extra_settings.py: |-
10+
# DO NOT CHANGE THIS MANUALLY
11+
12+
# Read ldap configuration, if there's any
13+
try:
14+
exec(open("/app/linaro_ldap.py").read())
15+
except (IOError, FileNotFoundError):
16+
pass
17+
18+
# Enable health-check endpoint
19+
# should enable it in worker as well!
20+
try:
21+
import health_check
22+
23+
# This is required by RabbitMQ checker
24+
# ref: https://github.com/KristianOellegaard/django-health-check/blob/d08200dd7c01a8781236856b7b4714a15a8ba286/health_check/contrib/rabbitmq/backends.py
25+
BROKER_URL = CELERY_BROKER_URL
26+
HEALTHCHECK_CELERY_PING_TIMEOUT = 5
27+
28+
INSTALLED_APPS.append('health_check')
29+
INSTALLED_APPS.append('health_check.db')
30+
INSTALLED_APPS.append('health_check.contrib.celery')
31+
INSTALLED_APPS.append('health_check.contrib.celery_ping')
32+
INSTALLED_APPS.append('health_check.contrib.s3boto3_storage')
33+
INSTALLED_APPS.append('health_check.contrib.rabbitmq')
34+
except ImportError:
35+
pass

k8s/qareports-fetch-worker.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ spec:
5353
configMap:
5454
name: qareports-local-settings
5555

56+
- name: qareports-extra-settings
57+
configMap:
58+
name: qareports-extra-settings
59+
5660
containers:
5761
- name: qareports-fetch-worker
5862
image: squadproject/squad:release
@@ -69,6 +73,11 @@ spec:
6973
- secretRef:
7074
name: qareports-environment
7175

76+
# Inject health-check settings
77+
env:
78+
- name: SQUAD_EXTRA_SETTINGS
79+
value: "/app/extra_settings.py"
80+
7281
volumeMounts:
7382
- name: qareports-secret-key
7483
mountPath: /app/secret.dat
@@ -78,6 +87,10 @@ spec:
7887
mountPath: /usr/local/lib/python3.7/dist-packages/squad/local_settings.py
7988
subPath: local_settings.py
8089

90+
- name: qareports-extra-settings
91+
mountPath: /app/extra_settings.py
92+
subPath: extra_settings.py
93+
8194
resources:
8295
requests:
8396
memory: "4096M"

k8s/qareports-web.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ spec:
129129
# Inject ldap into container
130130
env:
131131
- name: SQUAD_EXTRA_SETTINGS
132-
value: "/app/linaro_ldap.py"
132+
value: "/app/extra_settings.py"
133133

134134
volumeMounts:
135135
- name: qareports-secret-key
@@ -148,6 +148,10 @@ spec:
148148
mountPath: /usr/local/lib/python3.7/dist-packages/squad/local_settings.py
149149
subPath: local_settings.py
150150

151+
- name: qareports-extra-settings
152+
mountPath: /app/extra_settings.py
153+
subPath: extra_settings.py
154+
151155
resources:
152156
requests:
153157
memory: "1024M"
@@ -200,5 +204,9 @@ spec:
200204
configMap:
201205
name: qareports-local-settings
202206

207+
- name: qareports-extra-settings
208+
configMap:
209+
name: qareports-extra-settings
210+
203211
- name: static-files
204212
emptyDir: {}

k8s/qareports-worker.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ spec:
5757
configMap:
5858
name: qareports-local-settings
5959

60+
- name: qareports-extra-settings
61+
configMap:
62+
name: qareports-extra-settings
63+
6064
- name: ssh-folder
6165
emptyDir: {}
6266

@@ -92,6 +96,11 @@ spec:
9296
- secretRef:
9397
name: qareports-environment
9498

99+
# Inject health-check settings
100+
env:
101+
- name: SQUAD_EXTRA_SETTINGS
102+
value: "/app/extra_settings.py"
103+
95104
volumeMounts:
96105
- name: qareports-secret-key
97106
mountPath: /app/secret.dat
@@ -101,6 +110,10 @@ spec:
101110
mountPath: /usr/local/lib/python3.7/dist-packages/squad/local_settings.py
102111
subPath: local_settings.py
103112

113+
- name: qareports-extra-settings
114+
mountPath: /app/extra_settings.py
115+
subPath: extra_settings.py
116+
104117
- name: ssh-folder
105118
mountPath: /app/.ssh
106119

qareports

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ qareports_update_local_settings(){
152152
sed "s/%ENVIRONMENT%/${environment}/" k8s/qareports-local-settings.yml | k apply -f -
153153
}
154154

155+
qareports_update_extra_settings(){
156+
echo "Updating extra_settings.py for $environment"
157+
k apply -f k8s/qareports-extra-settings.yml
158+
}
159+
155160
qareports_upgrade_squad() {
156161
echo "Upgraging $environment"
157162

0 commit comments

Comments
 (0)