Merge pull request #663 from tahoe-lafs/3118.meaningful-plugin-exceptions

Raise a meaningful exception for misconfigured storage server plugins.
This commit is contained in:
Jean-Paul Calderone 2019-10-17 09:28:49 -04:00 committed by GitHub
commit 85bbb70aca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 3 deletions

0
newsfragments/3118.minor Normal file
View File

View File

@ -355,8 +355,13 @@ class _StoragePlugins(object):
"""
storage_plugin_names = cls._get_enabled_storage_plugin_names(config)
plugins = list(cls._collect_storage_plugins(storage_plugin_names))
# TODO Handle missing plugins
# https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3118
unknown_plugin_names = storage_plugin_names - {plugin.name for plugin in plugins}
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(
get_anonymous_storage_server,
config,
@ -375,7 +380,7 @@ class _StoragePlugins(object):
config.get_config(
"storage", "plugins", b""
).decode("ascii").split(u",")
)
) - {u""}
@classmethod
def _collect_storage_plugins(cls, storage_plugin_names):

View File

@ -54,6 +54,7 @@ from allmydata.util import (
base32,
fileutil,
encodingutil,
configutil,
)
from allmydata.util.fileutil import abspath_expanduser_unicode
from allmydata.interfaces import IFilesystemNode, IFileNode, \
@ -1496,3 +1497,30 @@ introducer.furl = pb://abcde@nowhere/fake
),
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),
),
),
)