Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: optionally run migrations as an init contianer #157

Merged
merged 2 commits into from
Oct 28, 2024

Conversation

jagregory
Copy link
Contributor

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:

  1. The OpenFGA Pod won't start until the migrations have been applied
  2. The Migration Job applies the migrations, and is configured as a Helm Hook
  3. When using helm --wait (or ArgoCD) hooks aren't run until all Pods are healthy
  4. 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:

  1. the Job is not created
  2. the wait-for-container init container is not included on the Deployment
  3. a new migrate-database init container is included instead

References

Review Checklist

  • 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]
  • 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

avoid the deadlock when using migrations with helm --wait and ArgoCD
@jagregory jagregory requested review from a team as code owners September 15, 2024 23:41
@akafazov
Copy link

I run into this issue too. The PR will solve it, is there any way to speed up the review?

Copy link
Member

@rhamzeh rhamzeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @jagregory - this is a nice way to do it without breaking backward compatibility!

@MisterTimn
Copy link

Any prospect when these changes will be merged and released?

@rhamzeh rhamzeh merged commit cbf79dc into openfga:main Oct 28, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants