Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm chart: added configuration of uwsgi using environment variables #2045

Merged
merged 2 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add models and framework to use different services (Phone, SMS, Verify) in Twilio depending on
the destination country code by @mderynck ([#1976](https://github.com/grafana/oncall/pull/1976))
- Prometheus exporter backend for alert groups related metrics
- Helm chart: configuration of `uwsgi` using environment variables by @alexintech ([#2045](https://github.com/grafana/oncall/pull/2045))
- Much expanded/improved docs for mobile app ([2026](https://github.com/grafana/oncall/pull/2026>))
- Enable by-day selection when defining monthly and hourly rotations ([2037](https://github.com/grafana/oncall/pull/2037))

### Fixed

- Fix error when updating closed modal window in Slack by @vadimkerr ([#2019](https://github.com/grafana/oncall/pull/2019))
- Fix final schedule export failing to update when ical imported events set start/end as date ([#2025](https://github.com/grafana/oncall/pull/2025))
- Helm chart: fix bugs in helm chart with external postgresql configuration by @alexintech ([#2036](https://github.com/grafana/oncall/pull/2036))
- Properly address `Organization.DoesNotExist` exceptions thrown which result in HTTP 500 for the Slack `interactive_api_endpoint`
endpoint by @joeyorlando ([#2040](https://github.com/grafana/oncall/pull/2040))

Expand Down
12 changes: 10 additions & 2 deletions helm/oncall/templates/_env.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
value: "admin"
- name: OSS
value: "True"
- name: UWSGI_LISTEN
value: "1024"
{{- template "snippet.oncall.uwsgi" . }}
- name: BROKER_TYPE
value: {{ .Values.broker.type | default "rabbitmq" }}
- name: GRAFANA_API_URL
Expand Down Expand Up @@ -51,6 +50,15 @@ MIRAGE_SECRET_KEY
{{- end -}}
{{- end -}}

{{- define "snippet.oncall.uwsgi" -}}
{{- if .Values.uwsgi -}}
{{- range $key, $value := .Values.uwsgi }}
- name: UWSGI_{{ $key | upper | replace "-" "_" }}
value: {{ $value | quote }}
{{- end -}}
{{- end -}}
{{- end -}}

{{- define "snippet.oncall.slack.env" -}}
{{- if .Values.oncall.slack.enabled -}}
- name: FEATURE_SLACK_INTEGRATION_ENABLED
Expand Down
14 changes: 7 additions & 7 deletions helm/oncall/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Create the name of the service account to use
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ['sh', '-c', "until (python manage.py migrate --check); do echo Waiting for database migrations; sleep 2; done"]
securityContext:
{{ toYaml .Values.init.securityContext| nindent 4}}
{{ toYaml .Values.init.securityContext | nindent 4 }}
env:
{{- include "snippet.oncall.env" . | nindent 4 }}
{{- include "snippet.mysql.env" . | nindent 4 }}
Expand All @@ -116,13 +116,13 @@ Create the name of the service account to use
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ['sh', '-c', "until (python manage.py migrate --check); do echo Waiting for database migrations; sleep 2; done"]
securityContext:
{{ toYaml .Values.init.securityContext| nindent 4}}
{{ toYaml .Values.init.securityContext | nindent 4 }}
env:
{{- include "snippet.oncall.env" . | nindent 12 }}
{{- include "snippet.postgresql.env" . | nindent 12 }}
{{- include "snippet.rabbitmq.env" . | nindent 12 }}
{{- include "snippet.redis.env" . | nindent 12 }}
{{- include "snippet.oncall.env" . | nindent 4 }}
{{- include "snippet.postgresql.env" . | nindent 4 }}
{{- include "snippet.rabbitmq.env" . | nindent 4 }}
{{- include "snippet.redis.env" . | nindent 4 }}
{{- if .Values.env }}
{{- toYaml .Values.env | nindent 12 }}
{{- toYaml .Values.env | nindent 4 }}
{{- end }}
{{- end }}
49 changes: 49 additions & 0 deletions helm/oncall/tests/uwsgi_env_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
suite: test uwsgi environment variables
templates:
- engine/deployment.yaml
- engine/job-migrate.yaml
- celery/deployment-celery.yaml
release:
name: oncall
tests:
- it: uwsgi.listen should overwrite UWSGI_LISTEN env
set:
uwsgi.listen: 128
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: UWSGI_LISTEN
value: "128"
- it: uwsgi.envs should set multiple UWSGI_* envs
set:
uwsgi:
processes: 3
max-requests: 1000
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: UWSGI_LISTEN
value: "1024"
- contains:
path: spec.template.spec.containers[0].env
content:
name: UWSGI_PROCESSES
value: "3"
- contains:
path: spec.template.spec.containers[0].env
content:
name: UWSGI_MAX_REQUESTS
value: "1000"
- it: uwsgi.null should not set any UWSGI_* variable
set:
uwsgi: null
asserts:
- notContains:
path: spec.template.spec.containers[0].env
content:
name: UWSGI_LISTEN



6 changes: 6 additions & 0 deletions helm/oncall/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ migrate:
# use a helm hook to manage the migration job
useHook: false

# Sets environment variables with name capitalized and prefixed with UWSGI_, and dashes are substituted with underscores.
# see more: https://uwsgi-docs.readthedocs.io/en/latest/Configuration.html#environment-variables
# Set null to disable all UWSGI environment variables
uwsgi:
listen: 1024

# Additional env variables to add to deployments
env: {}

Expand Down