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: Migrations & related checks can be disabled #5140

Merged
merged 1 commit into from
Apr 25, 2019

Conversation

ticean
Copy link
Member

@ticean ticean commented Apr 22, 2019

Resolves N/A
Impact: minor
Type: feature

Issue

The checks that verify the migration state are important to run the application in a safe and sane way. However, in some emergency circumstances it can be necessary to disable checks so that the application may be started when the migration versions don't line up.

An example scenario might be an emergency release rollback.

Solution

Adds new environment variables to flag the migration feature.

  • MIGRATION_BYPASS_ENABLED, boolean, not required, default: false

Code changes disable migrations and checks when the flag is true.

⚠️ Running in such a mode is inherently unsafe! It is the operator's responsibility to decide if it is OK to run in this mode. The difference between the target and existing migration state should be examined carefully.

Breaking changes

None.

Testing

Flag disabled

Migrations are Enabled

  1. Ensure MIGRATION_BYPASS_ENABLED flag is false
  2. Add a migration.
  3. Migrations should run on startup.

Migration Checks are Enabled

  1. Ensure MIGRATION_BYPASS_ENABLED flag is false
  2. Add a migration.
  3. Run migration.
  4. Rollback code to older version.
  5. Migration check should run at startup. App should not start.

Flag enabled

Migrations are Disabled

  1. Ensure MIGRATION_BYPASS_ENABLED flag is true
  2. Add a migration.
  3. Migrations should not run at startup.
  4. Warning should appear in logs, "DANGER: MIGRATION_BYPASS_ENABLED is true and all migration activity is bypassed. This is a dangerous mode and may result in data corruption."

Migration Checks are Disabled

  1. Ensure MIGRATION_BYPASS_ENABLED flag is true
  2. Add a migration.
  3. Run migration.
  4. Rollback code to older version.
  5. Migration check should not run at startup. App should start.

@ticean
Copy link
Member Author

ticean commented Apr 23, 2019

Thanks for the lint fix @aldeed! I can squash the commits down to a single, signed commit once the test/lint suites pass.

Copy link
Collaborator

@brent-hoover brent-hoover left a comment

Choose a reason for hiding this comment

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

This looks good to me but we should have @manueldelreal give it a test

Copy link
Member

@manueldelreal manueldelreal left a comment

Choose a reason for hiding this comment

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

:shipit:

@brent-hoover
Copy link
Collaborator

@ticean Sign your commits and let's get this merged. 🎉

@aldeed
Copy link
Contributor

aldeed commented Apr 24, 2019

Oops, sorry I did the lint fix on github and forgot to add my signature. A signed squash sounds good @ticean

The checks that verify the migration state are important to run the
application in a safe and sane way. However, in some emergency
circumstances it can be necessary to disable checks so that the
application may be started when the migration versions don't line up.

An example scenario might be an emergency release rollback.

Running in such a mode is inherently unsafe! It is the operator's
responsibility to decide if it is OK to run in this mode. The difference
between the target and existing migration state should be examined
carefully.

New environment variables:

- `MIGRATION_BYPASS_ENABLED`, boolean, not required, default: false

Signed-off-by: Ticean Bennett <ticean@reactioncommerce.com>
@ticean ticean force-pushed the feat-disable-migrations-and-checks branch from a10520a to 5c25072 Compare April 24, 2019 22:34
@ticean
Copy link
Member Author

ticean commented Apr 24, 2019

All squashed with no changes. The DCO is passing.

@aldeed aldeed merged commit 93efee0 into develop Apr 25, 2019
@aldeed aldeed deleted the feat-disable-migrations-and-checks branch April 25, 2019 14:39
@jeffcorpuz jeffcorpuz mentioned this pull request Jul 2, 2019
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