Support [api] parameters to control queries for cell databases

This change introduces some [api] parameters, which determine how
nova-api queries cell databases to get a list of instances.

Change-Id: Ifeb7ead9c70022371202d5f4d8644c8cd0fa5019
This commit is contained in:
Takashi Kajinami 2021-11-30 08:49:49 +09:00
parent 50dd912073
commit c89ed47e96
3 changed files with 84 additions and 35 deletions

View File

@ -156,6 +156,26 @@
# (optional) Allow destination machine to match source for resize.
# Defaults to false
#
# [*instance_list_per_project_cells*]
# (optional) Only query cell databases in which the tenant has mapped
# instances
# Defaults to $::os_service_default
#
# [*instance_list_cells_batch_strategy*]
# (optional) The method by which the API queries cell databases in smaller
# batches during large instance list operations.
# Defaults to $::os_service_default
#
# [*instance_list_cells_batch_fixed_size*]
# (optional) This controlls batch size of instances requested from each cell
# database if ``instance_list_cells_batch_strategy``` is set to ``fixed``
# Defaults to $::os_service_default
#
# [*list_records_by_skipping_down_cells*]
# (optional) Whether to skip the down cells and return the results from
# the up cells.
# Defaults to $::os_service_default
#
# DEPRECATED
#
# [*nova_metadata_wsgi_enabled*]
@ -210,6 +230,10 @@ class nova::api(
$enable_instance_password = $::os_service_default,
$password_length = $::os_service_default,
$allow_resize_to_same_host = false,
$instance_list_per_project_cells = $::os_service_default,
$instance_list_cells_batch_strategy = $::os_service_default,
$instance_list_cells_batch_fixed_size = $::os_service_default,
$list_records_by_skipping_down_cells = $::os_service_default,
# DEPRECATED PARAMETER
$nova_metadata_wsgi_enabled = false,
$install_cinder_client = undef,
@ -317,21 +341,25 @@ as a standalone service, or httpd for being run by a httpd server")
}
nova_config {
'DEFAULT/enabled_apis': value => join($enabled_apis_real, ',');
'wsgi/api_paste_config': value => $api_paste_config;
'DEFAULT/osapi_compute_listen': value => $api_bind_address;
'DEFAULT/osapi_compute_listen_port': value => $osapi_compute_listen_port;
'DEFAULT/osapi_compute_workers': value => $osapi_compute_workers;
'DEFAULT/enable_network_quota': value => $enable_network_quota;
'DEFAULT/password_length': value => $password_length;
'api/use_forwarded_for': value => $use_forwarded_for;
'api/max_limit': value => $max_limit;
'api/compute_link_prefix': value => $compute_link_prefix;
'api/glance_link_prefix': value => $glance_link_prefix;
'api/hide_server_address_states': value => $hide_server_address_states;
'api/allow_instance_snapshots': value => $allow_instance_snapshots;
'api/enable_instance_password': value => $enable_instance_password;
'DEFAULT/allow_resize_to_same_host': value => $allow_resize_to_same_host;
'DEFAULT/enabled_apis': value => join($enabled_apis_real, ',');
'wsgi/api_paste_config': value => $api_paste_config;
'DEFAULT/osapi_compute_listen': value => $api_bind_address;
'DEFAULT/osapi_compute_listen_port': value => $osapi_compute_listen_port;
'DEFAULT/osapi_compute_workers': value => $osapi_compute_workers;
'DEFAULT/enable_network_quota': value => $enable_network_quota;
'DEFAULT/password_length': value => $password_length;
'api/use_forwarded_for': value => $use_forwarded_for;
'api/max_limit': value => $max_limit;
'api/compute_link_prefix': value => $compute_link_prefix;
'api/glance_link_prefix': value => $glance_link_prefix;
'api/hide_server_address_states': value => $hide_server_address_states;
'api/allow_instance_snapshots': value => $allow_instance_snapshots;
'api/enable_instance_password': value => $enable_instance_password;
'DEFAULT/allow_resize_to_same_host': value => $allow_resize_to_same_host;
'api/instance_list_per_project_cells': value => $instance_list_per_project_cells;
'api/instance_list_cells_batch_strategy': value => $instance_list_cells_batch_strategy;
'api/instance_list_cells_batch_fixed_size': value => $instance_list_cells_batch_fixed_size;
'api/list_records_by_skipping_down_cells': value => $list_records_by_skipping_down_cells;
}
# Added arg and if statement prevents this from being run

View File

@ -0,0 +1,9 @@
---
features:
- |
The following parameters have been added to the ``nova::api`` class.
- ``instance_list_per_project_cells``
- ``instance_list_cells_batch_strategy``
- ``instance_list_cells_batch_fixed_size``
- ``list_records_by_skipping_down_cells``

View File

@ -67,32 +67,40 @@ describe 'nova::api' do
is_expected.to contain_nova_config('api/enable_instance_password').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('DEFAULT/password_length').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('DEFAULT/allow_resize_to_same_host').with_value(false)
is_expected.to contain_nova_config('api/instance_list_per_project_cells').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('api/instance_list_cells_batch_strategy').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('api/instance_list_cells_batch_fixed_size').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('api/list_records_by_skipping_down_cells').with_value('<SERVICE DEFAULT>')
end
end
context 'with overridden parameters' do
before do
params.merge!({
:enabled => false,
:ensure_package => '2012.1-2',
:api_bind_address => '192.168.56.210',
:metadata_listen => '127.0.0.1',
:metadata_listen_port => 8875,
:osapi_compute_listen_port => 8874,
:use_forwarded_for => false,
:osapi_compute_workers => 1,
:metadata_workers => 2,
:enable_proxy_headers_parsing => true,
:max_request_body_size => '102400',
:max_limit => 1000,
:compute_link_prefix => 'https://10.0.0.1:7777/',
:glance_link_prefix => 'https://10.0.0.1:6666/',
:hide_server_address_states => 'building',
:allow_instance_snapshots => true,
:enable_network_quota => false,
:enable_instance_password => true,
:password_length => 12,
:allow_resize_to_same_host => true,
:enabled => false,
:ensure_package => '2012.1-2',
:api_bind_address => '192.168.56.210',
:metadata_listen => '127.0.0.1',
:metadata_listen_port => 8875,
:osapi_compute_listen_port => 8874,
:use_forwarded_for => false,
:osapi_compute_workers => 1,
:metadata_workers => 2,
:enable_proxy_headers_parsing => true,
:max_request_body_size => '102400',
:max_limit => 1000,
:compute_link_prefix => 'https://10.0.0.1:7777/',
:glance_link_prefix => 'https://10.0.0.1:6666/',
:hide_server_address_states => 'building',
:allow_instance_snapshots => true,
:enable_network_quota => false,
:enable_instance_password => true,
:password_length => 12,
:allow_resize_to_same_host => true,
:instance_list_per_project_cells => false,
:instance_list_cells_batch_strategy => 'distributed',
:instance_list_cells_batch_fixed_size => 100,
:list_records_by_skipping_down_cells => true,
})
end
@ -132,6 +140,10 @@ describe 'nova::api' do
is_expected.to contain_nova_config('api/enable_instance_password').with_value(true)
is_expected.to contain_nova_config('DEFAULT/password_length').with_value('12')
is_expected.to contain_nova_config('DEFAULT/allow_resize_to_same_host').with_value(true)
is_expected.to contain_nova_config('api/instance_list_per_project_cells').with_value(false)
is_expected.to contain_nova_config('api/instance_list_cells_batch_strategy').with_value('distributed')
is_expected.to contain_nova_config('api/instance_list_cells_batch_fixed_size').with_value(100)
is_expected.to contain_nova_config('api/list_records_by_skipping_down_cells').with_value(true)
end
end