diff --git a/manifests/deps.pp b/manifests/deps.pp index 2b2aca0..eb3dc5c 100644 --- a/manifests/deps.pp +++ b/manifests/deps.pp @@ -31,6 +31,10 @@ class cloudkitty::deps { -> Cloudkitty_api_paste_ini<||> ~> Anchor['cloudkitty::config::end'] + # all coordination settings should be applied and all packages should be + # installed before service startup + Oslo::Coordination<||> -> Anchor['cloudkitty::service::begin'] + # all db settings should be applied and all packages should be installed # before dbsync starts Oslo::Db<||> -> Anchor['cloudkitty::dbsync::begin'] diff --git a/manifests/orchestrator.pp b/manifests/orchestrator.pp new file mode 100644 index 0000000..3b8948d --- /dev/null +++ b/manifests/orchestrator.pp @@ -0,0 +1,39 @@ +# == Class: cloudkitty::orchestrator +# +# Setup and configure Cloudkitty orchestrator settings. +# +# === Parameters +# +# [*coordination_url*] +# (Optional) Coordination backend URL. +# Defaults to $::os_service_default +# +# [*max_workers*] +# (Optional) Maximal number of workers to run. +# Defaults to $::os_service_default +# +# [*max_threads*] +# (Optional) Maximal numer of threads to use per worker. +# Defaults to $::os_service_default +# +class cloudkitty::orchestrator ( + $coordination_url = $::os_service_default, + $max_workers = $::os_service_default, + $max_threads = $::os_service_default +) { + + include cloudkitty::deps + + $max_workers_real = pick($::cloudkitty::processor::max_workers, $max_workers) + + oslo::coordination{ 'cloudkitty_config': + backend_url => $coordination_url, + manage_config => false, + } + + cloudkitty_config { + 'orchestrator/coordination_url': value => $coordination_url; + 'orchestrator/max_workers': value => $max_workers_real; + 'orchestrator/max_threads': value => $max_threads; + } +} diff --git a/manifests/processor.pp b/manifests/processor.pp index cf94987..39c5107 100644 --- a/manifests/processor.pp +++ b/manifests/processor.pp @@ -52,6 +52,8 @@ # (optional) Endpoint URL type # Default to $::os_service_default # +# DEPRECATED PARAMETERS +# # [*max_workers*] # (optional) Number of max workers for processor # Default to $::os_service_default @@ -69,12 +71,18 @@ class cloudkitty::processor ( $auth_section = 'keystone_authtoken', $region_name = $::os_service_default, $interface = $::os_service_default, - $max_workers = $::os_service_default, + # DEPRECATED PARAMETERS + $max_workers = undef, ) { include cloudkitty::deps include cloudkitty::params + if $max_workers != undef { + warning('The max_workers parameter is deprecated. Use the cloudkitty::orchestrator class.') + } + include cloudkitty::orchestrator + package { 'cloudkitty-processor': ensure => $package_ensure, name => $::cloudkitty::params::processor_package_name, @@ -116,7 +124,6 @@ class cloudkitty::processor ( 'collector_gnocchi/auth_section': value => $auth_section; 'collector_gnocchi/region_name': value => $region_name; 'collector_gnocchi/interface': value => $interface; - 'orchestrator/max_workers': value => $max_workers; } } diff --git a/releasenotes/notes/orchestrator-2f9ead1187266db8.yaml b/releasenotes/notes/orchestrator-2f9ead1187266db8.yaml new file mode 100644 index 0000000..a48e0f9 --- /dev/null +++ b/releasenotes/notes/orchestrator-2f9ead1187266db8.yaml @@ -0,0 +1,9 @@ +--- +features: + - | + The new ``cloudkitty::orchestrator`` class has been added. + +deprecations: + - | + The ``cloudkitty::processor::max_workers`` parameter has been deprecated + in favor of the new ``cloudkitty::orchestrator::max_workers`` parameter. diff --git a/spec/classes/cloudkitty_orchestrator_spec.rb b/spec/classes/cloudkitty_orchestrator_spec.rb new file mode 100644 index 0000000..6be1397 --- /dev/null +++ b/spec/classes/cloudkitty_orchestrator_spec.rb @@ -0,0 +1,56 @@ +require 'spec_helper' + +describe 'cloudkitty::orchestrator' do + + shared_examples_for 'cloudkitty::orchestrator' do + + context 'with defaults' do + it { is_expected.to contain_class('cloudkitty::deps') } + + it 'configures orchestrator' do + is_expected.to contain_cloudkitty_config('orchestrator/coordination_url')\ + .with_value('') + is_expected.to contain_oslo__coordination('cloudkitty_config').with( + :backend_url => '', + :manage_config => false, + ) + is_expected.to contain_cloudkitty_config('orchestrator/max_workers').with_value('') + is_expected.to contain_cloudkitty_config('orchestrator/max_threads').with_value('') + end + end + + context 'with parameters set' do + let :params do + { + :coordination_url => 'etcd3+http://127.0.0.1:2379', + :max_workers => 4, + :max_threads => 20, + } + end + + it 'configures orchestrator' do + is_expected.to contain_cloudkitty_config('orchestrator/coordination_url')\ + .with_value('etcd3+http://127.0.0.1:2379') + is_expected.to contain_oslo__coordination('cloudkitty_config').with( + :backend_url => 'etcd3+http://127.0.0.1:2379', + :manage_config => false, + ) + is_expected.to contain_cloudkitty_config('orchestrator/max_workers').with_value(4) + is_expected.to contain_cloudkitty_config('orchestrator/max_threads').with_value(20) + 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()) + end + + it_configures 'cloudkitty::orchestrator' + end + end + +end