From da9e1a7f4eeb907be212b0c1ac87b625dad2bea6 Mon Sep 17 00:00:00 2001 From: PranaliD Date: Thu, 10 Sep 2020 09:59:28 +0000 Subject: [PATCH] Add sparse image upload configuration parameters Addng configuration option ``rbd_thin_provisioning`` and ``filesystem_thin_provisioning`` to rbd and filesystem backends, to enable or not sparse upload. A sparse file means that we do not actually write null byte sequences but only the data itself at a given offset, the "holes" which can appear will automatically be interpreted by the storage backend as null bytes, and do not really consume your storage. Partially Implements: blueprint handle-sparse-image Change-Id: Ic95fa45af0f1db92d8425862c6267f466764fbbe --- manifests/backend/file.pp | 20 ++++++++++++------- manifests/backend/multistore/file.pp | 14 +++++++++---- manifests/backend/multistore/rbd.pp | 6 ++++++ manifests/backend/rbd.pp | 6 ++++++ ...andling_sparse_image-0a68af239b413df1.yaml | 6 ++++++ spec/classes/glance_backend_file_spec.rb | 7 ++++++- spec/classes/glance_backend_rbd_spec.rb | 3 +++ .../glance_backend_multistore_file_spec.rb | 7 ++++++- .../glance_backend_multistore_rbd_spec.rb | 3 +++ 9 files changed, 59 insertions(+), 13 deletions(-) create mode 100644 releasenotes/notes/enable_handling_sparse_image-0a68af239b413df1.yaml diff --git a/manifests/backend/file.pp b/manifests/backend/file.pp index 2d62c225..f94af957 100644 --- a/manifests/backend/file.pp +++ b/manifests/backend/file.pp @@ -9,13 +9,18 @@ # default_store == file. # Optional. Default: /var/lib/glance/images/ # -# [*multi_store*] -# (optional) Boolean describing if multiple backends will be configured -# Defaults to false +# [*filesystem_thin_provisioning*] +# (optional) Boolean describing if thin provisioning is enabled or not +# Defaults to $::os_service_default +# +# [*multi_store*] +# (optional) Boolean describing if multiple backends will be configured +# Defaults to false # class glance::backend::file( - $filesystem_store_datadir = '/var/lib/glance/images/', - $multi_store = false, + $filesystem_store_datadir = '/var/lib/glance/images/', + $filesystem_thin_provisioning = $::os_service_default, + $multi_store = false, ) { include glance::deps @@ -23,8 +28,9 @@ class glance::backend::file( warning('glance::backend::file is deprecated. Use glance::backend::multistore::file instead.') glance::backend::multistore::file { 'glance_store': - filesystem_store_datadir => $filesystem_store_datadir, - store_description => undef, + filesystem_store_datadir => $filesystem_store_datadir, + filesystem_thin_provisioning => $filesystem_thin_provisioning, + store_description => undef, } if !$multi_store { diff --git a/manifests/backend/multistore/file.pp b/manifests/backend/multistore/file.pp index 69c64aab..9c859f24 100644 --- a/manifests/backend/multistore/file.pp +++ b/manifests/backend/multistore/file.pp @@ -23,21 +23,27 @@ # Location where dist images are stored when the backend type is file. # Defaults to $::os_service_default. # +# [*filesystem_thin_provisioning*] +# (optional) Boolean describing if thin provisioning is enabled or not +# Defaults to $::os_service_default +# # [*store_description*] # (optional) Provides constructive information about the store backend to # end users. # Defaults to $::os_service_default. # define glance::backend::multistore::file( - $filesystem_store_datadir = $::os_service_default, - $store_description = $::os_service_default, + $filesystem_store_datadir = $::os_service_default, + $filesystem_thin_provisioning = $::os_service_default, + $store_description = $::os_service_default, ) { include glance::deps glance_api_config { - "${name}/filesystem_store_datadir": value => $filesystem_store_datadir; - "${name}/store_description": value => $store_description; + "${name}/filesystem_store_datadir": value => $filesystem_store_datadir; + "${name}/filesystem_thin_provisioning": value => $filesystem_thin_provisioning; + "${name}/store_description": value => $store_description; } glance_cache_config { diff --git a/manifests/backend/multistore/rbd.pp b/manifests/backend/multistore/rbd.pp index b20880d2..0c5299d4 100644 --- a/manifests/backend/multistore/rbd.pp +++ b/manifests/backend/multistore/rbd.pp @@ -32,6 +32,10 @@ # [*rbd_store_chunk_size*] # Optional. Default: $::os_service_default. # +# [*rbd_thin_provisioning*] +# Optional. Boolean describing if thin provisioning is enabled or not +# Defaults to $::os_service_default +# # [*manage_packages*] # Optional. Whether we should manage the packages. # Defaults to true, @@ -57,6 +61,7 @@ define glance::backend::multistore::rbd( $rbd_store_ceph_conf = $::os_service_default, $rbd_store_pool = $::os_service_default, $rbd_store_chunk_size = $::os_service_default, + $rbd_thin_provisioning = $::os_service_default, $manage_packages = true, $package_ensure = 'present', $rados_connect_timeout = $::os_service_default, @@ -71,6 +76,7 @@ define glance::backend::multistore::rbd( "${name}/rbd_store_user": value => $rbd_store_user; "${name}/rbd_store_pool": value => $rbd_store_pool; "${name}/rbd_store_chunk_size": value => $rbd_store_chunk_size; + "${name}/rbd_thin_provisioning": value => $rbd_thin_provisioning; "${name}/rados_connect_timeout": value => $rados_connect_timeout; "${name}/store_description": value => $store_description; } diff --git a/manifests/backend/rbd.pp b/manifests/backend/rbd.pp index a0748912..b60474e8 100644 --- a/manifests/backend/rbd.pp +++ b/manifests/backend/rbd.pp @@ -17,6 +17,10 @@ # [*rbd_store_chunk_size*] # Optional. Default: $::os_service_default. # +# [*rbd_thin_provisioning*] +# Optional. Boolean describing if thin provisioning is enabled or not +# Defaults to $::os_service_default +# # [*manage_packages*] # Optional. Whether we should manage the packages. # Defaults to true, @@ -41,6 +45,7 @@ class glance::backend::rbd( $rbd_store_ceph_conf = $::os_service_default, $rbd_store_pool = $::os_service_default, $rbd_store_chunk_size = $::os_service_default, + $rbd_thin_provisioning = $::os_service_default, $manage_packages = true, $package_ensure = 'present', $rados_connect_timeout = $::os_service_default, @@ -57,6 +62,7 @@ class glance::backend::rbd( rbd_store_user => $rbd_store_user, rbd_store_pool => $rbd_store_pool, rbd_store_chunk_size => $rbd_store_chunk_size, + rbd_thin_provisioning => $rbd_thin_provisioning, rados_connect_timeout => $rados_connect_timeout, manage_packages => $manage_packages, package_ensure => $package_ensure, diff --git a/releasenotes/notes/enable_handling_sparse_image-0a68af239b413df1.yaml b/releasenotes/notes/enable_handling_sparse_image-0a68af239b413df1.yaml new file mode 100644 index 00000000..6399d9cb --- /dev/null +++ b/releasenotes/notes/enable_handling_sparse_image-0a68af239b413df1.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Add new configuration option 'rbd_thin_provisioning' and + 'filesystem_thin_provisioning' to rbd and filesystem + backends to enable or not sparse upload, default are False. diff --git a/spec/classes/glance_backend_file_spec.rb b/spec/classes/glance_backend_file_spec.rb index 9cb4d584..ce9371bf 100644 --- a/spec/classes/glance_backend_file_spec.rb +++ b/spec/classes/glance_backend_file_spec.rb @@ -5,6 +5,7 @@ describe 'glance::backend::file' do shared_examples_for 'glance::backend::file' do it 'configures glance-api.conf' do is_expected.to contain_glance_api_config('glance_store/default_store').with_value('file') + is_expected.to contain_glance_api_config('glance_store/filesystem_thin_provisioning').with_value('') is_expected.to contain_glance_api_config('glance_store/filesystem_store_datadir').with_value('/var/lib/glance/images/') end @@ -14,11 +15,15 @@ describe 'glance::backend::file' do describe 'when overriding datadir' do let :params do - {:filesystem_store_datadir => '/tmp/'} + { + :filesystem_store_datadir => '/tmp/', + :filesystem_thin_provisioning => 'true', + } end it 'configures glance-api.conf' do is_expected.to contain_glance_api_config('glance_store/filesystem_store_datadir').with_value('/tmp/') + is_expected.to contain_glance_api_config('glance_store/filesystem_thin_provisioning').with_value('true') end it 'configures glance-cache.conf' do diff --git a/spec/classes/glance_backend_rbd_spec.rb b/spec/classes/glance_backend_rbd_spec.rb index 94260ccd..062db983 100644 --- a/spec/classes/glance_backend_rbd_spec.rb +++ b/spec/classes/glance_backend_rbd_spec.rb @@ -7,6 +7,7 @@ describe 'glance::backend::rbd' do it { should contain_glance_api_config('glance_store/rbd_store_pool').with_value('') } it { should contain_glance_api_config('glance_store/rbd_store_ceph_conf').with_value('') } it { should contain_glance_api_config('glance_store/rbd_store_chunk_size').with_value('') } + it { should contain_glance_api_config('glance_store/rbd_thin_provisioning').with_value('') } it { should contain_glance_api_config('glance_store/rados_connect_timeout').with_value('')} it { should contain_glance_api_config('glance_store/rbd_store_user').with_value('')} @@ -21,6 +22,7 @@ describe 'glance::backend::rbd' do { :rbd_store_user => 'user', :rbd_store_chunk_size => '2', + :rbd_thin_provisioning => 'true', :package_ensure => 'latest', :rados_connect_timeout => '30', } @@ -28,6 +30,7 @@ describe 'glance::backend::rbd' do it { should contain_glance_api_config('glance_store/rbd_store_user').with_value('user') } it { should contain_glance_api_config('glance_store/rbd_store_chunk_size').with_value('2') } + it { should contain_glance_api_config('glance_store/rbd_thin_provisioning').with_value('true') } it { should contain_glance_api_config('glance_store/rados_connect_timeout').with_value('30')} it { should contain_package('python-ceph').with( diff --git a/spec/defines/glance_backend_multistore_file_spec.rb b/spec/defines/glance_backend_multistore_file_spec.rb index c97406af..1621963c 100644 --- a/spec/defines/glance_backend_multistore_file_spec.rb +++ b/spec/defines/glance_backend_multistore_file_spec.rb @@ -24,6 +24,7 @@ describe 'glance::backend::multistore::file' do shared_examples_for 'glance::backend::multistore::file' do it 'configures glance-api.conf' do is_expected.to contain_glance_api_config('file/store_description').with_value('') + is_expected.to contain_glance_api_config('file/filesystem_thin_provisioning').with_value('') is_expected.to contain_glance_api_config('file/filesystem_store_datadir').with_value('') end @@ -34,11 +35,15 @@ describe 'glance::backend::multistore::file' do describe 'when overriding datadir' do let :params do - {:filesystem_store_datadir => '/tmp/'} + { + :filesystem_store_datadir => '/tmp/', + :filesystem_thin_provisioning => 'true', + } end it 'configures glance-api.conf' do is_expected.to contain_glance_api_config('file/filesystem_store_datadir').with_value('/tmp/') + is_expected.to contain_glance_api_config('file/filesystem_thin_provisioning').with_value('true') end it 'configures glance-cache.conf' do diff --git a/spec/defines/glance_backend_multistore_rbd_spec.rb b/spec/defines/glance_backend_multistore_rbd_spec.rb index e2605775..68554b13 100644 --- a/spec/defines/glance_backend_multistore_rbd_spec.rb +++ b/spec/defines/glance_backend_multistore_rbd_spec.rb @@ -27,6 +27,7 @@ describe 'glance::backend::multistore::rbd' do it { should contain_glance_api_config('rbd/rbd_store_pool').with_value('') } it { should contain_glance_api_config('rbd/rbd_store_ceph_conf').with_value('') } it { should contain_glance_api_config('rbd/rbd_store_chunk_size').with_value('') } + it { should contain_glance_api_config('rbd/rbd_thin_provisioning').with_value('') } it { should contain_glance_api_config('rbd/rados_connect_timeout').with_value('')} it { should contain_glance_api_config('rbd/rbd_store_user').with_value('')} @@ -42,6 +43,7 @@ describe 'glance::backend::multistore::rbd' do :store_description => 'My rbd store', :rbd_store_user => 'user', :rbd_store_chunk_size => '2', + :rbd_thin_provisioning => 'true', :package_ensure => 'latest', :rados_connect_timeout => '30', } @@ -50,6 +52,7 @@ describe 'glance::backend::multistore::rbd' do it { should contain_glance_api_config('rbd/store_description').with_value('My rbd store') } it { should contain_glance_api_config('rbd/rbd_store_user').with_value('user') } it { should contain_glance_api_config('rbd/rbd_store_chunk_size').with_value('2') } + it { should contain_glance_api_config('rbd/rbd_thin_provisioning').with_value('true') } it { should contain_glance_api_config('rbd/rados_connect_timeout').with_value('30')} it { should contain_package('python-ceph').with(