#3773 closed task

Merge adding lease with renewing lease — at Version 3

Reported by: itamarst Owned by: itamarst
Priority: normal Milestone: HTTP Storage Protocol
Component: unknown Version: n/a
Keywords: Cc:
Launchpad Bug:

Description (last modified by itamarst)

  1. From a client perspective, the goal is just to have a lease, whether it's a new lease or renewing a lease is irrelevant; renewing is essentially an optimization detail on server side.
  2. Cancelling leases is not actually supported.
  3. The way lease renewal secrets are generated is likely to change in the switchover from foolscap to HTTP.
  4. Internally, the server _already_ treats renewing a lease as potentially adding a new one if renewal fails.

As such, the distinction between adding a lease and renewing a lease is unnecessary (presuming item 4 is actually correct!). We would like to simplify HTTP protocol by removing it, and we need to make sure server can gracefully handle clients switching their renewal secret.

Therefore, we should merge the two into a single operation:

  1. Validate item 4 above, since it's critical requirement for the rest of this.
  2. In Foolscap client, switch to only using renewal code path.
  3. Make sure server creating new lease when renewal fails is well tested, so users don't lose data.
  4. On server-side, leave new lease Foolscap endpoint in place for backwards compat.
  5. In new GBS HTTP protocol spec, switch to a single end point for lease creation/renewal, and remove all references to lease cancellation secret.
  6. Clients should continue to try to pass in the same renewal secret, the way they do now.

Change History (3)

comment:1 Changed at 2021-08-18T15:14:15Z by itamarst

  • Description modified (diff)

comment:2 Changed at 2021-08-18T15:20:51Z by exarkun

Regarding item 4 from the first list:

Here is the implementation of add_lease from allmydata/storage/server.py:

    def remote_add_lease(self, storage_index, renew_secret, cancel_secret,
                         owner_num=1):
        start = time.time()
        self.count("add-lease")
        new_expire_time = time.time() + 31*24*60*60
        lease_info = LeaseInfo(owner_num,
                               renew_secret, cancel_secret,
                               new_expire_time, self.my_nodeid)
        for sf in self._iter_share_files(storage_index):
            sf.add_or_renew_lease(lease_info)
        self.add_latency("add-lease", time.time() - start)
        return None

And here is the implementation of MutableShareFile.add_or_renew_lease from `allmydata/storage/mutable.py:

    def add_or_renew_lease(self, lease_info):
        precondition(lease_info.owner_num != 0) # 0 means "no lease here"                                                                                                                     
        try:
            self.renew_lease(lease_info.renew_secret,
                             lease_info.expiration_time)
        except IndexError:
            self.add_lease(lease_info)

And here is the implementation of ShareFile.add_or_renew_lease from `allmydata/storage/immutable.py:

    def add_or_renew_lease(self, lease_info):
        try:
            self.renew_lease(lease_info.renew_secret,
                             lease_info.expiration_time)
        except IndexError:
            self.add_lease(lease_info)

(woops nice divergence in safety properties there)

comment:3 Changed at 2021-08-18T15:27:15Z by itamarst

  • Description modified (diff)
  • Summary changed from Merge adding lease with renewing lease (for immutables) to Merge adding lease with renewing lease
Note: See TracTickets for help on using tickets.