mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-19 07:48:11 +00:00
Raise UnknownConfigError when a server is configured with an unknown storage plugin
This commit is contained in:
@ -355,8 +355,13 @@ class _StoragePlugins(object):
|
|||||||
"""
|
"""
|
||||||
storage_plugin_names = cls._get_enabled_storage_plugin_names(config)
|
storage_plugin_names = cls._get_enabled_storage_plugin_names(config)
|
||||||
plugins = list(cls._collect_storage_plugins(storage_plugin_names))
|
plugins = list(cls._collect_storage_plugins(storage_plugin_names))
|
||||||
# TODO Handle missing plugins
|
unknown_plugin_names = storage_plugin_names - {plugin.name for plugin in plugins}
|
||||||
# https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3118
|
if unknown_plugin_names:
|
||||||
|
raise configutil.UnknownConfigError(
|
||||||
|
"Storage plugins {} are enabled but not known on this system.".format(
|
||||||
|
unknown_plugin_names,
|
||||||
|
),
|
||||||
|
)
|
||||||
announceable_storage_servers = yield cls._create_plugin_storage_servers(
|
announceable_storage_servers = yield cls._create_plugin_storage_servers(
|
||||||
get_anonymous_storage_server,
|
get_anonymous_storage_server,
|
||||||
config,
|
config,
|
||||||
@ -375,7 +380,7 @@ class _StoragePlugins(object):
|
|||||||
config.get_config(
|
config.get_config(
|
||||||
"storage", "plugins", b""
|
"storage", "plugins", b""
|
||||||
).decode("ascii").split(u",")
|
).decode("ascii").split(u",")
|
||||||
)
|
) - {u""}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _collect_storage_plugins(cls, storage_plugin_names):
|
def _collect_storage_plugins(cls, storage_plugin_names):
|
||||||
|
@ -54,6 +54,7 @@ from allmydata.util import (
|
|||||||
base32,
|
base32,
|
||||||
fileutil,
|
fileutil,
|
||||||
encodingutil,
|
encodingutil,
|
||||||
|
configutil,
|
||||||
)
|
)
|
||||||
from allmydata.util.fileutil import abspath_expanduser_unicode
|
from allmydata.util.fileutil import abspath_expanduser_unicode
|
||||||
from allmydata.interfaces import IFilesystemNode, IFileNode, \
|
from allmydata.interfaces import IFilesystemNode, IFileNode, \
|
||||||
@ -1496,3 +1497,30 @@ introducer.furl = pb://abcde@nowhere/fake
|
|||||||
),
|
),
|
||||||
failed(Always()),
|
failed(Always()),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_storage_plugin_not_found(self):
|
||||||
|
"""
|
||||||
|
``client.create_client_from_config`` raises ``UnknownConfigError`` when
|
||||||
|
called with a configuration which enables a storage plugin that is not
|
||||||
|
available on the system.
|
||||||
|
"""
|
||||||
|
config = client.config_from_string(
|
||||||
|
self.basedir,
|
||||||
|
u"tub.port",
|
||||||
|
self.get_config(
|
||||||
|
storage_enabled=True,
|
||||||
|
more_storage=b"plugins=tahoe-lafs-dummy-vX",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
self.assertThat(
|
||||||
|
client.create_client_from_config(
|
||||||
|
config,
|
||||||
|
_introducer_factory=MemoryIntroducerClient,
|
||||||
|
),
|
||||||
|
failed(
|
||||||
|
AfterPreprocessing(
|
||||||
|
lambda f: f.type,
|
||||||
|
Equals(configutil.UnknownConfigError),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
Reference in New Issue
Block a user