helm-charts
helm-charts copied to clipboard
feat: optionally run migrations as an init contianer
As covered in a few other issues and PRs, there's a deadlock situation with the chart when deploying with helm --wait and/or ArgoCD:
- The OpenFGA Pod won't start until the migrations have been applied
- The Migration Job applies the migrations, and is configured as a Helm Hook
- When using
helm --wait(or ArgoCD) hooks aren't run until all Pods are healthy - Deadlock: Job won't start because the Pod isn't healthy yet, Pod will never become healthy until the Job runs
Description
This PR introduces an alternative mechanism for running the migrations: an init container on the OpenFGA pod. Instead of waiting for a Job to run, the migrations are ran when the Pod first starts as an init container.
A new migrationType value is added, which can be set to job or initContainer and defaults to job (so is a backwards-compatible change). If set to job the chart behaves as it currently does, but if set to initContainer then the following happens:
- the Job is not created
- the
wait-for-containerinit container is not included on the Deployment - a new
migrate-databaseinit container is included instead
References
- https://github.com/openfga/helm-charts/issues/100
- https://github.com/openfga/helm-charts/issues/120
- https://github.com/openfga/helm-charts/issues/131
- https://github.com/openfga/helm-charts/pull/99
- https://github.com/openfga/helm-charts/pull/138
Review Checklist
- [x] I have clicked on "allow edits by maintainers".
- [ ] I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
- [x] The correct base branch is being used, if not
main - [ ] I have added tests to validate that the change in functionality is working as expected