From 122a144057308b23afb288381ac9afa7f2a75e69 Mon Sep 17 00:00:00 2001 From: Dharini Chandrasekar Date: Tue, 23 Aug 2016 19:59:32 +0000 Subject: [PATCH] Fixing inconsistency in Glance store names. The store names used in glance and glance_store are not in sync with each other. This can confuse operators who have to use different names to refer to the same store while setting values for configuration options such as ``store_type_preference`` in glance and configuration option like ``store`` in glance_store. This inconsistency may also confuse developers during code changes, complicating future code changes with respect to this. Mapping store names: ``vmware_datastore`` and ``filesystem`` to ``vmware`` and ``file`` respectively to be in sync with glance_store entry point names and at the same time accommodate backward compatibility for old configuration files that might still be using ``filesystem`` and ``vmware_datastore``. Note: This change applies only when multiple image locations are being used and ``location_strategy`` configuration option is set to ``store_type``. Note: Including glance-api.conf with this patch with the updated configuration option help text. Impact: UpgradeImpact Credit: This patch has a release note authored by Brian Rosmaita Change-Id: I3d8593cdae6780ae721afedcf47dd45afa684f25 Closes-Bug: #1615852 (cherry picked from commit dfa0682cac93938fc6fe3c0ccfb0640a0a18ee33) --- etc/glance-api.conf | 9 +--- glance/common/location_strategy/store_type.py | 45 ++++++++++++------- .../unit/common/test_location_strategy.py | 28 +++++++++++- ...nsistent-store-names-57374b9505d530d0.yaml | 32 +++++++++++++ 4 files changed, 88 insertions(+), 26 deletions(-) create mode 100644 releasenotes/notes/consistent-store-names-57374b9505d530d0.yaml diff --git a/etc/glance-api.conf b/etc/glance-api.conf index 9b944b0c..f10a6d34 100644 --- a/etc/glance-api.conf +++ b/etc/glance-api.conf @@ -4096,18 +4096,13 @@ # Possible values: # * Empty list # * Comma separated list of registered store names. Legal values are: -# (NOTE: Use only the following choices, which, unfortunately, -# are not entirely consistent with the store names used in other -# similar configuration options. Please take extra care while -# setting this option, and read the help text carefully when -# setting other similar options.) -# * filesystem +# * file # * http # * rbd # * swift # * sheepdog # * cinder -# * vmware_datastore +# * vmware # # Related options: # * location_strategy diff --git a/glance/common/location_strategy/store_type.py b/glance/common/location_strategy/store_type.py index bc4aa687..90ad5232 100644 --- a/glance/common/location_strategy/store_type.py +++ b/glance/common/location_strategy/store_type.py @@ -16,19 +16,14 @@ """Storage preference based location strategy module""" from oslo_config import cfg +from oslo_log import log as logging import six import six.moves.urllib.parse as urlparse -from glance.i18n import _ +from glance.i18n import _, _LW -# TODO(dharinic): The help text for ``store_type_preference`` must be -# edited to replace ``filesystem``and ``vmware_datastore`` with ``file`` -# and ``vmware`` respectively upon resolution of Bug #1615852. -# Also, remove the Note from ``Possible Values`` sections upon -# resolution of Bug #1615852. +LOG = logging.getLogger(__name__) -# NOTE(dharinic): We cannot restrict the choices for ``store_type_preference`` -# for backward compatability reasons. See Bug #1615852. store_type_opts = [ cfg.ListOpt('store_type_preference', default=[], @@ -48,18 +43,13 @@ change the location order. Possible values: * Empty list * Comma separated list of registered store names. Legal values are: - (NOTE: Use only the following choices, which, unfortunately, - are not entirely consistent with the store names used in other - similar configuration options. Please take extra care while - setting this option, and read the help text carefully when - setting other similar options.) - * filesystem + * file * http * rbd * swift * sheepdog * cinder - * vmware_datastore + * vmware Related options: * location_strategy @@ -89,13 +79,13 @@ def init(): # possible to prevent make relationships with Glance(server)-specific code, # for example: using functions within store module to validate # 'store_type_preference' option. - mapping = {'filesystem': ['file', 'filesystem'], + mapping = {'file': ['file', 'filesystem'], 'http': ['http', 'https'], 'rbd': ['rbd'], 'swift': ['swift', 'swift+https', 'swift+http'], 'sheepdog': ['sheepdog'], 'cinder': ['cinder'], - 'vmware_datastore': ['vsphere']} + 'vmware': ['vsphere']} _STORE_TO_SCHEME_MAP.clear() _STORE_TO_SCHEME_MAP.update(mapping) @@ -114,6 +104,27 @@ def get_ordered_locations(locations, uri_key='url', **kwargs): preferred_store = str(preferred_store).strip() if not preferred_store: continue + # NOTE(dharinic): The following conversion of ``filesystem`` and + # ``vmware_datastore`` to ``file`` and ``vmware`` respectively + # are to make store names consistent in Glance and glance_store + # and also be backward compatible. + # Reference: Bug 1615852 + if preferred_store == 'filesystem': + preferred_store = 'file' + msg = _LW('The value ``filesystem`` is DEPRECATED for use ' + 'with ``store_type_preference``. It will be ' + 'removed in the Pike release. Please use ``file`` ' + 'instead. Please see the Glance Newton release ' + 'notes for more information.') + LOG.warn(msg) + if preferred_store == 'vmware_datastore': + preferred_store = 'vmware' + msg = _LW('The value ``vmware_datastore`` is DEPRECATED for ' + 'use with ``store_type_preference``. It will be ' + 'removed in the Pike release. Please use ``vmware`` ' + 'instead. Please see the Glance Newton release ' + 'notes for more information.') + LOG.warn(msg) yield preferred_store if not locations: diff --git a/glance/tests/unit/common/test_location_strategy.py b/glance/tests/unit/common/test_location_strategy.py index ce3984c9..1858289b 100644 --- a/glance/tests/unit/common/test_location_strategy.py +++ b/glance/tests/unit/common/test_location_strategy.py @@ -158,15 +158,17 @@ class TestStoreTypeStrategyModule(base.IsolatedUnitTest): def test_get_ordered_locations(self): self.config(store_type_preference=[' rbd', 'sheepdog ', ' filesystem', - 'swift ', ' http '], + 'swift ', ' http ', + 'vmware_datastore'], group='store_type_location_strategy') locs = [{'url': 'file://image0', 'metadata': {'idx': 3}}, {'url': 'rbd://image1', 'metadata': {'idx': 0}}, {'url': 'file://image3', 'metadata': {'idx': 4}}, {'url': 'swift://image4', 'metadata': {'idx': 6}}, - {'url': 'cinder://image5', 'metadata': {'idx': 8}}, + {'url': 'cinder://image5', 'metadata': {'idx': 9}}, {'url': 'file://image6', 'metadata': {'idx': 5}}, {'url': 'rbd://image7', 'metadata': {'idx': 1}}, + {'url': 'vsphere://image9', 'metadata': {'idx': 8}}, {'url': 'sheepdog://image8', 'metadata': {'idx': 2}}] ordered_locs = store_type.get_ordered_locations(copy.deepcopy(locs)) locs.sort(key=lambda loc: loc['metadata']['idx']) @@ -189,3 +191,25 @@ class TestStoreTypeStrategyModule(base.IsolatedUnitTest): locs.sort(key=lambda loc: loc['metadata']['idx']) # The result will ordered by preferred store type order. self.assertEqual(locs, ordered_locs) + + def test_get_ordered_locations_with_consistent_store_names(self): + """This test is for the change made with respect to making store names + in glance to be consistent with store names used in glance_store. + Reference: Bug #1615852 + """ + self.config(store_type_preference=[' rbd', 'sheepdog ', 'file', + 'swift ', ' http ', 'vmware'], + group='store_type_location_strategy') + locs = [{'url': 'file://image0', 'metadata': {'idx': 3}}, + {'url': 'rbd://image1', 'metadata': {'idx': 0}}, + {'url': 'file://image3', 'metadata': {'idx': 4}}, + {'url': 'swift://image4', 'metadata': {'idx': 6}}, + {'url': 'cinder://image5', 'metadata': {'idx': 9}}, + {'url': 'file://image6', 'metadata': {'idx': 5}}, + {'url': 'rbd://image7', 'metadata': {'idx': 1}}, + {'url': 'vsphere://image9', 'metadata': {'idx': 8}}, + {'url': 'sheepdog://image8', 'metadata': {'idx': 2}}] + ordered_locs = store_type.get_ordered_locations(copy.deepcopy(locs)) + locs.sort(key=lambda loc: loc['metadata']['idx']) + # The result will ordered by preferred store type order. + self.assertEqual(locs, ordered_locs) diff --git a/releasenotes/notes/consistent-store-names-57374b9505d530d0.yaml b/releasenotes/notes/consistent-store-names-57374b9505d530d0.yaml new file mode 100644 index 00000000..4ec91639 --- /dev/null +++ b/releasenotes/notes/consistent-store-names-57374b9505d530d0.yaml @@ -0,0 +1,32 @@ +--- +upgrade: + - | + Some backend store names were inconsistent between glance + and glance_store. This meant that operators of the + VMware datastore or file system store were required to use + store names in ``glance-api.conf`` that did not correspond + to any valid identifier in glance_store. As this situation + encouraged misconfiguration and operator unhappiness, we + have made the store names consistent in the Newton + release. What this means for you: + + * This change applies only to operators who are using + multiple image locations + * This change applies only to operators using the VMware + datastore or filesystem stores + * This change applies only to the ``store_type_preference`` + option + * *VMware datastore operators*: The old name, now + **DEPRECATED**, was ``vmware_datastore``. The **new** + name, used in both glance and glance_store, is + ``vmware`` + * *File system store operators*: the old name, now + **DEPRECATED**, was ``filesystem``. The **new** name, + used in both glance and glance_store, is ``file`` + * This change is backward compatible, that is, the old + names will be recognized by the code during the deprecation + period. Support for the deprecated names will be removed in + the **Pike** release + * We strongly encourage operators to modify their + ``glance-api.conf`` files immediately to use the **new** + names