From 939590fe4cad8cd3e9436117ad8db74d0e34b7de Mon Sep 17 00:00:00 2001 From: Ivan Shelestov Date: Wed, 12 Jul 2023 17:30:20 +0200 Subject: [PATCH] Added resources limits definition for wait-for-db container (#2501) # 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 Co-authored-by: Joey Orlando --- CHANGELOG.md | 5 ++++ helm/oncall/templates/_helpers.tpl | 4 +++ .../__snapshot__/wait_for_db_test.yaml.snap | 28 +++++++++++++++++++ helm/oncall/tests/wait_for_db_test.yaml | 15 ++++++++++ helm/oncall/values.yaml | 7 +++++ 5 files changed, 59 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e902ca54..6b53a492 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/helm/oncall/templates/_helpers.tpl b/helm/oncall/templates/_helpers.tpl index e58f9edc..4cf593ee 100644 --- a/helm/oncall/templates/_helpers.tpl +++ b/helm/oncall/templates/_helpers.tpl @@ -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 }} @@ -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 }} diff --git a/helm/oncall/tests/__snapshot__/wait_for_db_test.yaml.snap b/helm/oncall/tests/__snapshot__/wait_for_db_test.yaml.snap index 7d764bde..fc8d400e 100644 --- a/helm/oncall/tests/__snapshot__/wait_for_db_test.yaml.snap +++ b/helm/oncall/tests/__snapshot__/wait_for_db_test.yaml.snap @@ -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: @@ -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: | @@ -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: @@ -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: {} diff --git a/helm/oncall/tests/wait_for_db_test.yaml b/helm/oncall/tests/wait_for_db_test.yaml index e43b1ef8..9a8bdf8e 100644 --- a/helm/oncall/tests/wait_for_db_test.yaml +++ b/helm/oncall/tests/wait_for_db_test.yaml @@ -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 @@ -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 diff --git a/helm/oncall/values.yaml b/helm/oncall/values.yaml index 079ae51f..63963c08 100644 --- a/helm/oncall/values.yaml +++ b/helm/oncall/values.yaml @@ -422,3 +422,10 @@ init: # runAsGroup: 1337 # runAsNonRoot: true # runAsUser: 1337 + resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi