# What this PR does ## Issue At the first run (`helm install ...`) the migration job cannot start the container because cannot find Postgres/Redis/MySQL credentials and ServiceAccount. Workaround: set `.migrate.useHook` value to `false` for the `install` stage, and after you can switch back to `true`. This PR completely resolves this issue. ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated (doesn't violate anything) - [x] 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) - [x] It is manually tested in the internal environment --------- Co-authored-by: Joey Orlando <joey.orlando@grafana.com> Co-authored-by: Joey Orlando <joseph.t.orlando@gmail.com>
132 lines
3.8 KiB
YAML
132 lines
3.8 KiB
YAML
suite: test MySQL password envs for deployments
|
|
release:
|
|
name: oncall
|
|
templates:
|
|
- engine/deployment.yaml
|
|
- engine/job-migrate.yaml
|
|
- celery/deployment.yaml
|
|
- telegram-polling/deployment.yaml
|
|
- secrets.yaml
|
|
tests:
|
|
- it: secrets -> should fail if externalMysql.password not set
|
|
set:
|
|
mariadb.enabled: false
|
|
asserts:
|
|
- failedTemplate:
|
|
errorMessage: externalMysql.password is required if not mariadb.enabled and not externalMysql.existingSecret
|
|
template: secrets.yaml
|
|
|
|
- it: externalMySQL.password -> should create a Secret -mariadb-external
|
|
templates:
|
|
- engine/deployment.yaml
|
|
- engine/job-migrate.yaml
|
|
- celery/deployment.yaml
|
|
- telegram-polling/deployment.yaml
|
|
set:
|
|
telegramPolling.enabled: true
|
|
mariadb.enabled: false
|
|
externalMysql:
|
|
user: user123
|
|
password: abcd123
|
|
asserts:
|
|
- contains:
|
|
path: spec.template.spec.containers[0].env
|
|
content:
|
|
name: MYSQL_USER
|
|
value: user123
|
|
- contains:
|
|
path: spec.template.spec.containers[0].env
|
|
content:
|
|
name: MYSQL_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: oncall-mysql-external
|
|
key: mariadb-root-password
|
|
- containsDocument:
|
|
kind: Secret
|
|
apiVersion: v1
|
|
metadata.name: oncall-mysql-external
|
|
template: secrets.yaml
|
|
- equal:
|
|
path: data.mariadb-root-password
|
|
value: abcd123
|
|
decodeBase64: true
|
|
documentIndex: 1
|
|
template: secrets.yaml
|
|
|
|
- it: externalMysql.existingSecret -> should use existing secret
|
|
templates:
|
|
- engine/deployment.yaml
|
|
- engine/job-migrate.yaml
|
|
- celery/deployment.yaml
|
|
set:
|
|
mariadb.enabled: false
|
|
externalMysql:
|
|
existingSecret: some-mysql-secret
|
|
asserts:
|
|
- contains:
|
|
path: spec.template.spec.containers[0].env
|
|
content:
|
|
name: MYSQL_USER
|
|
value: root
|
|
- contains:
|
|
path: spec.template.spec.containers[0].env
|
|
content:
|
|
name: MYSQL_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: some-mysql-secret
|
|
key: mariadb-root-password
|
|
|
|
- it: externalMysql.usernameKey and externalMysql.passwordKey -> should be used for existing secret
|
|
templates:
|
|
- engine/deployment.yaml
|
|
- engine/job-migrate.yaml
|
|
- celery/deployment.yaml
|
|
set:
|
|
mariadb.enabled: false
|
|
externalMysql:
|
|
existingSecret: some-mysql-secret
|
|
usernameKey: mysql.user
|
|
passwordKey: mysql.key
|
|
asserts:
|
|
- contains:
|
|
path: spec.template.spec.containers[0].env
|
|
content:
|
|
name: MYSQL_USER
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: some-mysql-secret
|
|
key: mysql.user
|
|
- contains:
|
|
path: spec.template.spec.containers[0].env
|
|
content:
|
|
name: MYSQL_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: some-mysql-secret
|
|
key: mysql.key
|
|
|
|
- it: |
|
|
mariadb.enabled=false and migrate.useHook=>true -> should add "helm.sh/hook" annotations
|
|
to secret with MySQL credentials
|
|
templates:
|
|
- secrets.yaml
|
|
set:
|
|
migrate.useHook: true
|
|
mariadb.enabled: false
|
|
externalMysql:
|
|
user: user123
|
|
password: abcd123
|
|
asserts:
|
|
- containsDocument:
|
|
kind: Secret
|
|
apiVersion: v1
|
|
name: oncall-mysql-external
|
|
documentIndex: 1
|
|
- isSubset:
|
|
path: metadata.annotations
|
|
content:
|
|
"helm.sh/hook": pre-install,pre-upgrade
|
|
"helm.sh/hook-weight": "-5"
|
|
documentIndex: 1
|