Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
configuration
Commits
8a80b541
Commit
8a80b541
authored
Feb 26, 2016
by
Kevin Falcone
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2801 from edx/jibsheet/migrate-multiple-databases
Jibsheet/migrate multiple databases
parents
452308b1
3fbdd6e1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
15 deletions
+51
-15
playbooks/edx-east/edxapp_migrate.yml
+22
-4
playbooks/roles/edxapp/defaults/main.yml
+3
-0
playbooks/roles/edxapp/templates/edx/bin/edxapp-migrate-cms.j2
+9
-1
playbooks/roles/edxapp/templates/edx/bin/edxapp-migrate-lms.j2
+9
-1
playbooks/roles/supervisor/files/pre_supervisor_checks.py
+5
-5
util/jenkins/check-migrations.sh
+3
-4
No files found.
playbooks/edx-east/edxapp_migrate.yml
View file @
8a80b541
...
...
@@ -4,14 +4,32 @@
gather_facts
:
False
vars
:
db_dry_run
:
"
--list"
roles
:
-
edxapp
tasks
:
-
name
:
migrate
-
name
:
migrate
lms
shell
:
>
chdir={{ edxapp_code_dir }}
python manage.py
{{ item }} migrate
--noinput {{ db_dry_run }} --settings=aws_migrate
python manage.py
lms migrate --database {{ item }}
--noinput {{ db_dry_run }} --settings=aws_migrate
environment
:
DB_MIGRATION_USER
:
"
{{
COMMON_MYSQL_MIGRATE_USER
}}"
DB_MIGRATION_PASS
:
"
{{
COMMON_MYSQL_MIGRATE_PASS
}}"
# Migrate any database in the config, but not the read_replica
when
:
item != 'read_replica'
with_items
:
-
lms
-
cms
-
"
{{
lms_auth_config.DATABASES.keys()
}}"
tags
:
-
always
-
name
:
migrate cms
shell
:
>
chdir={{ edxapp_code_dir }}
python manage.py cms migrate --database {{ item }} --noinput {{ db_dry_run }} --settings=aws_migrate
environment
:
DB_MIGRATION_USER
:
"
{{
COMMON_MYSQL_MIGRATE_USER
}}"
DB_MIGRATION_PASS
:
"
{{
COMMON_MYSQL_MIGRATE_PASS
}}"
# Migrate any database in the config, but not the read_replica
when
:
item != 'read_replica'
with_items
:
-
"
{{
cms_auth_config.DATABASES.keys()
}}"
tags
:
-
always
playbooks/roles/edxapp/defaults/main.yml
View file @
8a80b541
...
...
@@ -662,6 +662,9 @@ edxapp_generic_auth_config: &edxapp_generic_auth
ADDITIONAL_OPTIONS
:
"
{{
EDXAPP_CONTENTSTORE_ADDITIONAL_OPTS
}}"
DOC_STORE_CONFIG
:
*edxapp_generic_default_docstore
DATABASES
:
# edxapp's edxapp-migrate scripts and the edxapp_migrate play
# will ensure that any DB not named read_replica will be migrated
# for both the lms and cms.
read_replica
:
ENGINE
:
'
django.db.backends.mysql'
NAME
:
"
{{
EDXAPP_MYSQL_REPLICA_DB_NAME
}}"
...
...
playbooks/roles/edxapp/templates/edx/bin/edxapp-migrate-cms.j2
View file @
8a80b541
{% include "edxapp_common.j2" %}
sudo -E -u {{ edxapp_user }} env "PATH=$PATH" {{ edxapp_venv_bin}}/python manage.py cms migrate --noinput --settings $EDX_PLATFORM_SETTINGS
if [[ -z "$NO_EDXAPP_SUDO" ]]; then
SUDO='sudo -E -u {{ edxapp_user }} env "PATH=$PATH"'
fi
{% for db in cms_auth_config.DATABASES.keys() %}
{%- if db != 'read_replica' %}
$SUDO {{ edxapp_venv_bin}}/python manage.py cms migrate --database {{ db }} --noinput --settings $EDX_PLATFORM_SETTINGS $@
{% endif %}
{% endfor %}
playbooks/roles/edxapp/templates/edx/bin/edxapp-migrate-lms.j2
View file @
8a80b541
{% include "edxapp_common.j2" %}
sudo -E -u {{ edxapp_user }} env "PATH=$PATH" {{ edxapp_venv_bin}}/python manage.py lms migrate --noinput --settings $EDX_PLATFORM_SETTINGS
if [[ -z "$NO_EDXAPP_SUDO" ]]; then
SUDO='sudo -E -u {{ edxapp_user }} env "PATH=$PATH"'
fi
{% for db in lms_auth_config.DATABASES.keys() %}
{%- if db != 'read_replica' %}
$SUDO {{ edxapp_venv_bin}}/python manage.py lms migrate --database {{ db }} --noinput --settings $EDX_PLATFORM_SETTINGS $@
{% endif %}
{% endfor %}
playbooks/roles/supervisor/files/pre_supervisor_checks.py
View file @
8a80b541
...
...
@@ -11,8 +11,8 @@ import time
# Services that should be checked for migrations.
MIGRATION_COMMANDS
=
{
'lms'
:
"
. {env_file}; {python} {code_dir}/manage.py lms migrate --noinput --list --settings=aws
"
,
'cms'
:
"
. {env_file}; {python} {code_dir}/manage.py cms migrate --noinput --list --settings=aws
"
,
'lms'
:
"
NO_EDXAPP_SUDO=1 /edx/bin/edxapp-migrate-lms --noinput --list
"
,
'cms'
:
"
NO_EDXAPP_SUDO=1 /edx/bin/edxapp-migrate-cms --noinput --list
"
,
'xqueue'
:
"{python} {code_dir}/manage.py xqueue migrate --noinput --settings=aws --db-dry-run --merge"
,
'ecommerce'
:
". {env_file}; {python} {code_dir}/manage.py migrate --noinput --list"
,
'programs'
:
". {env_file}; {python} {code_dir}/manage.py migrate --noinput --list"
,
...
...
@@ -217,7 +217,7 @@ if __name__ == '__main__':
if
'Migrating'
in
output
:
raise
Exception
(
"Migrations have not been run for {}"
.
format
(
service
))
else
:
new_
services
=
{
services
=
{
"lms"
:
{
'python'
:
args
.
edxapp_python
,
'env_file'
:
args
.
edxapp_env
,
'code_dir'
:
args
.
edxapp_code_dir
},
"cms"
:
{
'python'
:
args
.
edxapp_python
,
'env_file'
:
args
.
edxapp_env
,
'code_dir'
:
args
.
edxapp_code_dir
},
"ecommerce"
:
{
'python'
:
args
.
ecommerce_python
,
'env_file'
:
args
.
ecommerce_env
,
'code_dir'
:
args
.
ecommerce_code_dir
},
...
...
@@ -226,8 +226,8 @@ if __name__ == '__main__':
"analytics_api"
:
{
'python'
:
args
.
analytics_api_python
,
'env_file'
:
args
.
analytics_api_env
,
'code_dir'
:
args
.
analytics_api_code_dir
}
}
if
service
in
new_services
and
all
(
arg
!=
None
for
arg
in
new_
services
[
service
]
.
values
())
and
service
in
MIGRATION_COMMANDS
:
serv_vars
=
new_
services
[
service
]
if
service
in
services
and
all
(
arg
!=
None
for
arg
in
services
[
service
]
.
values
())
and
service
in
MIGRATION_COMMANDS
:
serv_vars
=
services
[
service
]
cmd
=
MIGRATION_COMMANDS
[
service
]
.
format
(
**
serv_vars
)
if
os
.
path
.
exists
(
serv_vars
[
'code_dir'
]):
...
...
util/jenkins/check-migrations.sh
View file @
8a80b541
...
...
@@ -58,13 +58,12 @@ extra_var_args+=" -e edxapp_code_dir=${WORKSPACE}/edx-platform"
extra_var_args+
=
" -e edxapp_user=jenkins"
extra_var_args+
=
" -e EDXAPP_CFG_DIR=
${
WORKSPACE
}
"
# Generate the json configuration files
ansible-playbook
-c
local
$extra_var_args
--tags
edxapp_cfg
-i
localhost,
-s
-U
jenkins edxapp.yml
# Run migrations and replace literal '\n' with actual newlines to make the output
# easier to read
# We use the edxapp_cfg tag so that the edxapp role will generate config files but
# nothing else. The actual migrate commands are then run from the playbook.
ansible-playbook
-v
-c
local
$extra_var_args
-i
localhost,
-s
-U
jenkins edxapp_migrate.yml | sed
's/\\n/\n/g'
ansible-playbook
-v
-c
local
$extra_var_args
-
-tags
edxapp_cfg
-
i
localhost,
-s
-U
jenkins edxapp_migrate.yml | sed
's/\\n/\n/g'
#We don't care about the exit status of the `sed`
exit
${
PIPESTATUS
[0]
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment