Run online data migrations

We always run DB sync in deploy_tasks, ensuring that the database is
up to date. We should follow up with online data migrations
too.

Doing this via docker_config has 2 purposes:

* We can easily ensure this happens in a container with the right
  config files mounted.

* We can even apply this via a minor update. This is important because
  we'll have to backport this all the way to Pike and apply it there
  using Pike containers, before upgrading to Queens containers.

There's an additional issue to consider: In Puppet service variant we
ran the online migrations for release X before upgrading to X+1, but
the proposed Docker variant migrations for X run with upgrade to
X. This means that when switching from non-containerized to
containerized, we'll need to run migrations twice, to correctly switch
between the aforementioned approaches.

Change-Id: I2eb6c7c42d7e7aea4a78a892790e42bc5371f792
Closes-Bug: #1790474
(cherry picked from commit 16405ff928)
(cherry picked from commit f2680ceb71)
This commit is contained in:
Jiri Stransky 2018-09-03 12:32:53 +02:00
parent 6b46b44973
commit dded2d427c
4 changed files with 96 additions and 1 deletions

View File

@ -116,7 +116,7 @@ Steps correlate to the following:
a) step 4 baremetal
b) step 4 containers
c) Keystone containers post initialization (tenant,service,endpoint creation)
5) Service activation (Pacemaker)
5) Service activation (Pacemaker), online data migration
a) step 5 baremetal
b) step 5 containers

View File

@ -168,6 +168,26 @@ outputs:
- ''
environment:
- KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
step_5:
cinder_api_online_migrations:
start_order: 2
image: *cinder_api_image
net: host
privileged: false
detach: false
user: root
volumes:
list_concat:
- {get_attr: [ContainersCommon, volumes]}
-
- /var/lib/config-data/cinder/etc/my.cnf.d/tripleo.cnf:/etc/my.cnf.d/tripleo.cnf:ro
- /var/lib/config-data/cinder/etc/cinder/:/etc/cinder/:ro
- /var/log/containers/cinder:/var/log/cinder
- /var/log/containers/httpd/cinder-api:/var/log/httpd
command:
- '/usr/bin/bootstrap_host_exec'
- 'cinder_api'
- "su cinder -s /bin/bash -c 'cinder-manage db online_data_migrations'"
cinder_api_cron:
image: *cinder_api_image
net: host
@ -206,6 +226,11 @@ outputs:
- when: step|int == 0
tags: common
block:
- name: get bootstrap nodeid
command: hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid
register: bootstrap_node
- name: set is_bootstrap_node fact
set_fact: is_bootstrap_node={{bootstrap_node.stdout|lower == ansible_hostname|lower}}
- name: Check is cinder_api is deployed
command: systemctl is-enabled openstack-cinder-api
ignore_errors: True
@ -217,6 +242,18 @@ outputs:
shell: systemctl is-active --quiet openstack-cinder-api
when: cinder_api_enabled|bool
tags: validation
# NOTE: In puppet service variant, we ran release N online
# migrations before upgrade to release N+1. In docker
# service variant, we run release N online migrations
# after upgrade to release N. This means that during
# switch from non-containerized to containerized, we need
# to run both of these.
- name: Online data migration for Cinder before switching to containers
tags: pre-upgrade
when:
- is_bootstrap_node|bool
- cinder_api_enabled|bool
command: cinder-manage db online_data_migrations
- when: step|int == 2
block:
- name: Stop and disable cinder_api service (pre-upgrade not under httpd)

View File

@ -135,6 +135,22 @@ outputs:
- /var/log/containers/httpd/ironic-api:/var/log/httpd
environment:
- KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
step_5:
ironic_online_migrations:
start_order: 2
image: *ironic_api_image
net: host
privileged: false
detach: false
user: root
volumes:
list_concat:
- {get_attr: [ContainersCommon, volumes]}
-
- /var/lib/config-data/ironic_api/etc/ironic:/etc/ironic:ro
- /var/log/containers/ironic:/var/log/ironic
- /var/log/containers/httpd/ironic-api:/var/log/httpd
command: "/usr/bin/bootstrap_host_exec ironic_api su ironic -s /bin/bash -c 'ironic-dbsync --config-file /etc/ironic/ironic.conf online_data_migrations'"
host_prep_tasks:
- name: create persistent logs directory
file:
@ -154,6 +170,11 @@ outputs:
- when: step|int == 0
tags: common
block:
- name: get bootstrap nodeid
command: hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid
register: bootstrap_node
- name: set is_bootstrap_node fact
set_fact: is_bootstrap_node={{bootstrap_node.stdout|lower == ansible_hostname|lower}}
- name: Check if ironic_api is deployed
command: systemctl is-enabled --quiet openstack-ironic-api
ignore_errors: True
@ -188,6 +209,18 @@ outputs:
when:
- ironic_httpd_enabled|bool
- httpd_running|bool
# NOTE: In puppet service variant, we ran release N online
# migrations before upgrade to release N+1. In docker
# service variant, we run release N online migrations
# after upgrade to release N. This means that during
# switch from non-containerized to containerized, we need
# to run both of these.
- name: Online data migration for Ironic before switching to containers
tags: pre-upgrade
when:
- is_bootstrap_node|bool
- (ironic_httpd_enabled|bool and httpd_running|bool) or ironic_api_enabled|bool
command: ironic-dbsync --config-file /etc/ironic/ironic.conf online_data_migrations
- when: step|int == 2
block:
- name: Stop and disable ironic_api service

View File

@ -311,6 +311,14 @@ outputs:
- ''
- - 'TRIPLEO_DEPLOY_IDENTIFIER='
- {get_param: DeployIdentifier}
nova_online_migrations:
start_order: 2
image: *nova_api_image
net: host
detach: false
volumes: *nova_api_bootstrap_volumes
user: root
command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage db online_data_migrations'"
metadata_settings:
get_attr: [NovaApiBase, role_data, metadata_settings]
host_prep_tasks: {get_attr: [NovaApiLogging, host_prep_tasks]}
@ -318,6 +326,11 @@ outputs:
- when: step|int == 0
tags: common
block:
- name: get bootstrap nodeid
command: hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid
register: bootstrap_node
- name: set is_bootstrap_node fact
set_fact: is_bootstrap_node={{bootstrap_node.stdout|lower == ansible_hostname|lower}}
- name: Check if nova_api is deployed
command: systemctl is-enabled --quiet openstack-nova-api
ignore_errors: True
@ -349,6 +362,18 @@ outputs:
when:
- nova_api_httpd_enabled|bool
- httpd_running|bool
# NOTE: In puppet service variant, we ran release N online
# migrations before upgrade to release N+1. In docker
# service variant, we run release N online migrations
# after upgrade to release N. This means that during
# switch from non-containerized to containerized, we need
# to run both of these.
- name: Online data migration for Nova before switching to containers
tags: pre-upgrade
when:
- is_bootstrap_node|bool
- (nova_api_httpd_enabled|bool and httpd_running|bool) or nova_api_enabled|bool
command: nova-manage db online_data_migrations
- when: step|int == 2
block:
- name: Stop and disable nova_api service