ScaleIO Driver: Fix for using scheduler specified pool
Addresses an issue where the pool specified by the scheduler was
ignored and default settings applied instead
Change-Id: I72dac64b72da258556da416b61cc8151aec8d6a2
Closes-Bug: #1698921
(cherry picked from commit ee13434298
)
This commit is contained in:
parent
2239bb60c5
commit
d64250f651
|
@ -34,6 +34,10 @@ class TestCreateVolume(scaleio.TestScaleIODriver):
|
|||
ctx = context.RequestContext('fake', 'fake', auth_token=True)
|
||||
|
||||
self.volume = fake_volume.fake_volume_obj(ctx)
|
||||
host = 'host@backend#{}:{}'.format(
|
||||
self.PROT_DOMAIN_NAME,
|
||||
self.STORAGE_POOL_NAME)
|
||||
self.volume.host = host
|
||||
|
||||
self.HTTPS_MOCK_RESPONSES = {
|
||||
self.RESPONSE_MODE.Valid: {
|
||||
|
@ -71,6 +75,7 @@ class TestCreateVolume(scaleio.TestScaleIODriver):
|
|||
"""No protection domain name or ID provided."""
|
||||
self.driver.protection_domain_name = None
|
||||
self.driver.protection_domain_id = None
|
||||
self.volume.host = "host@backend"
|
||||
self.assertRaises(exception.VolumeBackendAPIException,
|
||||
self.test_create_volume)
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ from cinder import utils
|
|||
from cinder.volume import driver
|
||||
from cinder.volume.drivers.san import san
|
||||
from cinder.volume import qos_specs
|
||||
from cinder.volume import utils as volume_utils
|
||||
from cinder.volume import volume_types
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
@ -256,8 +257,15 @@ class ScaleIODriver(driver.VolumeDriver):
|
|||
self.storage_pool_id)
|
||||
|
||||
def _find_storage_pool_name_from_storage_type(self, storage_type):
|
||||
return storage_type.get(STORAGE_POOL_NAME,
|
||||
self.storage_pool_name)
|
||||
pool_name = storage_type.get(STORAGE_POOL_NAME)
|
||||
# using the extra spec of sio:sp_name is deprecated
|
||||
if pool_name is not None:
|
||||
LOG.warning(_LW("Using the volume type extra spec of "
|
||||
"sio:sp_name is deprecated and will be removed "
|
||||
"in a future version. The supported way to "
|
||||
"specify this is by specifying an extra spec "
|
||||
"of 'pool_name=protection_domain:storage_pool'"))
|
||||
return pool_name
|
||||
|
||||
def _find_protection_domain_id_from_storage_type(self, storage_type):
|
||||
# Default to what was configured in configuration file if not defined.
|
||||
|
@ -265,9 +273,15 @@ class ScaleIODriver(driver.VolumeDriver):
|
|||
self.protection_domain_id)
|
||||
|
||||
def _find_protection_domain_name_from_storage_type(self, storage_type):
|
||||
# Default to what was configured in configuration file if not defined.
|
||||
return storage_type.get(PROTECTION_DOMAIN_NAME,
|
||||
self.protection_domain_name)
|
||||
domain_name = storage_type.get(PROTECTION_DOMAIN_NAME)
|
||||
# using the extra spec of sio:pd_name is deprecated
|
||||
if domain_name is not None:
|
||||
LOG.warning(_LW("Using the volume type extra spec of "
|
||||
"sio:pd_name is deprecated and will be removed "
|
||||
"in a future version. The supported way to "
|
||||
"specify this is by specifying an extra spec "
|
||||
"of 'pool_name=protection_domain:storage_pool'"))
|
||||
return domain_name
|
||||
|
||||
def _find_provisioning_type(self, storage_type):
|
||||
new_provisioning_type = storage_type.get(PROVISIONING_KEY)
|
||||
|
@ -328,27 +342,67 @@ class ScaleIODriver(driver.VolumeDriver):
|
|||
|
||||
volname = self._id_to_base64(volume.id)
|
||||
|
||||
# the cinder scheduler will send us the pd:sp for the volume
|
||||
requested_pd = None
|
||||
requested_sp = None
|
||||
try:
|
||||
pd_sp = volume_utils.extract_host(volume.host, 'pool')
|
||||
if pd_sp is not None:
|
||||
requested_pd = pd_sp.split(':')[0]
|
||||
requested_sp = pd_sp.split(':')[1]
|
||||
except (KeyError, ValueError):
|
||||
# we seem to have not gotten it so we'll figure out defaults
|
||||
requested_pd = None
|
||||
requested_sp = None
|
||||
|
||||
storage_type = self._get_volumetype_extraspecs(volume)
|
||||
storage_pool_name = self._find_storage_pool_name_from_storage_type(
|
||||
storage_type)
|
||||
type_sp = self._find_storage_pool_name_from_storage_type(storage_type)
|
||||
storage_pool_id = self._find_storage_pool_id_from_storage_type(
|
||||
storage_type)
|
||||
protection_domain_id = (
|
||||
self._find_protection_domain_id_from_storage_type(storage_type))
|
||||
protection_domain_name = (
|
||||
type_pd = (
|
||||
self._find_protection_domain_name_from_storage_type(storage_type))
|
||||
provisioning_type = self._find_provisioning_type(storage_type)
|
||||
|
||||
if type_sp is not None:
|
||||
# prefer the storage pool in the volume type
|
||||
# this was undocumented so will likely not happen
|
||||
storage_pool_name = type_sp
|
||||
else:
|
||||
storage_pool_name = requested_sp
|
||||
if type_pd is not None:
|
||||
# prefer the protection domain in the volume type
|
||||
# this was undocumented so will likely not happen
|
||||
protection_domain_name = type_pd
|
||||
else:
|
||||
protection_domain_name = requested_pd
|
||||
|
||||
# check if the requested pd:sp match the ones that will
|
||||
# be used. If not, spit out a deprecation notice
|
||||
# should never happen
|
||||
if (protection_domain_name != requested_pd
|
||||
or storage_pool_name != requested_sp):
|
||||
LOG.warning(_LW(
|
||||
"Creating volume in different protection domain or "
|
||||
"storage pool than scheduler requested. "
|
||||
"Requested: %(req_pd)s:%(req_sp)s, "
|
||||
"Actual %(act_pd)s:%(act_sp)s."),
|
||||
{'req_pd': requested_pd,
|
||||
'req_sp': requested_sp,
|
||||
'act_pd': protection_domain_name,
|
||||
'act_sp': storage_pool_name})
|
||||
|
||||
LOG.info(_LI(
|
||||
"Volume type: %(volume_type)s, "
|
||||
"storage pool name: %(pool_name)s, "
|
||||
"storage pool id: %(pool_id)s, protection domain id: "
|
||||
"%(domain_id)s, protection domain name: %(domain_name)s."),
|
||||
{'volume_type': storage_type,
|
||||
'pool_name': storage_pool_name,
|
||||
'pool_id': storage_pool_id,
|
||||
'domain_id': protection_domain_id,
|
||||
'domain_name': protection_domain_name})
|
||||
"Volume type: %(volume_type)s, "
|
||||
"storage pool name: %(pool_name)s, "
|
||||
"storage pool id: %(pool_id)s, protection domain id: "
|
||||
"%(domain_id)s, protection domain name: %(domain_name)s."),
|
||||
{'volume_type': storage_type,
|
||||
'pool_name': storage_pool_name,
|
||||
'pool_id': storage_pool_id,
|
||||
'domain_id': protection_domain_id,
|
||||
'domain_name': protection_domain_name})
|
||||
|
||||
verify_cert = self._get_verify_cert()
|
||||
|
||||
|
|
Loading…
Reference in New Issue