From: Brian Warner Date: Wed, 18 Feb 2009 02:30:53 +0000 (-0700) Subject: change RIStorageServer.remote_add_lease to exit silently in case of no-such-bucket... X-Git-Tag: allmydata-tahoe-1.4.0~199 X-Git-Url: https://git.rkrishnan.org/...?a=commitdiff_plain;h=e9563ebc02a67314060f38e8533e2e1e551ce9a6;p=tahoe-lafs%2Ftahoe-lafs.git change RIStorageServer.remote_add_lease to exit silently in case of no-such-bucket, instead of raising IndexError, because that makes the upcoming --add-lease feature faster and less noisy --- diff --git a/src/allmydata/interfaces.py b/src/allmydata/interfaces.py index b92e919d..bab8ed91 100644 --- a/src/allmydata/interfaces.py +++ b/src/allmydata/interfaces.py @@ -123,7 +123,9 @@ class RIStorageServer(RemoteInterface): """ Add a new lease on the given bucket. If the renew_secret matches an existing lease, that lease will be renewed instead. If there is no - bucket for the given storage_index, IndexError will be raised. + bucket for the given storage_index, return silently. (note that in + tahoe-1.3.0 and earlier, IndexError was raised if there was no + bucket) """ return None diff --git a/src/allmydata/storage.py b/src/allmydata/storage.py index ac6de53c..29bce1d4 100644 --- a/src/allmydata/storage.py +++ b/src/allmydata/storage.py @@ -1074,17 +1074,10 @@ class StorageServer(service.MultiService, Referenceable): lease_info = LeaseInfo(owner_num, renew_secret, cancel_secret, new_expire_time, self.my_nodeid) - found_buckets = False for sf in self._iter_share_files(storage_index): - found_buckets = True - # note: if the share has been migrated, the renew_lease() - # call will throw an exception, with information to help the - # client update the lease. sf.add_or_renew_lease(lease_info) self.add_latency("add-lease", time.time() - start) - if not found_buckets: - raise IndexError("no such storage index to do add-lease") - + return None def remote_renew_lease(self, storage_index, renew_secret): start = time.time() diff --git a/src/allmydata/test/test_storage.py b/src/allmydata/test/test_storage.py index 96d1c410..4c054443 100644 --- a/src/allmydata/test/test_storage.py +++ b/src/allmydata/test/test_storage.py @@ -502,8 +502,8 @@ class Server(unittest.TestCase): self.failUnlessEqual(len(leases), 3) self.failUnlessEqual(set([l.renew_secret for l in leases]), set([rs1, rs2, rs2a])) - # add-lease on a missing storage index is an error - self.failUnlessRaises(IndexError, ss.remote_add_lease, "si18", "", "") + # add-lease on a missing storage index is silently ignored + self.failUnlessEqual(ss.remote_add_lease("si18", "", ""), None) # check that si0 is readable readers = ss.remote_get_buckets("si0") @@ -1062,8 +1062,8 @@ class MutableServer(unittest.TestCase): s0 = MutableShareFile(os.path.join(bucket_dir, "0")) self.failUnlessEqual(len(s0.debug_get_leases()), 1) - # add-lease on a missing storage index is an error - self.failUnlessRaises(IndexError, ss.remote_add_lease, "si18", "", "") + # add-lease on a missing storage index is silently ignored + self.failUnlessEqual(ss.remote_add_lease("si18", "", ""), None) # re-allocate the slots and use the same secrets, that should update # the lease