Skip to content

Commit

Permalink
Added resources limits definition for wait-for-db container (#2501)
Browse files Browse the repository at this point in the history
# What this PR does
Added 'resources limits' definition for wait-for-db container

## Which issue(s) this PR fixes

I face a problem: when i install OnCall by Helm, my pods with
oncall-engine and oncall-celery stuck on Init state, because they don't
have enough resources to run.

## Checklist

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

---------

Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
Co-authored-by: Joey Orlando <joseph.t.orlando@gmail.com>
  • Loading branch information
3 people authored Jul 12, 2023
1 parent 79fc529 commit 939590f
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Added

- [Helm] Added ability to specify `resources` definition within the `wait-for-db` init container by @Shelestov7
([#2501](https://github.com/grafana/oncall/pull/2501))

### Changed

- Deprecated `/maintenance` web UI page. Maintenance is now handled at the integration level and can be performed
Expand Down
4 changes: 4 additions & 0 deletions helm/oncall/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ Create the name of the service account to use
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 }}
resources:
{{ toYaml .Values.init.resources | nindent 4 }}
env:
{{- include "snippet.oncall.env" . | nindent 4 }}
{{- include "snippet.mysql.env" . | nindent 4 }}
Expand All @@ -107,6 +109,8 @@ Create the name of the service account to use
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 }}
resources:
{{ toYaml .Values.init.resources | nindent 4 }}
env:
{{- include "snippet.oncall.env" . | nindent 4 }}
{{- include "snippet.postgresql.env" . | nindent 4 }}
Expand Down
28 changes: 28 additions & 0 deletions helm/oncall/tests/__snapshot__/wait_for_db_test.yaml.snap
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ database.type=mysql -> should create initContainer for MySQL database (default):
image: grafana/oncall:v1.2.36
imagePullPolicy: Always
name: wait-for-db
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
securityContext: {}
2: |
- command:
Expand Down Expand Up @@ -144,6 +151,13 @@ database.type=mysql -> should create initContainer for MySQL database (default):
image: grafana/oncall:v1.2.36
imagePullPolicy: Always
name: wait-for-db
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
securityContext: {}
database.type=postgresql -> should create initContainer for PostgreSQL database:
1: |
Expand Down Expand Up @@ -220,6 +234,13 @@ database.type=postgresql -> should create initContainer for PostgreSQL database:
image: grafana/oncall:v1.2.36
imagePullPolicy: Always
name: wait-for-db
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
securityContext: {}
2: |
- command:
Expand Down Expand Up @@ -295,4 +316,11 @@ database.type=postgresql -> should create initContainer for PostgreSQL database:
image: grafana/oncall:v1.2.36
imagePullPolicy: Always
name: wait-for-db
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
securityContext: {}
15 changes: 15 additions & 0 deletions helm/oncall/tests/wait_for_db_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ chart:
appVersion: v1.2.36
tests:
- it: database.type=mysql -> should create initContainer for MySQL database (default)
set:
init.resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
asserts:
- contains:
path: spec.template.spec.initContainers
Expand All @@ -26,6 +34,13 @@ tests:
set:
database.type: postgresql
externalPostgresql.host: some-postgresql-host
init.resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
asserts:
- contains:
path: spec.template.spec.initContainers
Expand Down
7 changes: 7 additions & 0 deletions helm/oncall/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -422,3 +422,10 @@ init:
# runAsGroup: 1337
# runAsNonRoot: true
# runAsUser: 1337
resources: {}
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

0 comments on commit 939590f

Please sign in to comment.