This is an internal documentation. There is a good chance you’re looking for something else. See Disclaimer.
Migration¶
Tip
See Introduction to Deployments and Migrations for a simpler introduction to migrations.
This document describes the DevOps part of updating from one major or minor version to another.
Pre-Migration / Non-Migration State¶
When no migration is in progress, there is exatly one production and one test system.
Migration of Test¶
First, a testnew system is created and upgraded. During these phase hotfixes can still be deployed independently by deploying them to test first and then production.
Instructions¶
Create an installation named ${customer}testnew via Ansible. Copy the config from ${customer}test to ensure custom configurations are preserved. You should end up with something like this in config.yml:
example: # <-- customer # ... installations: example: # <-- production db_server: db1.example.net # <-- ${prod_db_server} # ... exampletest: # <-- pre-existing test branch: releases/1.0 env: # custom_option: example # COPY THIS db_server: db1.example.net # exampletestnew: # <-- new test system branch: releases/1.0 # <-- set this to correct (target) version env: custom_option: abc db_server: db1.example.net # <-- ${testnew_db_server}
For details see Create new Customer or Installation.
If you don’t want to replace ${customer}, ${prod_db_server} and ${test_db_server} in the following steps manually, set them as variables in your terminal:
customer=${customer} # prod_db_server=${prod_db_server} # Replace ${…} test_db_server=${test_db_server} #
Check if DNS record exists:
dig ${customer}testnew.tocco.ch
If it doesn’t (no output from
dig
), create records for both, ${customer}newtest and ${customer}testold [1]. See ${INSTALLATION_NAME}.tocco.ch.Create installation ${customer}testnew:
cd ${GIT_ROOT}/tocco ansible-playbook playbook.yml -l ${customer}testnew --skip-tags monitoring
Note
If you see errors that don’t make sense to you, make sure that your local ansible setup is according to the latest tocco docs ansible setup guide.
Copy prod database:
copy_db ${prod_db_server} nice_${customer} ${testnew_db_server} nice_${customer}testnew
See Copy Database for details about
copy_db
.Deploy installation ${customer}testnew
See Deliver (Simple)
Enable monitoring:
cd ${GIT_ROOT}/tocco ansible-playbook playbook.yml -l ${customer}testnew -t monitoring
Migration of Production¶
During this phase, the old test system is renamed testold and testnew renamed test. Once this is done, production can be upgraded to the new version.
Instructions¶
Update config.yml:
Rename ${customer}test to ${customer}testold
Rename ${customer}testnew to ${customer}test
Update or add
branch
for productionAdd
branch
for testold if missing
Example:
example: # ... installations: example: branch: releases/1.0 # <-- set to target version # ... exampletestnew: # <-- rename to 'exampletest' # ... exampletest: # <-- rename to 'exampletestold' # ... branch: release/1.0 # <-- add if missing # ...
If you don’t want to replace ${customer} and ${db_server} in the following steps manually, set them as variables in your terminal:
customer=${customer} # Replace ${…} db_server=${db_server} #
Create ${customer}testold and update configs of ${customer}test and ${customer}:
cd ${GIT_ROOT}/tocco ansible-playbook playbook.yml -l ${customer}test,${customer}testold,${customer} --skip-tags monitoring
Set downtime for ${customer}test and ${customer}testnew.
Stop test systems:
oc -n nice-${customer}test scale --replicas 0 dc/nice oc -n nice-${customer}testnew scale --replicas 0 dc/nice
Rename databases:
ssh ${db_server} psql postgres -c "\"ALTER DATABASE nice_${customer}test RENAME TO nice_${customer}testold\"" ssh ${db_server} psql nice_${customer}testold -c "\"REASSIGN OWNED BY nice_${customer}test TO nice_${customer}testold\"" ssh ${db_server} psql postgres -c "\"ALTER DATABASE nice_${customer}test_history RENAME TO nice_${customer}testold_history\"" ssh ${db_server} psql nice_${customer}testold_history -c "\"REASSIGN OWNED BY nice_${customer}test TO nice_${customer}testold\"" ssh ${db_server} psql postgres -c "\"ALTER DATABASE nice_${customer}testnew RENAME TO nice_${customer}test\"" ssh ${db_server} psql nice_${customer}test -c "\"REASSIGN OWNED BY nice_${customer}testnew TO nice_${customer}test\"" ssh ${db_server} psql postgres -c "\"ALTER DATABASE nice_${customer}testnew_history RENAME TO nice_${customer}test_history\"" ssh ${db_server} psql nice_${customer}test_history -c "\"REASSIGN OWNED BY nice_${customer}testnew TO nice_${customer}test\""
Warning
REASSIGN OWNED
will change the owner of all objects in the DB connected to matchingBY ${ROLE_NAME}
and the owner of all DBs matching. Be careful when there are other DBs that have${ROLE_NAME}
as owner!Start ${customer}test again:
oc -n nice-${customer}test scale --replicas 1 dc/nice
Remove ${customer}testnew
Skip removal of DNS record [1].
Deploy installation ${customer}test
See Deliver (Simple)
Deploy installation ${customer} (production)
See Deliver (Simple)
Deploy installation ${customer}testold
See Deliver (Simple)
Enable monitoring for testold:
cd ${GIT_ROOT}/tocco ansible-playbook playbook.yml -l ${customer}testold -t monitoring
Complete Migration¶
Weeks later, when sure it isn’t needed anymore, testold can be removed.
Instructions¶
Remove ${customer}testold
Skip removal of DNS record [1].
Footnotes