From 59858c08677d8a633bbb1cbaf4b0dc5504595d5f Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 23 Dec 2016 10:01:09 -0500 Subject: [PATCH] Allow db sync timeouts to be configurable As Openstack projects continue to have longer database migration chains, the Puppet default timeout of 300 seconds for an execution is becoming too short a duration on some hardware, leading to timeouts. As projects continue to add more migration scripts without "pruning" the base, timeouts will continue to become more frequent unless this time can be expanded. The proposed change adds a configuration option db_sync_timeout which maintains the Puppet default of 300 but allows TripleO to change the timeout to something higher. Change-Id: I6b30a4d9e3ca25d9a473e4eb614a8769fa4567e7 --- manifests/db/sync.pp | 8 +++++- manifests/db/sync_api.pp | 10 ++++++-- .../add_db_sync_timeout-88f19f3a5c9f8a42.yaml | 3 +++ spec/classes/nova_db_sync_api_spec.rb | 23 +++++++++++++++++ spec/classes/nova_db_sync_spec.rb | 25 +++++++++++++++++++ 5 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/add_db_sync_timeout-88f19f3a5c9f8a42.yaml diff --git a/manifests/db/sync.pp b/manifests/db/sync.pp index 57fa199ce..7b96090e9 100644 --- a/manifests/db/sync.pp +++ b/manifests/db/sync.pp @@ -9,8 +9,13 @@ # 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::sync( - $extra_params = undef, + $extra_params = undef, + $db_sync_timeout = 300, ) { include ::nova::deps @@ -21,6 +26,7 @@ class nova::db::sync( refreshonly => true, try_sleep => 5, tries => 10, + timeout => $db_sync_timeout, logoutput => on_failure, subscribe => [ Anchor['nova::install::end'], diff --git a/manifests/db/sync_api.pp b/manifests/db/sync_api.pp index d09e661bc..962331b39 100644 --- a/manifests/db/sync_api.pp +++ b/manifests/db/sync_api.pp @@ -14,9 +14,14 @@ # with nova-manage. # Defaults to true. # +# [*db_sync_timeout*] +# (optional) Timeout for the execution of the db_sync +# Defaults to 300. +# class nova::db::sync_api( - $extra_params = undef, - $cellv2_setup = true, + $extra_params = undef, + $db_sync_timeout = 300, + $cellv2_setup = true, ) { include ::nova::deps @@ -27,6 +32,7 @@ class nova::db::sync_api( refreshonly => true, try_sleep => 5, tries => 10, + timeout => $db_sync_timeout, logoutput => on_failure, subscribe => [ Anchor['nova::install::end'], diff --git a/releasenotes/notes/add_db_sync_timeout-88f19f3a5c9f8a42.yaml b/releasenotes/notes/add_db_sync_timeout-88f19f3a5c9f8a42.yaml new file mode 100644 index 000000000..f9010277a --- /dev/null +++ b/releasenotes/notes/add_db_sync_timeout-88f19f3a5c9f8a42.yaml @@ -0,0 +1,3 @@ +--- +features: + - Adds db_sync_timeout parameter to nova db sync and nova db sync_api diff --git a/spec/classes/nova_db_sync_api_spec.rb b/spec/classes/nova_db_sync_api_spec.rb index d1bb1b319..8dae60fb4 100644 --- a/spec/classes/nova_db_sync_api_spec.rb +++ b/spec/classes/nova_db_sync_api_spec.rb @@ -8,6 +8,7 @@ describe 'nova::db::sync_api' do is_expected.to contain_exec('nova-db-sync-api').with( :command => '/usr/bin/nova-manage api_db sync', :refreshonly => 'true', + :timeout => 300, :logoutput => 'on_failure', :subscribe => ['Anchor[nova::install::end]', 'Anchor[nova::config::end]', @@ -30,6 +31,7 @@ describe 'nova::db::sync_api' do is_expected.to contain_exec('nova-db-sync-api').with( :command => '/usr/bin/nova-manage --config-file /etc/nova/nova.conf api_db sync', :refreshonly => 'true', + :timeout => 300, :logoutput => 'on_failure', :subscribe => ['Anchor[nova::install::end]', 'Anchor[nova::config::end]', @@ -39,6 +41,27 @@ describe 'nova::db::sync_api' do } it { is_expected.to_not contain_class('nova::db::sync_cell_v2') } end + + context "overriding db_sync_timeout" do + let :params do + { + :db_sync_timeout => 750 + } + end + + it { + is_expected.to contain_exec('nova-db-sync-api').with( + :command => '/usr/bin/nova-manage api_db sync', + :refreshonly => 'true', + :timeout => 750, + :logoutput => 'on_failure', + :subscribe => ['Anchor[nova::install::end]', + 'Anchor[nova::config::end]', + 'Anchor[nova::dbsync_api::begin]'], + :notify => 'Anchor[nova::dbsync_api::end]', + ) + } + end end diff --git a/spec/classes/nova_db_sync_spec.rb b/spec/classes/nova_db_sync_spec.rb index 8487f7540..43cf16472 100644 --- a/spec/classes/nova_db_sync_spec.rb +++ b/spec/classes/nova_db_sync_spec.rb @@ -10,6 +10,7 @@ describe 'nova::db::sync' do :refreshonly => 'true', :try_sleep => 5, :tries => 10, + :timeout => 300, :logoutput => 'on_failure', :subscribe => ['Anchor[nova::install::end]', 'Anchor[nova::config::end]', @@ -31,6 +32,30 @@ describe 'nova::db::sync' do :refreshonly => 'true', :try_sleep => 5, :tries => 10, + :timeout => 300, + :logoutput => 'on_failure', + :subscribe => ['Anchor[nova::install::end]', + 'Anchor[nova::config::end]', + 'Anchor[nova::dbsync::begin]'], + :notify => 'Anchor[nova::dbsync::end]', + ) + } + end + + describe "overriding db_sync_timeout" do + let :params do + { + :db_sync_timeout => 750, + } + end + + it { + is_expected.to contain_exec('nova-db-sync').with( + :command => '/usr/bin/nova-manage db sync', + :refreshonly => 'true', + :try_sleep => 5, + :tries => 10, + :timeout => 750, :logoutput => 'on_failure', :subscribe => ['Anchor[nova::install::end]', 'Anchor[nova::config::end]',