Added ability to configure workers for watcher api

By default it will use the ::os_workers fact. ::os_workers
is based on the number of processors (currently cpu/4) but is
capped at a maximum of 8 worker processors.

Change-Id: I415794daa6305d675b9341165a3722d2c0760560
This commit is contained in:
Alex Schultz 2016-10-13 17:22:21 -06:00
parent e321519dce
commit b9651a0639
2 changed files with 23 additions and 0 deletions

View File

@ -55,6 +55,10 @@
# (Optional) Listen IP for the watcher API server. # (Optional) Listen IP for the watcher API server.
# Defaults to '0.0.0.0'. # Defaults to '0.0.0.0'.
# #
# [*watcher_api_workers*]
# (Optional) Number of worker processors to for the Watcher API service.
# Defaults to $::os_workers.
#
# [*watcher_client_default_domain_name*] # [*watcher_client_default_domain_name*]
# (Optional)domain name to use with v3 API and v2 parameters. It will # (Optional)domain name to use with v3 API and v2 parameters. It will
# be used for both the user and project domain in v3 and ignored in v2 # be used for both the user and project domain in v3 and ignored in v2
@ -127,6 +131,7 @@ class watcher::api (
$watcher_api_port = '9322', $watcher_api_port = '9322',
$watcher_api_max_limit = $::os_service_default, $watcher_api_max_limit = $::os_service_default,
$watcher_api_bind_host = '0.0.0.0', $watcher_api_bind_host = '0.0.0.0',
$watcher_api_workers = $::os_workers,
$watcher_client_default_domain_name = $::os_service_default, $watcher_client_default_domain_name = $::os_service_default,
$watcher_client_project_name = 'service', $watcher_client_project_name = 'service',
$watcher_client_certfile = $::os_service_default, $watcher_client_certfile = $::os_service_default,
@ -194,6 +199,7 @@ class watcher::api (
'api/port': value => $watcher_api_port; 'api/port': value => $watcher_api_port;
'api/max_limit': value => $watcher_api_max_limit; 'api/max_limit': value => $watcher_api_max_limit;
'api/host': value => $watcher_api_bind_host; 'api/host': value => $watcher_api_bind_host;
'api/workers': value => $watcher_api_workers;
} }
} }

View File

@ -48,6 +48,15 @@ describe 'watcher::api' do
end end
end end
context 'with default api configuration' do
it 'should configure the api configurations section when enabled' do
is_expected.to contain_watcher_config('api/port').with_value('9322')
is_expected.to contain_watcher_config('api/max_limit').with_value('<SERVICE DEFAULT>')
is_expected.to contain_watcher_config('api/host').with_value('0.0.0.0')
is_expected.to contain_watcher_config('api/workers').with_value(2)
end
end
context 'with disabled service managing' do context 'with disabled service managing' do
before do before do
params.merge!({ params.merge!({
@ -67,6 +76,14 @@ describe 'watcher::api' do
'watcher-db-manage-upgrade'], 'watcher-db-manage-upgrade'],
) )
end end
it 'should not configure the api configurations section when disabled' do
is_expected.to_not contain_watcher_config('api/port')
is_expected.to_not contain_watcher_config('api/max_limit')
is_expected.to_not contain_watcher_config('api/host')
is_expected.to_not contain_watcher_config('api/workers')
end
end end
context 'watcher clients auth section with default parameters' do context 'watcher clients auth section with default parameters' do