]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
client.py: throw error when reserved_space= is unparseable. Closes #1812.
authorBrian Warner <warner@lothar.com>
Wed, 20 Mar 2013 22:25:10 +0000 (15:25 -0700)
committerDavid-Sarah Hopwood <david-sarah@jacaranda.org>
Wed, 20 Mar 2013 23:24:22 +0000 (23:24 +0000)
This should now fail quickly (during "tahoe start"). Previously this
would silently treat an unparseable size as "0", and the only way to
discover that it had had a problem would be to look at the foolscap log,
or examine the storage-service web page for the unexpected "Reserved
Size" number.

src/allmydata/client.py
src/allmydata/test/test_client.py

index ad804248cbc0fea1d4e668134b69f8e6e76f95e7..23ca8b3d19f33248df2067f9d7deedb2444d924b 100644 (file)
@@ -257,12 +257,12 @@ class Client(node.Node, pollmixin.PollMixin):
         storedir = os.path.join(self.basedir, self.STOREDIR)
 
         data = self.get_config("storage", "reserved_space", None)
-        reserved = None
         try:
             reserved = parse_abbreviated_size(data)
         except ValueError:
             log.msg("[storage]reserved_space= contains unparseable value %s"
                     % data)
+            raise
         if reserved is None:
             reserved = 0
         discard = self.get_config("storage", "debug_discard", False,
index ec713abc4bb15b458ee06525ea0a9705863be8c6..61d0860395282d5e781f123d330edb921d94a833 100644 (file)
@@ -132,8 +132,7 @@ class Basic(testutil.ReallyEqualMixin, unittest.TestCase):
                            "[storage]\n" + \
                            "enabled = true\n" + \
                            "reserved_space = bogus\n")
-        c = client.Client(basedir)
-        self.failUnlessEqual(c.getServiceNamed("storage").reserved_space, 0)
+        self.failUnlessRaises(ValueError, client.Client, basedir)
 
     def _permute(self, sb, key):
         return [ s.get_longname() for s in sb.get_servers_for_psi(key) ]