Always return a sorted list of drivers for configs

glance.store entry point used in Glance for the store library is
resulting in generating random order in each run of the ``tox -e
genconfig`` command. This is because of the unsorted iterator returned
by the stevedore extension manager [1, 2].

This commit fixes that and returs a deterministic, sorted list of
drivers to generate the configs in Glance.

Example scenario is at change Iea2c538b37182191445cc5c1f8b2d9dceed06343

Closes-Bug: 1619487

[1] 22fa2b08e7/glance_store/backend.py (L135)
[2] http://docs.openstack.org/developer/stevedore/managers.html#stevedore.extension.ExtensionManager.__iter__

Co-Authored-By: Joshua Harlow <jxharlow@godaddy.com>

Change-Id: I3146b8597a5d89da49b84d6653edacc3067c2c71
This commit is contained in:
Nikhil Komawar 2016-09-01 18:48:05 -04:00
parent 22fa2b08e7
commit b5833a8723
2 changed files with 17 additions and 1 deletions

View File

@ -132,7 +132,7 @@ def _list_opts():
driver_opts = []
mgr = extension.ExtensionManager('glance_store.drivers')
# NOTE(zhiyan): Handle available drivers entry_points provided
drivers = [ext.name for ext in mgr]
drivers = sorted([ext.name for ext in mgr])
handled_drivers = [] # Used to handle backwards-compatible entries
for store_entry in drivers:
driver_cls = _load_store(None, store_entry, False)

View File

@ -0,0 +1,16 @@
---
prelude: >
Return list of store drivers in sorted order for
generating configs. More info in ``Upgrade Notes``
and ``Bug Fixes`` section.
upgrade:
- This version of glance_store will result in Glance
generating the configs in a sorted (deterministic)
order. So, preferably store releases on or after this
should be used for generating any new configs if the
mismatched ordering of the configs results in an issue
in your environment.
fixes:
- Bug 1619487 is fixed which was causing random order of
the generation of configs in Glance. See ``upgrade``
section for more details.