From 8ac5b132e3b2ac4e71d2671de5751e349312dcaf Mon Sep 17 00:00:00 2001 From: Pranali Deore Date: Thu, 21 May 2020 10:32:40 +0530 Subject: [PATCH] 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 24ee288b85d376c96746f1f0864bfb0344cf5b19) (cherry picked from commit 311cb2ade54812d3bec0c947d1453aad47c22c3a) --- manifests/api.pp | 46 +++--- ..._prefetcher_interval-e77d98c5235e91bc.yaml | 6 + spec/classes/glance_api_spec.rb | 139 +++++++++--------- 3 files changed, 103 insertions(+), 88 deletions(-) create mode 100644 releasenotes/notes/add_cache_prefetcher_interval-e77d98c5235e91bc.yaml diff --git a/manifests/api.pp b/manifests/api.pp index dd319cbf..b530fd69 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -91,6 +91,10 @@ # (optional) If set, use this value for max_overflow with sqlalchemy. # 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*] # (optional) The upper limit (the maximum size of accumulated cache in bytes) beyond which pruner, # if running, starts cleaning the images cache. @@ -352,6 +356,7 @@ class glance::api( $database_max_retries = undef, $database_retry_interval = undef, $database_max_overflow = undef, + $cache_prefetcher_interval = $::os_service_default, $image_cache_max_size = $::os_service_default, $image_cache_stall_time = $::os_service_default, $image_cache_dir = '/var/lib/glance/image-cache', @@ -414,26 +419,27 @@ class glance::api( # basic service config glance_api_config { - 'DEFAULT/bind_host': value => $bind_host; - 'DEFAULT/bind_port': value => $bind_port; - 'DEFAULT/backlog': value => $backlog; - 'DEFAULT/workers': value => $workers; - 'DEFAULT/show_image_direct_url': value => $show_image_direct_url; - 'DEFAULT/show_multiple_locations': value => $show_multiple_locations; - 'DEFAULT/location_strategy': value => $location_strategy; - 'DEFAULT/scrub_time': value => $scrub_time; - 'DEFAULT/delayed_delete': value => $delayed_delete; - 'DEFAULT/image_cache_dir': value => $image_cache_dir; - 'DEFAULT/image_cache_stall_time': value => $image_cache_stall_time; - 'DEFAULT/image_cache_max_size': value => $image_cache_max_size; - 'DEFAULT/enabled_import_methods': value => $enabled_import_methods_real; - 'DEFAULT/node_staging_uri': value => $node_staging_uri; - 'DEFAULT/image_member_quota': value => $image_member_quota; - 'DEFAULT/enable_v1_api': value => $enable_v1_api; - 'DEFAULT/enable_v2_api': value => $enable_v2_api; - 'DEFAULT/limit_param_default': value => $limit_param_default; - 'DEFAULT/api_limit_max': value => $api_limit_max; - 'glance_store/os_region_name': value => $os_region_name; + 'DEFAULT/bind_host': value => $bind_host; + 'DEFAULT/bind_port': value => $bind_port; + 'DEFAULT/backlog': value => $backlog; + 'DEFAULT/workers': value => $workers; + 'DEFAULT/show_image_direct_url': value => $show_image_direct_url; + 'DEFAULT/show_multiple_locations': value => $show_multiple_locations; + 'DEFAULT/location_strategy': value => $location_strategy; + 'DEFAULT/scrub_time': value => $scrub_time; + 'DEFAULT/delayed_delete': value => $delayed_delete; + 'DEFAULT/cache_prefetcher_interval': value => $cache_prefetcher_interval; + 'DEFAULT/image_cache_dir': value => $image_cache_dir; + 'DEFAULT/image_cache_stall_time': value => $image_cache_stall_time; + 'DEFAULT/image_cache_max_size': value => $image_cache_max_size; + 'DEFAULT/enabled_import_methods': value => $enabled_import_methods_real; + 'DEFAULT/node_staging_uri': value => $node_staging_uri; + 'DEFAULT/image_member_quota': value => $image_member_quota; + 'DEFAULT/enable_v1_api': value => $enable_v1_api; + 'DEFAULT/enable_v2_api': value => $enable_v2_api; + 'DEFAULT/limit_param_default': value => $limit_param_default; + 'DEFAULT/api_limit_max': value => $api_limit_max; + 'glance_store/os_region_name': value => $os_region_name; } # task/taskflow_executor config. diff --git a/releasenotes/notes/add_cache_prefetcher_interval-e77d98c5235e91bc.yaml b/releasenotes/notes/add_cache_prefetcher_interval-e77d98c5235e91bc.yaml new file mode 100644 index 00000000..66076e67 --- /dev/null +++ b/releasenotes/notes/add_cache_prefetcher_interval-e77d98c5235e91bc.yaml @@ -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. diff --git a/spec/classes/glance_api_spec.rb b/spec/classes/glance_api_spec.rb index 320c504c..2cf710b0 100644 --- a/spec/classes/glance_api_spec.rb +++ b/spec/classes/glance_api_spec.rb @@ -9,84 +9,86 @@ describe 'glance::api' do let :default_params do { - :bind_host => '', - :bind_port => '9292', - :registry_host => '0.0.0.0', - :registry_port => '', - :registry_client_protocol => '', - :auth_strategy => 'keystone', - :enabled => true, - :manage_service => true, - :backlog => '', - :workers => '7', - :show_image_direct_url => '', - :show_multiple_locations => '', + :bind_host => '', + :bind_port => '9292', + :registry_host => '0.0.0.0', + :registry_port => '', + :registry_client_protocol => '', + :auth_strategy => 'keystone', + :enabled => true, + :manage_service => true, + :backlog => '', + :workers => '7', + :show_image_direct_url => '', + :show_multiple_locations => '', :filesystem_store_metadata_file => '', - :filesystem_store_file_perm => '', - :location_strategy => '', - :purge_config => false, - :delayed_delete => '', - :scrub_time => '', - :image_cache_dir => '/var/lib/glance/image-cache', - :image_import_plugins => '', + :filesystem_store_file_perm => '', + :location_strategy => '', + :purge_config => false, + :delayed_delete => '', + :scrub_time => '', + :image_cache_dir => '/var/lib/glance/image-cache', + :image_import_plugins => '', :image_conversion_output_format => '', - :inject_metadata_properties => '', - :ignore_user_roles => '', - :enabled_import_methods => '', - :node_staging_uri => '', - :image_member_quota => '', - :image_cache_stall_time => '', - :image_cache_max_size => '', - :os_region_name => 'RegionOne', - :pipeline => 'keystone', - :task_time_to_live => '', - :task_executor => '', - :task_work_dir => '', - :taskflow_engine_mode => '', - :taskflow_max_workers => '', - :conversion_format => '', - :enable_v1_api => false, - :enable_v2_api => '', - :sync_db => true, - :limit_param_default => '', - :api_limit_max => '', + :inject_metadata_properties => '', + :ignore_user_roles => '', + :enabled_import_methods => '', + :node_staging_uri => '', + :image_member_quota => '', + :image_cache_stall_time => '', + :image_cache_max_size => '', + :cache_prefetcher_interval => '', + :os_region_name => 'RegionOne', + :pipeline => 'keystone', + :task_time_to_live => '', + :task_executor => '', + :task_work_dir => '', + :taskflow_engine_mode => '', + :taskflow_max_workers => '', + :conversion_format => '', + :enable_v1_api => false, + :enable_v2_api => '', + :sync_db => true, + :limit_param_default => '', + :api_limit_max => '', } end shared_examples_for 'glance::api' do [{ - :bind_host => '127.0.0.1', - :bind_port => '9222', - :registry_host => '127.0.0.1', - :registry_port => '9111', - :registry_client_protocol => 'https', - :auth_strategy => 'not_keystone', - :enabled => false, - :backlog => '4095', - :workers => '5', - :show_image_direct_url => true, - :show_multiple_locations => true, + :bind_host => '127.0.0.1', + :bind_port => '9222', + :registry_host => '127.0.0.1', + :registry_port => '9111', + :registry_client_protocol => 'https', + :auth_strategy => 'not_keystone', + :enabled => false, + :backlog => '4095', + :workers => '5', + :show_image_direct_url => true, + :show_multiple_locations => true, :filesystem_store_metadata_file => '/etc/glance/glance-metadata-file.conf', - :filesystem_store_file_perm => '0644', - :location_strategy => 'store_type', - :delayed_delete => 'true', - :scrub_time => '10', - :image_cache_dir => '/tmp/glance', - :image_import_plugins => 'image_conversion', + :filesystem_store_file_perm => '0644', + :location_strategy => 'store_type', + :delayed_delete => 'true', + :scrub_time => '10', + :image_cache_dir => '/tmp/glance', + :image_import_plugins => 'image_conversion', :image_conversion_output_format => 'raw', - :inject_metadata_properties => 'key:val', - :ignore_user_roles => 'admin', - :enabled_import_methods => 'glance-direct,web-download', - :node_staging_uri => '/tmp/staging', - :image_member_quota => '128', - :image_cache_stall_time => '10', - :image_cache_max_size => '10737418240', - :os_region_name => 'RegionOne2', - :pipeline => 'keystone2', - :sync_db => false, - :limit_param_default => '10', - :api_limit_max => '10', + :inject_metadata_properties => 'key:val', + :ignore_user_roles => 'admin', + :enabled_import_methods => 'glance-direct,web-download', + :node_staging_uri => '/tmp/staging', + :image_member_quota => '128', + :image_cache_stall_time => '10', + :image_cache_max_size => '10737418240', + :cache_prefetcher_interval => '300', + :os_region_name => 'RegionOne2', + :pipeline => 'keystone2', + :sync_db => false, + :limit_param_default => '10', + :api_limit_max => '10', } ].each do |param_set| @@ -137,6 +139,7 @@ describe 'glance::api' do 'image_cache_dir', 'image_cache_stall_time', 'image_cache_max_size', + 'cache_prefetcher_interval', 'node_staging_uri', 'image_member_quota', 'enable_v1_api',