Closed
Bug 1464107
Opened 7 years ago
Closed 7 years ago
write a script for doing migrations in post-deploy
Categories
(Socorro :: Infra, task, P2)
Socorro
Infra
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: willkg, Assigned: willkg)
Details
Attachments
(1 file)
We run alembic and Django migrations after deploys as a post-migration step. Currently, that code is in the cloudops repo.
This bug covers writing a script that runs the migrations and have it live in the Socorro report, then fixing the deploys to use that script.
Assignee | ||
Updated•7 years ago
|
Assignee: nobody → willkg
Priority: -- → P2
Assignee | ||
Comment 1•7 years ago
|
||
We have this in the cloudops repo:
socorro::exec { 'socorro_upload_telemetry_schema':
command => "${docker} /app/socorro-cmd upload_telemetry_schema",
}
socorro::exec { 'socorro_migrate_django':
command => "${docker} /app/webapp-django/manage.py migrate --no-input",
onlyif => "${docker} /app/webapp-django/manage.py showmigrations | grep -qF '[ ]'",
}
socorro::exec { 'socorro_migrate_alembic':
command => "${docker} alembic -c docker/config/alembic.ini upgrade head",
unless => "${docker} alembic -c docker/config/alembic.ini current | grep -qF '(head)'",
}
Both migration systems are idempotent and won't do anything if there's nothing to do, so running them every time is fine. I'll write a script to do that now.
Comment 2•7 years ago
|
||
Nice idea!
Running these commands in a python script with access to your code and settings would let you report errors in them to sentry, in case you prefer that to datadog events.
Assignee | ||
Comment 3•7 years ago
|
||
Oh, that's an interesting idea. That's probably easier than datadog events.
This blog post covers sending things to Sentry via bash:
https://blog.sentry.io/2017/11/28/sentry-bash
That seems pretty straight-forward.
Assignee | ||
Comment 4•7 years ago
|
||
Assignee | ||
Comment 5•7 years ago
|
||
Here's the docs for sentry-cli:
https://docs.sentry.io/learn/cli/send-event/
and:
https://docs.sentry.io/learn/cli/send-event/#bash-hook
Comment 6•7 years ago
|
||
Commits pushed to master at https://github.com/mozilla-services/socorro
https://github.com/mozilla-services/socorro/commit/c04df654f46c040cd6faedf6cafc63a604aec23c
fix bug 1464107: add script to run migrations
This codifies all the migration stuff in a single script which we'll run
as a post-deploy script.
This adds curl and gawk to the Ubuntu setup. We need curl for installing
sentry-cli and we need gawk because it's the version of awk that sentry-cli
uses.
This also adds the sentry-cli to the crontabber container. This enables
us to send errors in bash scripts to Sentry.
https://github.com/mozilla-services/socorro/commit/2519cf9d88c80620374f0f20ed4ce7ede26c8579
Merge pull request #4461 from willkg/1464107-migration-script
fix bug 1464107: add script to run migrations
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Comment 7•7 years ago
|
||
willkg, are we ready for me to change the relevant puppet code to
socorro::exec { 'socorro_upload_telemetry_schema':
command => "${docker} /app/socorro-cmd upload_telemetry_schema",
}
socorro::exec { 'socorro_run_migrations':
command => "${docker} /app/scripts/run_migrations.sh",
}
?
Assignee | ||
Comment 8•7 years ago
|
||
Brian: I was thinking we'd wait for this to get to -stage, then test it out there, then we could adjust the puppet script.
To test it on stage, we'd want to do the following:
1. Run:
${docker} /app/scripts/run_migrations.sh
* Does it kick up any errors? It shouldn't.
* Does it show that migration state is fine? It should.
* Does it show a datestamp? It should.
2. Edit the script changing "alembic" to "lembic" (which doesn't exist) and run the script.
* Does it kick up an error? It should.
* Does it send an error to Sentry? It should.
Can you do that when you have a moment today?
Status: RESOLVED → REOPENED
Flags: needinfo?(bpitts)
Resolution: FIXED → ---
Comment 10•7 years ago
|
||
Output for 1:
RAVEN_DSN defined--enabling sentry.
Mon Jun 4 16:46:43 UTC 2018
DatadogMetrics configured: localhost:8125 None
Operations to perform:
Apply all migrations: admin, auth, contenttypes, eventlog, sessions, status, symbols, tokens, waffle
Running migrations:
No migrations to apply.
Creating Socorro permissions:
Creating Socorro groups:
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
Output for 2:
RAVEN_DSN defined--enabling sentry.
Mon Jun 4 16:44:47 UTC 2018
scripts/run_migrations.sh: line 26: python4: command not found
and it's in sentry at https://sentry.prod.mozaws.net/operations/socorro-new-stage/issues/4374649/
Assignee | ||
Comment 11•7 years ago
|
||
That's awesome! Seems good to go to me.
Comment 12•7 years ago
|
||
Puppet side was merged in https://github.com/mozilla-services/cloudops-deployment/pull/2080 so this should be good to close.
Assignee | ||
Comment 13•7 years ago
|
||
Yay us! Marking as fixed!
Status: REOPENED → RESOLVED
Closed: 7 years ago → 7 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•