Skip to content

Commit

Permalink
Helm chart: added configuration of uwsgi using environment variables (#…
Browse files Browse the repository at this point in the history
…2045)

# What this PR does

Adds `uwsgi` configuration to helm chart.
Sets environment variables with name capitalized and prefixed with
`UWSGI_`, and dashes are substituted with underscores like described
[here](https://uwsgi-docs.readthedocs.io/en/latest/Configuration.html#environment-variables)

Sets `UWSGI_LISTEN=1024` by default, but can be overwritten or
completely removed by `uwsgi: null`

Or is it better to not specify default value (it's not backward
compatible)?

Also, small indentation fixes for postgresql configuration.

## Which issue(s) this PR fixes

closes #562

Also, [this PR](#856) has been
closed because of this PR

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)

Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
  • Loading branch information
alexintech and joeyorlando authored May 29, 2023
1 parent 4ebc723 commit 8049b50
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 9 deletions.
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

0 comments on commit 8049b50

Please sign in to comment.