Skip to content

Commit 6e9f7c2

Browse files
committed
Support optimized cinder backend for glance
When Glance is configured with a cinder glance_store, Cinder can be configured to allow cloning of image data directly in the backend instead of transferring data through Glance. Expose these configuration options in devstack to facilitate testing this feature. Adds: - CINDER_ALLOWED_DIRECT_URL_SCHEMES - GLANCE_SHOW_DIRECT_URL - GLANCE_SHOW_MULTIPLE_LOCATIONS Change-Id: Iee619b443088fd77cf7b1a48563203bdf4a93a39
1 parent b04a62b commit 6e9f7c2

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

lib/cinder

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,22 @@ if is_fedora || is_suse; then
104104
fi
105105
fi
106106

107+
# When Cinder is used as a backend for Glance, it can be configured to clone
108+
# the volume containing image data directly in the backend instead of
109+
# transferring data from volume to volume. Value is a comma separated list of
110+
# schemes (currently only 'file' and 'cinder' are supported). The default
111+
# configuration in Cinder is empty (that is, do not use this feature). NOTE:
112+
# to use this feature you must also enable GLANCE_SHOW_DIRECT_URL and/or
113+
# GLANCE_SHOW_MULTIPLE_LOCATIONS for glance-api.conf.
114+
CINDER_ALLOWED_DIRECT_URL_SCHEMES=${CINDER_ALLOWED_DIRECT_URL_SCHEMES:-}
115+
if [[ -n "$CINDER_ALLOWED_DIRECT_URL_SCHEMES" ]]; then
116+
if [[ "${GLANCE_SHOW_DIRECT_URL:-False}" != "True" \
117+
&& "${GLANCE_SHOW_MULTIPLE_LOCATIONS:-False}" != "True" ]]; then
118+
warn $LINENO "CINDER_ALLOWED_DIRECT_URL_SCHEMES is set, but neither \
119+
GLANCE_SHOW_DIRECT_URL nor GLANCE_SHOW_MULTIPLE_LOCATIONS is True"
120+
fi
121+
fi
122+
107123
# For backward compatibility
108124
# Before CINDER_BACKUP_DRIVER was introduced, ceph backup driver was configured
109125
# along with ceph backend driver.
@@ -266,6 +282,9 @@ function configure_cinder {
266282
fi
267283
iniset $CINDER_CONF key_manager backend cinder.keymgr.conf_key_mgr.ConfKeyManager
268284
iniset $CINDER_CONF key_manager fixed_key $(openssl rand -hex 16)
285+
if [[ -n "$CINDER_ALLOWED_DIRECT_URL_SCHEMES" ]]; then
286+
iniset $CINDER_CONF DEFAULT allowed_direct_url_schemes $CINDER_ALLOWED_DIRECT_URL_SCHEMES
287+
fi
269288

270289
# Avoid RPC timeouts in slow CI and test environments by doubling the
271290
# default response timeout set by RPC clients. See bug #1873234 for more

lib/glance

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ GLANCE_STORE_ROOTWRAP_BASE_DIR=/usr/local/etc/glance
5151
if is_opensuse; then
5252
GLANCE_STORE_ROOTWRAP_BASE_DIR=/usr/etc/glance
5353
fi
54+
# When Cinder is used as a glance store, you can optionally configure cinder to
55+
# optimize bootable volume creation by allowing volumes to be cloned directly
56+
# in the backend instead of transferring data via Glance. To use this feature,
57+
# set CINDER_ALLOWED_DIRECT_URL_SCHEMES for cinder.conf and enable
58+
# GLANCE_SHOW_DIRECT_URL and/or GLANCE_SHOW_MULTIPLE_LOCATIONS for Glance. The
59+
# default value for both of these is False, because for some backends they
60+
# present a grave security risk (though not for Cinder, because all that's
61+
# exposed is the volume_id where the image data is stored.) See OSSN-0065 for
62+
# more information: https://wiki.openstack.org/wiki/OSSN/OSSN-0065
63+
GLANCE_SHOW_DIRECT_URL=$(trueorfalse False GLANCE_SHOW_DIRECT_URL)
64+
GLANCE_SHOW_MULTIPLE_LOCATIONS=$(trueorfalse False GLANCE_SHOW_MULTIPLE_LOCATIONS)
65+
5466
# Glance multi-store configuration
5567
# Boolean flag to enable multiple store configuration for glance
5668
GLANCE_ENABLE_MULTIPLE_STORES=$(trueorfalse False GLANCE_ENABLE_MULTIPLE_STORES)
@@ -283,6 +295,9 @@ function configure_glance {
283295
if [ "$VIRT_DRIVER" = 'libvirt' ] && [ "$LIBVIRT_TYPE" = 'parallels' ]; then
284296
iniset $GLANCE_API_CONF DEFAULT disk_formats "ami,ari,aki,vhd,vmdk,raw,qcow2,vdi,iso,ploop"
285297
fi
298+
# Only use these if you know what you are doing! See OSSN-0065
299+
iniset $GLANCE_API_CONF DEFAULT show_image_direct_url $GLANCE_SHOW_DIRECT_URL
300+
iniset $GLANCE_API_CONF DEFAULT show_multiple_locations $GLANCE_SHOW_MULTIPLE_LOCATIONS
286301

287302
# Configure glance_store
288303
configure_glance_store $USE_CINDER_FOR_GLANCE $GLANCE_ENABLE_MULTIPLE_STORES

0 commit comments

Comments
 (0)