Makes the Extension loader behavior predictable

When using a cluster of load-balanced Neutron Servers,
the order of extension files being loaded may differ
from one server to another. This is usually harmless,
but it is better to force the list to be loaded in the
same way across the entire cluster, just in case
something funky is going on.

Partial-bug: #1285999

Change-Id: Ib0bfd24fc52b6cd9f90c350d3af496f04a90f50a
This commit is contained in:
armando-migliaccio 2014-03-06 12:40:38 -08:00
parent 0aa2ceb685
commit bdd122c17e

View File

@ -541,7 +541,10 @@ class ExtensionManager(object):
LOG.error(_("Extension path '%s' doesn't exist!"), path) LOG.error(_("Extension path '%s' doesn't exist!"), path)
def _load_all_extensions_from_path(self, path): def _load_all_extensions_from_path(self, path):
for f in os.listdir(path): # Sorting the extension list makes the order in which they
# are loaded predictable across a cluster of load-balanced
# Neutron Servers
for f in sorted(os.listdir(path)):
try: try:
LOG.info(_('Loading extension file: %s'), f) LOG.info(_('Loading extension file: %s'), f)
mod_name, file_ext = os.path.splitext(os.path.split(f)[-1]) mod_name, file_ext = os.path.splitext(os.path.split(f)[-1])