From a55719cdc4538696eb3d231ea501e8527f64bbb4 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Wed, 16 Oct 2019 19:56:29 -0400 Subject: [PATCH 1/2] Raise UnknownConfigError when a server is configured with an unknown storage plugin --- src/allmydata/client.py | 11 ++++++++--- src/allmydata/test/test_client.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/allmydata/client.py b/src/allmydata/client.py index 3fca70b03..e45666049 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -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): diff --git a/src/allmydata/test/test_client.py b/src/allmydata/test/test_client.py index 098ab461b..824db82fe 100644 --- a/src/allmydata/test/test_client.py +++ b/src/allmydata/test/test_client.py @@ -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), + ), + ), + ) From 351c7bad452e40e44c843ec93a31a807a08d36cc Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Wed, 16 Oct 2019 19:58:15 -0400 Subject: [PATCH 2/2] news fragment --- newsfragments/3118.minor | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 newsfragments/3118.minor diff --git a/newsfragments/3118.minor b/newsfragments/3118.minor new file mode 100644 index 000000000..e69de29bb