diff --git a/manifests/init.pp b/manifests/init.pp index 851a02266..d282ad6fa 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -405,6 +405,24 @@ # retries on failures # Defaults to $::os_service_default # +# [*cpu_allocation_ratio*] +# (optional) Virtual CPU to physical CPU allocation ratio which affects all +# CPU filters. This can be set on the scheduler, or can be overridden +# per compute node. +# Defaults to $::os_service_default +# +# [*ram_allocation_ratio*] +# (optional) Virtual ram to physical ram allocation ratio which affects all +# ram filters. This can be set on the scheduler, or can be overridden +# per compute node. +# Defaults to $::os_service_default +# +# [*disk_allocation_ratio*] +# (optional) Virtual disk to physical disk allocation ratio which is used +# by the disk filter. This can be set on the scheduler, or can be overridden +# per compute node. +# Defaults to $::os_service_default +# # DEPRECATED PARAMETERS # # [*verbose*] @@ -503,6 +521,9 @@ class nova( $upgrade_level_network = $::os_service_default, $upgrade_level_scheduler = $::os_service_default, $use_ipv6 = $::os_service_default, + $cpu_allocation_ratio = $::os_service_default, + $ram_allocation_ratio = $::os_service_default, + $disk_allocation_ratio = $::os_service_default, $purge_config = false, # DEPRECATED PARAMETERS $verbose = undef, @@ -611,6 +632,14 @@ class nova( } } + # maintain backwards compatibility + $real_cpu_allocation_ratio = pick($::nova::scheduler::filter::cpu_allocation_ratio, $cpu_allocation_ratio) + ensure_resource('nova_config', 'DEFAULT/cpu_allocation_ratio', { value => $real_cpu_allocation_ratio }) + $real_ram_allocation_ratio = pick($::nova::scheduler::filter::ram_allocation_ratio, $ram_allocation_ratio) + ensure_resource('nova_config', 'DEFAULT/ram_allocation_ratio', { value => $real_ram_allocation_ratio }) + $real_disk_allocation_ratio = pick($::nova::scheduler::filter::disk_allocation_ratio, $disk_allocation_ratio) + ensure_resource('nova_config', 'DEFAULT/disk_allocation_ratio', { value => $real_disk_allocation_ratio }) + nova_config { 'DEFAULT/image_service': value => $image_service; 'DEFAULT/auth_strategy': value => $auth_strategy; diff --git a/manifests/scheduler/filter.pp b/manifests/scheduler/filter.pp index 1d09f1c51..6b3975d72 100644 --- a/manifests/scheduler/filter.pp +++ b/manifests/scheduler/filter.pp @@ -16,14 +16,6 @@ # (optional) defines the subset size that a host is chosen from # Defaults to '1' # -# [*cpu_allocation_ratio*] -# (optional) Virtual CPU to Physical CPU allocation ratio -# Defaults to '16.0' -# -# [*disk_allocation_ratio*] -# (optional) Virtual disk to physical disk allocation ratio -# Defaults to '1.0' -# # [*max_io_ops_per_host*] # (optional) Ignore hosts that have too many builds/resizes/snaps/migrations # Defaults to '8' @@ -40,10 +32,6 @@ # (optional) Ignore hosts that have too many instances # Defaults to '50' # -# [*ram_allocation_ratio*] -# (optional) Virtual ram to physical ram allocation ratio -# Defaults to '1.5' -# # [*scheduler_available_filters*] # (optional) Filter classes available to the scheduler # Defaults to 'nova.scheduler.filters.all_filters' @@ -64,15 +52,26 @@ # (optional) Use baremetal_scheduler_default_filters or not. # Defaults to false # +# DEPRECATED PARAMETERS +# +# [*cpu_allocation_ratio*] +# (optional) Virtual CPU to Physical CPU allocation ratio +# Defaults to undef +# +# [*ram_allocation_ratio*] +# (optional) Virtual ram to physical ram allocation ratio +# Defaults to undef +# +# [*disk_allocation_ratio*] +# (optional) Virtual disk to physical disk allocation ratio +# Defaults to undef +# class nova::scheduler::filter ( $scheduler_host_manager = 'host_manager', $scheduler_max_attempts = '3', $scheduler_host_subset_size = '1', - $cpu_allocation_ratio = '16.0', - $disk_allocation_ratio = '1.0', $max_io_ops_per_host = '8', $max_instances_per_host = '50', - $ram_allocation_ratio = '1.5', $isolated_images = $::os_service_default, $isolated_hosts = $::os_service_default, $scheduler_available_filters = 'nova.scheduler.filters.all_filters', @@ -80,6 +79,10 @@ class nova::scheduler::filter ( $scheduler_weight_classes = 'nova.scheduler.weights.all_weighers', $baremetal_scheduler_default_filters = $::os_service_default, $scheduler_use_baremetal_filters = false, + # DEPRECATED PARAMETERS + $cpu_allocation_ratio = undef, + $ram_allocation_ratio = undef, + $disk_allocation_ratio = undef, ) { include ::nova::deps @@ -113,15 +116,24 @@ class nova::scheduler::filter ( $isolated_hosts_real = $::os_service_default } + if $cpu_allocation_ratio { + warning('cpu_allocation_ratio is deprecated in nova::scheduler::filter, please add to nova::init instead') + } + + if $ram_allocation_ratio { + warning('ram_allocation_ratio is deprecated in nova::scheduler::filter, please add to nova::init instead') + } + + if $disk_allocation_ratio { + warning('disk_allocation_ratio is deprecated in nova::scheduler::filter, please add to nova::init instead') + } + nova_config { 'DEFAULT/scheduler_host_manager': value => $scheduler_host_manager; 'DEFAULT/scheduler_max_attempts': value => $scheduler_max_attempts; 'DEFAULT/scheduler_host_subset_size': value => $scheduler_host_subset_size; - 'DEFAULT/cpu_allocation_ratio': value => $cpu_allocation_ratio; - 'DEFAULT/disk_allocation_ratio': value => $disk_allocation_ratio; 'DEFAULT/max_io_ops_per_host': value => $max_io_ops_per_host; 'DEFAULT/max_instances_per_host': value => $max_instances_per_host; - 'DEFAULT/ram_allocation_ratio': value => $ram_allocation_ratio; 'DEFAULT/scheduler_available_filters': value => $scheduler_available_filters; 'DEFAULT/scheduler_weight_classes': value => $scheduler_weight_classes; 'DEFAULT/scheduler_use_baremetal_filters': value => $scheduler_use_baremetal_filters; diff --git a/releasenotes/notes/move-scheduler-ratios-to-top-level-76c6383d828e6d4a.yaml b/releasenotes/notes/move-scheduler-ratios-to-top-level-76c6383d828e6d4a.yaml new file mode 100644 index 000000000..ece4f73ca --- /dev/null +++ b/releasenotes/notes/move-scheduler-ratios-to-top-level-76c6383d828e6d4a.yaml @@ -0,0 +1,5 @@ +--- + deprecations: + - The following parameters moved from ::nova::scheduler::filter to + ::nova so they can be configured at top level - cpu_allocation_ratio, + ram_allocation_ratio and disk_allocation_ratio diff --git a/spec/classes/nova_init_spec.rb b/spec/classes/nova_init_spec.rb index fb72bd759..b5c0c64f3 100644 --- a/spec/classes/nova_init_spec.rb +++ b/spec/classes/nova_init_spec.rb @@ -63,6 +63,9 @@ describe 'nova' do is_expected.to contain_nova_config('DEFAULT/rpc_response_timeout').with_value('') is_expected.to contain_nova_config('cinder/os_region_name').with_value('') is_expected.to contain_nova_config('cinder/catalog_info').with('value' => 'volumev2:cinderv2:publicURL') + is_expected.to contain_nova_config('DEFAULT/cpu_allocation_ratio').with_value('') + is_expected.to contain_nova_config('DEFAULT/ram_allocation_ratio').with_value('') + is_expected.to contain_nova_config('DEFAULT/disk_allocation_ratio').with_value('') end it 'configures block_device_allocate params' do @@ -562,6 +565,20 @@ describe 'nova' do it { is_expected.to contain_nova_config('ssl/key_file').with_ensure('absent') } end + context 'with allocation ratios set' do + let :params do + { + :cpu_allocation_ratio => 32.0, + :ram_allocation_ratio => 2.0, + :disk_allocation_ratio => 1.5, + } + end + + it { is_expected.to contain_nova_config('DEFAULT/cpu_allocation_ratio').with_value('32.0') } + it { is_expected.to contain_nova_config('DEFAULT/ram_allocation_ratio').with_value('2.0') } + it { is_expected.to contain_nova_config('DEFAULT/disk_allocation_ratio').with_value('1.5') } + end + end diff --git a/spec/classes/nova_scheduler_filter_spec.rb b/spec/classes/nova_scheduler_filter_spec.rb index a5066cbbb..615a86846 100644 --- a/spec/classes/nova_scheduler_filter_spec.rb +++ b/spec/classes/nova_scheduler_filter_spec.rb @@ -12,11 +12,8 @@ describe 'nova::scheduler::filter' do it { is_expected.to contain_nova_config('DEFAULT/scheduler_host_manager').with_value('host_manager') } it { is_expected.to contain_nova_config('DEFAULT/scheduler_max_attempts').with_value('3') } it { is_expected.to contain_nova_config('DEFAULT/scheduler_host_subset_size').with_value('1') } - it { is_expected.to contain_nova_config('DEFAULT/cpu_allocation_ratio').with_value('16.0') } - it { is_expected.to contain_nova_config('DEFAULT/disk_allocation_ratio').with_value('1.0') } it { is_expected.to contain_nova_config('DEFAULT/max_io_ops_per_host').with_value('8') } it { is_expected.to contain_nova_config('DEFAULT/max_instances_per_host').with_value('50') } - it { is_expected.to contain_nova_config('DEFAULT/ram_allocation_ratio').with_value('1.5') } it { is_expected.to contain_nova_config('DEFAULT/scheduler_available_filters').with_value('nova.scheduler.filters.all_filters') } it { is_expected.to contain_nova_config('DEFAULT/scheduler_weight_classes').with_value('nova.scheduler.weights.all_weighers') } it { is_expected.to contain_nova_config('DEFAULT/scheduler_use_baremetal_filters').with_value(false) }