diff --git a/manifests/api.pp b/manifests/api.pp index 3b849ce6d..03979d876 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -65,6 +65,11 @@ # (optional) Run nova-manage api_db sync on api nodes after installing the package. # Defaults to true # +# [*db_online_data_migrations*] +# (optional) Run nova-manage db online_data_migrations on api nodes after +# installing the package - required on upgrade. +# Defaults to false. +# # [*neutron_metadata_proxy_shared_secret*] # (optional) Shared secret to validate proxies Neutron metadata requests # Defaults to undef @@ -246,6 +251,7 @@ class nova::api( $metadata_workers = $::processorcount, $sync_db = true, $sync_db_api = true, + $db_online_data_migrations = false, $neutron_metadata_proxy_shared_secret = undef, $default_floating_pool = 'nova', $pci_alias = undef, @@ -454,6 +460,9 @@ as a standalone service, or httpd for being run by a httpd server") if $sync_db_api { include ::nova::db::sync_api } + if $db_online_data_migrations { + include ::nova::db::online_data_migrations + } # Remove auth configuration from api-paste.ini nova_paste_api_ini { diff --git a/manifests/db/online_data_migrations.pp b/manifests/db/online_data_migrations.pp new file mode 100644 index 000000000..f1bfafc54 --- /dev/null +++ b/manifests/db/online_data_migrations.pp @@ -0,0 +1,39 @@ +# +# Class to execute nova api_db sync +# +# ==Parameters +# +# [*extra_params*] +# (optional) String of extra command line parameters to append +# to the nova-manage db sync command. These will be inserted in +# the command line between 'nova-manage' and 'db sync'. +# Defaults to undef +# +# [*db_sync_timeout*] +# (optional) Timeout for the execution of the db_sync +# Defaults to 300. +# +class nova::db::online_data_migrations( + $extra_params = undef, + $db_sync_timeout = 300, +) { + + include ::nova::deps + include ::nova::params + + exec { 'nova-db-online-data-migrations': + command => "/usr/bin/nova-manage ${extra_params} db online_data_migrations", + refreshonly => true, + try_sleep => 5, + tries => 10, + timeout => $db_sync_timeout, + logoutput => on_failure, + subscribe => [ + Anchor['nova::install::end'], + Anchor['nova::config::end'], + Anchor['nova::dbsync_api::end'], + Anchor['nova::db_online_data_migrations::begin'] + ], + notify => Anchor['nova::db_online_data_migrations::end'], + } +} diff --git a/manifests/deps.pp b/manifests/deps.pp index 6d57b0d54..64b66253c 100644 --- a/manifests/deps.pp +++ b/manifests/deps.pp @@ -107,4 +107,12 @@ class nova::deps { anchor { 'nova::cell_v2::end': notify => Anchor['nova::dbsync::begin'] } + + # Wedge online data migrations after db/api_sync and before service + anchor { 'nova::db_online_data_migrations::begin': + subscribe => Anchor['nova::dbsync_api::end'] + } -> + anchor { 'nova::db_online_data_migrations::end': + notify => Anchor['nova::service::begin'] + } } diff --git a/releasenotes/notes/add-nova-db-online-data-migrations-586a6f3c23dfefcb.yaml b/releasenotes/notes/add-nova-db-online-data-migrations-586a6f3c23dfefcb.yaml new file mode 100644 index 000000000..867d095ca --- /dev/null +++ b/releasenotes/notes/add-nova-db-online-data-migrations-586a6f3c23dfefcb.yaml @@ -0,0 +1,5 @@ +--- +features: + - Added a class to run the db online_data_migrations. This needs to happen + after a dbsync when you when you upgrade to Newton. More info at + https://bugs.launchpad.net/tripleo/+bug/1656791. diff --git a/spec/classes/nova_db_online_data_migrations_spec.rb b/spec/classes/nova_db_online_data_migrations_spec.rb new file mode 100644 index 000000000..89c7f5fb0 --- /dev/null +++ b/spec/classes/nova_db_online_data_migrations_spec.rb @@ -0,0 +1,89 @@ +require 'spec_helper' + +describe 'nova::db::online_data_migrations' do + + shared_examples_for 'nova-db-online-data-migrations' do + + it 'runs nova-db-sync' do + is_expected.to contain_exec('nova-db-online-data-migrations').with( + :command => '/usr/bin/nova-manage db online_data_migrations', + :refreshonly => 'true', + :try_sleep => 5, + :tries => 10, + :timeout => 300, + :logoutput => 'on_failure', + :subscribe => ['Anchor[nova::install::end]', + 'Anchor[nova::config::end]', + 'Anchor[nova::dbsync_api::end]', + 'Anchor[nova::db_online_data_migrations::begin]'], + :notify => 'Anchor[nova::db_online_data_migrations::end]', + ) + end + + describe "overriding extra_params" do + let :params do + { + :extra_params => '--config-file /etc/nova/nova.conf', + } + end + + it { + is_expected.to contain_exec('nova-db-online-data-migrations').with( + :command => '/usr/bin/nova-manage --config-file /etc/nova/nova.conf db online_data_migrations', + :refreshonly => 'true', + :try_sleep => 5, + :tries => 10, + :timeout => 300, + :logoutput => 'on_failure', + :subscribe => ['Anchor[nova::install::end]', + 'Anchor[nova::config::end]', + 'Anchor[nova::dbsync_api::end]', + 'Anchor[nova::db_online_data_migrations::begin]'], + :notify => 'Anchor[nova::db_online_data_migrations::end]', + ) + } + end + + describe "overriding db_sync_timeout" do + let :params do + { + :db_sync_timeout => 750, + } + end + + it { + is_expected.to contain_exec('nova-db-online-data-migrations').with( + :command => '/usr/bin/nova-manage db online_data_migrations', + :refreshonly => 'true', + :try_sleep => 5, + :tries => 10, + :timeout => 750, + :logoutput => 'on_failure', + :subscribe => ['Anchor[nova::install::end]', + 'Anchor[nova::config::end]', + 'Anchor[nova::dbsync_api::end]', + 'Anchor[nova::db_online_data_migrations::begin]'], + :notify => 'Anchor[nova::db_online_data_migrations::end]', + ) + } + end + + end + + + on_supported_os({ + :supported_os => OSDefaults.get_supported_os + }).each do |os,facts| + context "on #{os}" do + let (:facts) do + facts.merge(OSDefaults.get_facts({ + :processorcount => 8, + :concat_basedir => '/var/lib/puppet/concat' + })) + end + + it_configures 'nova-db-online-data-migrations' + end + end + +end