Skip to content

Commit 1898a68

Browse files
committed
Create multiattach volume type for tempest
Creating multiattach volume is a non-admin operation but creating multiattach volume type is an admin operation. Previously cinder allowed creating multiattach volumes without a volume type but that support is being removed with[1]. The change requires updating tempest tests[2] but some tempest tests are non-admin, which require admin priviledges to create the multiattach volume type. Based on the last discussion with tempest team[3], the proposed solution is to create a multiattach volume type in devstack, if ENABLE_VOLUME_MULTIATTACH is True, and use it in tempest tests. Similar to how admins create multiattach volume types for non-admin users. This patch creates a multiattach volume type if ENABLE_VOLUME_MULTIATTACH is True. Also we set the multiattach type name as a tempest config option 'volume_type_multiattach'. [1] https://review.opendev.org/c/openstack/cinder/+/874865 [2] https://review.opendev.org/c/openstack/tempest/+/875372 [3] https://meetings.opendev.org/irclogs/%23openstack-cinder/%23openstack-cinder.2023-03-13.log.html#t2023-03-13T18:47:56 Change-Id: Icd3690565bf7b27898cd206641e612da3993703d
1 parent 35c9aff commit 1898a68

2 files changed

Lines changed: 27 additions & 11 deletions

File tree

lib/cinder

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ CINDER_ENABLED_BACKENDS=${CINDER_ENABLED_BACKENDS:-lvm:lvmdriver-1}
9595
CINDER_VOLUME_CLEAR=${CINDER_VOLUME_CLEAR:-${CINDER_VOLUME_CLEAR_DEFAULT:-zero}}
9696
CINDER_VOLUME_CLEAR=$(echo ${CINDER_VOLUME_CLEAR} | tr '[:upper:]' '[:lower:]')
9797

98+
VOLUME_TYPE_MULTIATTACH=${VOLUME_TYPE_MULTIATTACH:-multiattach}
9899

99100
if [[ -n "$CINDER_ISCSI_HELPER" ]]; then
100101
if [[ -z "$CINDER_TARGET_HELPER" ]]; then
@@ -649,26 +650,37 @@ function stop_cinder {
649650
stop_process c-vol
650651
}
651652

653+
function create_one_type {
654+
type_name=$1
655+
property_key=$2
656+
property_value=$3
657+
# NOTE (e0ne): openstack client doesn't work with cinder in noauth mode
658+
if is_service_enabled keystone; then
659+
openstack --os-region-name="$REGION_NAME" volume type create --property $property_key="$property_value" $type_name
660+
else
661+
# TODO (e0ne): use openstack client once it will support cinder in noauth mode:
662+
# https://bugs.launchpad.net/python-cinderclient/+bug/1755279
663+
local cinder_url
664+
cinder_url=$CINDER_SERVICE_PROTOCOL://$SERVICE_HOST:$CINDER_SERVICE_PORT/v3
665+
OS_USER_ID=$OS_USERNAME OS_PROJECT_ID=$OS_PROJECT_NAME cinder --os-auth-type noauth --os-endpoint=$cinder_url type-create $type_name
666+
OS_USER_ID=$OS_USERNAME OS_PROJECT_ID=$OS_PROJECT_NAME cinder --os-auth-type noauth --os-endpoint=$cinder_url type-key $type_name set $property_key="$property_value"
667+
fi
668+
}
669+
652670
# create_volume_types() - Create Cinder's configured volume types
653671
function create_volume_types {
654672
# Create volume types
655673
if is_service_enabled c-api && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then
656674
local be be_name
657675
for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
658676
be_name=${be##*:}
659-
# NOTE (e0ne): openstack client doesn't work with cinder in noauth mode
660-
if is_service_enabled keystone; then
661-
openstack --os-region-name="$REGION_NAME" volume type create --property volume_backend_name="${be_name}" ${be_name}
662-
else
663-
# TODO (e0ne): use openstack client once it will support cinder in noauth mode:
664-
# https://bugs.launchpad.net/python-cinderclient/+bug/1755279
665-
local cinder_url
666-
cinder_url=$CINDER_SERVICE_PROTOCOL://$SERVICE_HOST:$CINDER_SERVICE_PORT/v3
667-
OS_USER_ID=$OS_USERNAME OS_PROJECT_ID=$OS_PROJECT_NAME cinder --os-auth-type noauth --os-endpoint=$cinder_url type-create ${be_name}
668-
OS_USER_ID=$OS_USERNAME OS_PROJECT_ID=$OS_PROJECT_NAME cinder --os-auth-type noauth --os-endpoint=$cinder_url type-key ${be_name} set volume_backend_name=${be_name}
669-
fi
677+
create_one_type $be_name "volume_backend_name" $be_name
670678
done
671679

680+
if [[ $ENABLE_VOLUME_MULTIATTACH == "True" ]]; then
681+
create_one_type $VOLUME_TYPE_MULTIATTACH $VOLUME_TYPE_MULTIATTACH "<is> True"
682+
fi
683+
672684
# Increase quota for the service project if glance is using cinder,
673685
# since it's likely to occasionally go above the default 10 in parallel
674686
# test execution.

lib/tempest

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,10 @@ function configure_tempest {
604604
iniset $TEMPEST_CONFIG volume storage_protocol "$TEMPEST_STORAGE_PROTOCOL"
605605
fi
606606

607+
if [[ $ENABLE_VOLUME_MULTIATTACH == "True" ]]; then
608+
iniset $TEMPEST_CONFIG volume volume_type_multiattach $VOLUME_TYPE_MULTIATTACH
609+
fi
610+
607611
# Placement Features
608612
# Set the microversion range for placement.
609613
# Setting [None, latest] range of microversion which allow Tempest to run all microversions tests.

0 commit comments

Comments
 (0)