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.
![digraph {
label="Normal Operations (v3.0)"
subgraph cluster_git {
label="Git repository"
r300 [ label="releases/3.0", shape="hexagon" ]
}
prod [ label="prod (v3.0)" ]
test [ label="test (v3.0)" ]
r300 -> test [ style=dotted ]
test -> prod [ style=dotted ]
}](../../_images/graphviz-eb6d9f63f6f303c50e4a7df01bb29375eb6a68b3.png)
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.
![digraph {
label="Migration of Test System (v3.0 → v3.5)"
subgraph cluster_git {
label="Git repository"
r300 [ label="releases/3.0", shape="hexagon" ]
r305 [ label="releases/3.5", shape="hexagon" ]
}
prod [ label="prod (v3.0)" ]
test [ label="test (v3.0)" ]
testnew [ label="testnew (v3.0 → v3.5)", color=green ]
{ rank=same test testnew }
r300 -> test [ style=dotted ]
r305 -> testnew [ color=red, fontcolor=red, label=deploy ]
test -> prod [ style=dotted ]
prod -> testnew [ color=blue, fontcolor=blue, label="copy DB" ]
}](../../_images/graphviz-942685c45f5794d9e532da5e13650d475d60b4a3.png)
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:
tco cp ${prod_installation} ${test_installation}/nice_${customer}testnew
Deploy installation ${customer}testnew
Warning
If the customer has a customer specific action or widget, it is recommended to create the “testnew” installation in the back office already one day earlier. Then the customer bundle is automatically release for the new version during the night. Else you must Manual trigger releasing with the variable
CI_RUN_AUTO_RELEASE
set to1
andCI_RELEASING_PACKAGES
set toCUSTOMER-bundle
(e.g. for the test customer it would betest-bundle
)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.
![digraph {
label="Migration of Production System (v3.0 → v3.5)"
subgraph cluster_git {
label="Git repository"
r305 [ label="releases/3.5", shape="hexagon" ]
}
prod [ label="prod (v3.0 → v3.5)" ]
test [ label="test (v3.5)" ]
testnew [ label="testnew", style=dotted ]
testold [ label="testold (v3.0)", color=green ]
{ rank=same test testnew testold }
r305 -> test [ style=dotted ]
r305 -> testnew [ style=invis ]
test -> prod [ color=red, fontcolor=red, label=deploy ]
r305 -> testold [ style=invis ]
testnew -> test [ label="rename DB", color=blue, fontcolor=blue ]
test -> testold [ label="rename DB", color=blue, fontcolor=blue ]
}](../../_images/graphviz-7176f0d83b842c381099e583dabe47af603b6be8.png)
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:
tco db-rename ${customer}test ${customer}testold tco db-rename ${customer}testnew ${customer}test
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.
![digraph {
label="Returning to Normal Operations (v3.5)"
subgraph cluster_git {
label="Git repository"
r305 [ label="releases/3.5", shape=hexagon ]
}
prod [ label="prod (v3.5)" ]
test [ label="test (v3.5)" ]
testold [ style=dotted, label="testold (v3.0)" ]
{ rank=same test testold }
r305 -> test [ style=dotted ]
test -> prod [ style=dotted ]
}](../../_images/graphviz-27974021bc134cb3086fdc6d0d73b56f1d2aa2d4.png)
Instructions¶
Remove ${customer}testold
Skip removal of DNS record [1].
Footnotes