mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-08 03:14:21 +00:00
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
This commit is contained in:
parent
fde2289e7b
commit
e9563ebc02
@ -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
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user