Browse Source

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
changes/50/750950/3
PranaliD 1 year ago
committed by Takashi Kajinami
parent
commit
da9e1a7f4e
  1. 20
      manifests/backend/file.pp
  2. 14
      manifests/backend/multistore/file.pp
  3. 6
      manifests/backend/multistore/rbd.pp
  4. 6
      manifests/backend/rbd.pp
  5. 6
      releasenotes/notes/enable_handling_sparse_image-0a68af239b413df1.yaml
  6. 7
      spec/classes/glance_backend_file_spec.rb
  7. 3
      spec/classes/glance_backend_rbd_spec.rb
  8. 7
      spec/defines/glance_backend_multistore_file_spec.rb
  9. 3
      spec/defines/glance_backend_multistore_rbd_spec.rb

20
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 {

14
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 {

6
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;
}

6
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,

6
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.

7
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('<SERVICE DEFAULT>')
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

3
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('<SERVICE DEFAULT>') }
it { should contain_glance_api_config('glance_store/rbd_store_ceph_conf').with_value('<SERVICE DEFAULT>') }
it { should contain_glance_api_config('glance_store/rbd_store_chunk_size').with_value('<SERVICE DEFAULT>') }
it { should contain_glance_api_config('glance_store/rbd_thin_provisioning').with_value('<SERVICE DEFAULT>') }
it { should contain_glance_api_config('glance_store/rados_connect_timeout').with_value('<SERVICE DEFAULT>')}
it { should contain_glance_api_config('glance_store/rbd_store_user').with_value('<SERVICE DEFAULT>')}
@ -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(

7
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('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('file/filesystem_thin_provisioning').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('file/filesystem_store_datadir').with_value('<SERVICE DEFAULT>')
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

3
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('<SERVICE DEFAULT>') }
it { should contain_glance_api_config('rbd/rbd_store_ceph_conf').with_value('<SERVICE DEFAULT>') }
it { should contain_glance_api_config('rbd/rbd_store_chunk_size').with_value('<SERVICE DEFAULT>') }
it { should contain_glance_api_config('rbd/rbd_thin_provisioning').with_value('<SERVICE DEFAULT>') }
it { should contain_glance_api_config('rbd/rados_connect_timeout').with_value('<SERVICE DEFAULT>')}
it { should contain_glance_api_config('rbd/rbd_store_user').with_value('<SERVICE DEFAULT>')}
@ -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(

Loading…
Cancel
Save