Add cache prefetcher interval configuration option

As new periodic job added in glance which will run as per
interval set using 'cache_prefetcher_interval' configuration
option and fetch images which are queued for caching in cache
directory.

Enabled 'cache_prefetcher_interval' configuration option
in glance-api.conf.

Conflicts:
        manifests/api.pp
        spec/classes/glance_api_spec.rb

Change-Id: I8ece28a9b0c6f104130d817490e9ea4c2b4e7808
(cherry picked from commit 24ee288b85)
(cherry picked from commit 311cb2ade5)
This commit is contained in:
Pranali Deore 2020-05-21 10:32:40 +05:30
parent 43f3d5eab2
commit 8ac5b132e3
3 changed files with 103 additions and 88 deletions

View File

@ -91,6 +91,10 @@
# (optional) If set, use this value for max_overflow with sqlalchemy. # (optional) If set, use this value for max_overflow with sqlalchemy.
# Defaults to undef. # Defaults to undef.
# #
# [*cache_prefetcher_interval*]
# (optional) The interval in seconds to run periodic job 'cache_images'
# Defaults to $::os_service_default.
#
# [*image_cache_max_size*] # [*image_cache_max_size*]
# (optional) The upper limit (the maximum size of accumulated cache in bytes) beyond which pruner, # (optional) The upper limit (the maximum size of accumulated cache in bytes) beyond which pruner,
# if running, starts cleaning the images cache. # if running, starts cleaning the images cache.
@ -352,6 +356,7 @@ class glance::api(
$database_max_retries = undef, $database_max_retries = undef,
$database_retry_interval = undef, $database_retry_interval = undef,
$database_max_overflow = undef, $database_max_overflow = undef,
$cache_prefetcher_interval = $::os_service_default,
$image_cache_max_size = $::os_service_default, $image_cache_max_size = $::os_service_default,
$image_cache_stall_time = $::os_service_default, $image_cache_stall_time = $::os_service_default,
$image_cache_dir = '/var/lib/glance/image-cache', $image_cache_dir = '/var/lib/glance/image-cache',
@ -414,26 +419,27 @@ class glance::api(
# basic service config # basic service config
glance_api_config { glance_api_config {
'DEFAULT/bind_host': value => $bind_host; 'DEFAULT/bind_host': value => $bind_host;
'DEFAULT/bind_port': value => $bind_port; 'DEFAULT/bind_port': value => $bind_port;
'DEFAULT/backlog': value => $backlog; 'DEFAULT/backlog': value => $backlog;
'DEFAULT/workers': value => $workers; 'DEFAULT/workers': value => $workers;
'DEFAULT/show_image_direct_url': value => $show_image_direct_url; 'DEFAULT/show_image_direct_url': value => $show_image_direct_url;
'DEFAULT/show_multiple_locations': value => $show_multiple_locations; 'DEFAULT/show_multiple_locations': value => $show_multiple_locations;
'DEFAULT/location_strategy': value => $location_strategy; 'DEFAULT/location_strategy': value => $location_strategy;
'DEFAULT/scrub_time': value => $scrub_time; 'DEFAULT/scrub_time': value => $scrub_time;
'DEFAULT/delayed_delete': value => $delayed_delete; 'DEFAULT/delayed_delete': value => $delayed_delete;
'DEFAULT/image_cache_dir': value => $image_cache_dir; 'DEFAULT/cache_prefetcher_interval': value => $cache_prefetcher_interval;
'DEFAULT/image_cache_stall_time': value => $image_cache_stall_time; 'DEFAULT/image_cache_dir': value => $image_cache_dir;
'DEFAULT/image_cache_max_size': value => $image_cache_max_size; 'DEFAULT/image_cache_stall_time': value => $image_cache_stall_time;
'DEFAULT/enabled_import_methods': value => $enabled_import_methods_real; 'DEFAULT/image_cache_max_size': value => $image_cache_max_size;
'DEFAULT/node_staging_uri': value => $node_staging_uri; 'DEFAULT/enabled_import_methods': value => $enabled_import_methods_real;
'DEFAULT/image_member_quota': value => $image_member_quota; 'DEFAULT/node_staging_uri': value => $node_staging_uri;
'DEFAULT/enable_v1_api': value => $enable_v1_api; 'DEFAULT/image_member_quota': value => $image_member_quota;
'DEFAULT/enable_v2_api': value => $enable_v2_api; 'DEFAULT/enable_v1_api': value => $enable_v1_api;
'DEFAULT/limit_param_default': value => $limit_param_default; 'DEFAULT/enable_v2_api': value => $enable_v2_api;
'DEFAULT/api_limit_max': value => $api_limit_max; 'DEFAULT/limit_param_default': value => $limit_param_default;
'glance_store/os_region_name': value => $os_region_name; 'DEFAULT/api_limit_max': value => $api_limit_max;
'glance_store/os_region_name': value => $os_region_name;
} }
# task/taskflow_executor config. # task/taskflow_executor config.

View File

@ -0,0 +1,6 @@
---
features:
- |
Added cache_prefetcher_interval in glance-api.conf,
using which the periodic job will run as per the set
interval and prefetch images into cache.

View File

@ -9,84 +9,86 @@ describe 'glance::api' do
let :default_params do let :default_params do
{ {
:bind_host => '<SERVICE DEFAULT>', :bind_host => '<SERVICE DEFAULT>',
:bind_port => '9292', :bind_port => '9292',
:registry_host => '0.0.0.0', :registry_host => '0.0.0.0',
:registry_port => '<SERVICE DEFAULT>', :registry_port => '<SERVICE DEFAULT>',
:registry_client_protocol => '<SERVICE DEFAULT>', :registry_client_protocol => '<SERVICE DEFAULT>',
:auth_strategy => 'keystone', :auth_strategy => 'keystone',
:enabled => true, :enabled => true,
:manage_service => true, :manage_service => true,
:backlog => '<SERVICE DEFAULT>', :backlog => '<SERVICE DEFAULT>',
:workers => '7', :workers => '7',
:show_image_direct_url => '<SERVICE DEFAULT>', :show_image_direct_url => '<SERVICE DEFAULT>',
:show_multiple_locations => '<SERVICE DEFAULT>', :show_multiple_locations => '<SERVICE DEFAULT>',
:filesystem_store_metadata_file => '<SERVICE DEFAULT>', :filesystem_store_metadata_file => '<SERVICE DEFAULT>',
:filesystem_store_file_perm => '<SERVICE DEFAULT>', :filesystem_store_file_perm => '<SERVICE DEFAULT>',
:location_strategy => '<SERVICE DEFAULT>', :location_strategy => '<SERVICE DEFAULT>',
:purge_config => false, :purge_config => false,
:delayed_delete => '<SERVICE DEFAULT>', :delayed_delete => '<SERVICE DEFAULT>',
:scrub_time => '<SERVICE DEFAULT>', :scrub_time => '<SERVICE DEFAULT>',
:image_cache_dir => '/var/lib/glance/image-cache', :image_cache_dir => '/var/lib/glance/image-cache',
:image_import_plugins => '<SERVICE DEFAULT>', :image_import_plugins => '<SERVICE DEFAULT>',
:image_conversion_output_format => '<SERVICE DEFAULT>', :image_conversion_output_format => '<SERVICE DEFAULT>',
:inject_metadata_properties => '<SERVICE DEFAULT>', :inject_metadata_properties => '<SERVICE DEFAULT>',
:ignore_user_roles => '<SERVICE DEFAULT>', :ignore_user_roles => '<SERVICE DEFAULT>',
:enabled_import_methods => '<SERVICE DEFAULT>', :enabled_import_methods => '<SERVICE DEFAULT>',
:node_staging_uri => '<SERVICE DEFAULT>', :node_staging_uri => '<SERVICE DEFAULT>',
:image_member_quota => '<SERVICE DEFAULT>', :image_member_quota => '<SERVICE DEFAULT>',
:image_cache_stall_time => '<SERVICE DEFAULT>', :image_cache_stall_time => '<SERVICE DEFAULT>',
:image_cache_max_size => '<SERVICE DEFAULT>', :image_cache_max_size => '<SERVICE DEFAULT>',
:os_region_name => 'RegionOne', :cache_prefetcher_interval => '<SERVICE DEFAULT>',
:pipeline => 'keystone', :os_region_name => 'RegionOne',
:task_time_to_live => '<SERVICE DEFAULT>', :pipeline => 'keystone',
:task_executor => '<SERVICE DEFAULT>', :task_time_to_live => '<SERVICE DEFAULT>',
:task_work_dir => '<SERVICE DEFAULT>', :task_executor => '<SERVICE DEFAULT>',
:taskflow_engine_mode => '<SERVICE DEFAULT>', :task_work_dir => '<SERVICE DEFAULT>',
:taskflow_max_workers => '<SERVICE DEFAULT>', :taskflow_engine_mode => '<SERVICE DEFAULT>',
:conversion_format => '<SERVICE DEFAULT>', :taskflow_max_workers => '<SERVICE DEFAULT>',
:enable_v1_api => false, :conversion_format => '<SERVICE DEFAULT>',
:enable_v2_api => '<SERVICE DEFAULT>', :enable_v1_api => false,
:sync_db => true, :enable_v2_api => '<SERVICE DEFAULT>',
:limit_param_default => '<SERVICE DEFAULT>', :sync_db => true,
:api_limit_max => '<SERVICE DEFAULT>', :limit_param_default => '<SERVICE DEFAULT>',
:api_limit_max => '<SERVICE DEFAULT>',
} }
end end
shared_examples_for 'glance::api' do shared_examples_for 'glance::api' do
[{ [{
:bind_host => '127.0.0.1', :bind_host => '127.0.0.1',
:bind_port => '9222', :bind_port => '9222',
:registry_host => '127.0.0.1', :registry_host => '127.0.0.1',
:registry_port => '9111', :registry_port => '9111',
:registry_client_protocol => 'https', :registry_client_protocol => 'https',
:auth_strategy => 'not_keystone', :auth_strategy => 'not_keystone',
:enabled => false, :enabled => false,
:backlog => '4095', :backlog => '4095',
:workers => '5', :workers => '5',
:show_image_direct_url => true, :show_image_direct_url => true,
:show_multiple_locations => true, :show_multiple_locations => true,
:filesystem_store_metadata_file => '/etc/glance/glance-metadata-file.conf', :filesystem_store_metadata_file => '/etc/glance/glance-metadata-file.conf',
:filesystem_store_file_perm => '0644', :filesystem_store_file_perm => '0644',
:location_strategy => 'store_type', :location_strategy => 'store_type',
:delayed_delete => 'true', :delayed_delete => 'true',
:scrub_time => '10', :scrub_time => '10',
:image_cache_dir => '/tmp/glance', :image_cache_dir => '/tmp/glance',
:image_import_plugins => 'image_conversion', :image_import_plugins => 'image_conversion',
:image_conversion_output_format => 'raw', :image_conversion_output_format => 'raw',
:inject_metadata_properties => 'key:val', :inject_metadata_properties => 'key:val',
:ignore_user_roles => 'admin', :ignore_user_roles => 'admin',
:enabled_import_methods => 'glance-direct,web-download', :enabled_import_methods => 'glance-direct,web-download',
:node_staging_uri => '/tmp/staging', :node_staging_uri => '/tmp/staging',
:image_member_quota => '128', :image_member_quota => '128',
:image_cache_stall_time => '10', :image_cache_stall_time => '10',
:image_cache_max_size => '10737418240', :image_cache_max_size => '10737418240',
:os_region_name => 'RegionOne2', :cache_prefetcher_interval => '300',
:pipeline => 'keystone2', :os_region_name => 'RegionOne2',
:sync_db => false, :pipeline => 'keystone2',
:limit_param_default => '10', :sync_db => false,
:api_limit_max => '10', :limit_param_default => '10',
:api_limit_max => '10',
} }
].each do |param_set| ].each do |param_set|
@ -137,6 +139,7 @@ describe 'glance::api' do
'image_cache_dir', 'image_cache_dir',
'image_cache_stall_time', 'image_cache_stall_time',
'image_cache_max_size', 'image_cache_max_size',
'cache_prefetcher_interval',
'node_staging_uri', 'node_staging_uri',
'image_member_quota', 'image_member_quota',
'enable_v1_api', 'enable_v1_api',