From 2e08dfc0cd0e5696afa189737e6de5503aa993d3 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Fri, 4 Aug 2023 02:30:06 +0900 Subject: [PATCH] conductor: Remove redundant if check We changed the default value from undef to os_worker fact very long ago[1] but kept the if logic. Because the logic is no longer really required(in case undef is used then it's omitted by puppet), let's remove it to simplify the logic. [1] 9fe9b56aebe01f2e043363c8df8394713602005b Change-Id: I706ad61b10bb914d29092eeb5090ba702857836f --- manifests/conductor.pp | 7 +------ spec/classes/nova_conductor_spec.rb | 10 +++++++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/manifests/conductor.pp b/manifests/conductor.pp index d99944311..cc6d6d88a 100644 --- a/manifests/conductor.pp +++ b/manifests/conductor.pp @@ -48,13 +48,8 @@ class nova::conductor( ensure_package => $ensure_package, } - if $workers { - nova_config { - 'conductor/workers': value => $workers; - } - } - nova_config { + 'conductor/workers': value => $workers; 'DEFAULT/enable_new_services': value => $enable_new_services } } diff --git a/spec/classes/nova_conductor_spec.rb b/spec/classes/nova_conductor_spec.rb index f1eb3569f..e827146f7 100644 --- a/spec/classes/nova_conductor_spec.rb +++ b/spec/classes/nova_conductor_spec.rb @@ -41,11 +41,15 @@ describe 'nova::conductor' do )} end + context 'with default workers parameter' do + it { is_expected.to contain_nova_config('conductor/workers').with_value(2) } + end + context 'with overridden workers parameter' do let :params do - {:workers => '5' } + {:workers => 5 } end - it { is_expected.to contain_nova_config('conductor/workers').with_value('5') } + it { is_expected.to contain_nova_config('conductor/workers').with_value(5) } end context 'with default enable_new_services parameter' do @@ -67,7 +71,7 @@ describe 'nova::conductor' do }).each do |os,facts| context "on #{os}" do let (:facts) do - facts.merge!(OSDefaults.get_facts()) + facts.merge!(OSDefaults.get_facts({ :os_workers => 2 })) end let (:platform_params) do