Skip to content

Cloud leasing: deferred P2 findings and follow-ups #33

Open

Description

@lydakis

The cloud work was split into #31 (GPU where terms), #32 (leasing with provider commands) and #26 (Lambda provider). Those PRs are gated on P1 and above. Lower-severity review findings and agreed follow-ups are tracked here instead of being patched one at a time. Lease rules referenced below are the "Lease guarantees" in docs/DESIGN.md.

Open review findings (P2)

  • Busy observation lost on a failed write. When persisting LastBusy after a busy probe fails transiently, the old idle deadline can release a lease soon after the job finishes. The fix is to retry the write or keep the observation in memory until it persists. (internal/cloud/broker.go, watch) Fix in Keep cloud leases alive while in use and bound what the cloud peer keeps #45: the idle clock is kept in memory, so a failed write cannot lose a busy observation.
  • Lease identity dropped without a host key. A command provider that returns an ssh target without host_key gets no lease identity on the client, so its machine cannot admit the client's errand key. The fix is to offer the lease identity whether or not the host key is pinned. (cmd/errand/leases.go) Fixed in Check lease targets when acquire returns and reach leases by the client's key #46.
  • Invalid provider targets accepted. Targets with both url and ssh, a non-HTTP URL, a bad SSH name or a malformed host key are accepted and only fail later at the client. They should be rejected when acquire returns, with the same validation the client uses. (internal/cloud/provider.go) Fixed in Check lease targets when acquire returns and reach leases by the client's key #46.
  • Discovered leases are not claimed. A ready lease found through /v0/info (by --where or --on <lease>) becomes an ordinary candidate with no claim, so guarantee 5 (a full idle window from hand-out) does not cover it. The fix is to make reuse of a discovered lease go through the cloud peer as a hand-out. (cmd/errand/placement.go) Fix in Keep cloud leases alive while in use and bound what the cloud peer keeps #45: --where, --on <lease> and push --on <lease> claim the lease through the cloud peer right before their first request that changes anything.

Follow-ups from the outside reviews

  • Results end with the lease. Fixed in Keep a lease up while finished jobs' results are unfetched #59: unfetched results of jobs run during a lease keep it up until max_lifetime; persistent workspaces still end with it. Retained results and persistent workspaces on a leased machine end with it. One option is to keep the idle clock running until finished results have been fetched.
  • Admission race at the idle deadline. A job admitted in the second or two between an idle check and the termination can lose its machine. Closing this needs the runner to refuse new jobs while it is being drained. Handled by the claim in Keep cloud leases alive while in use and bound what the cloud peer keeps #45: a claim and an idle release are decided under one lock on the cloud peer, so whichever is recorded first wins, and a refused claim gets 409 and the run picks another lease. What remains is a submission that never claims (a direct URL), which fails visibly. A runner-side hold was built and then split out to branch claude/errand-lease-hold; George decided 2026-10-06 to leave it parked. Revive it only on evidence of jobs lost at the idle deadline, or if a supported way to submit without claiming appears (such as third-party clients).

Follow-ups found while fixing these


Generated by Claude Code

Activity

  1. lydakis commented on Oct 5, 2026

    @lydakis
    OwnerAuthor

    From the Codex review of #26 at bb8e342 (P2): progress tail rotation. Once an acquire command has printed more than 100 progress lines, the broker drops one old line for each new one. The tail's length then stays at 100, so followLease never sees it shrink and prints nothing more for that launch. The fix is to carry a progress sequence number in the lease, so the client prints the lines after the last one it showed, rather than treating a shorter tail as the sign that lines were trimmed.


    Generated by Claude Code

  2. lydakis commented on Oct 5, 2026

    @lydakis
    OwnerAuthor

    From the Codex review of #35 at 4183fc8 (P2): SSH admission on Windows targets. The script that admits another device's key is POSIX shell (umask, mkdir -p, a while read loop). A Windows runner leased over OpenSSH would leave the key pending, so reuse from a second device, and --on, would wait and then fail. A fix needs admission that works on any target, or one chosen by the leased runner's OS.


    Generated by Claude Code

  3. lydakis commented on Oct 5, 2026

    @lydakis
    OwnerAuthor

    One more P2, from the Codex review of #35:

    • Idle lease released during admission. If another device names a ready lease at or just after its IdleUntil, the admission request queues the key but doesn't refresh LastBusy or add a holder. The worker admits the key, probes before the client can submit, and then releases the still-idle lease. The fix is to record a usage window or a temporary holder for the admission request. (internal/cloud/broker.go, AdmitLeaseKey) Fixed in Keep cloud leases alive while in use and bound what the cloud peer keeps #45.

    Generated by Claude Code

  4. lydakis commented on Oct 5, 2026

    @lydakis
    OwnerAuthor

    More P2s from the latest Codex reviews of #32 and #26. Two of the #32 findings repeat items already listed here: lease identity without a host key, and invalid provider targets, which now also notes that they keep the machine until acquire_timeout.


    Generated by Claude Code

  5. lydakis commented on Oct 5, 2026

    @lydakis
    OwnerAuthor

    #32 changes since the last update:

    New P2s from the Codex review of #32 at 0600050:


    Generated by Claude Code

  6. lydakis commented on Oct 5, 2026

    @lydakis
    OwnerAuthor

    One more P2, from the Codex review of #35 at 0cef48c:


    Generated by Claude Code

  7. lydakis commented on Oct 5, 2026

    @lydakis
    OwnerAuthor

    Two more P2s, from the Codex review of #32 at 307e8df:


    Generated by Claude Code

  8. lydakis commented on Oct 6, 2026

    @lydakis
    OwnerAuthor

    One more P2, from the Codex review of #35 at b872a8f:

    • An admitted lease peer can get a too-short name. When this device is let into a lease by name, admitThisDevice lists only that lease. If another ready lease ends in the same four characters, the returned peer is named with the ambiguous short suffix, and errand peers --on <name> shows that unusable name. The fix is to name the peer against the full lease list. (cmd/errand/leases.go, admitThisDevice) Fixed in Check lease targets when acquire returns and reach leases by the client's key #46.

    Generated by Claude Code

  9. lydakis commented on Oct 6, 2026

    @lydakis
    OwnerAuthor

    Three more P2s, from the Codex review of #32 at fcf95d8:

    • A ready lease that stops working keeps being handed out. Since 7e853c4, handing out a ready lease counts as use before the client has checked the machine. If the machine becomes unreachable or stops matching where, the client's withdrawal no longer ends the lease, and each new run refreshes its idle window and is sent to the same machine. Only the lifetime limit or errand leases release ends it. The fix is to count the hand-out as use only once the client has checked the target, or to retire a ready lease whose hand-out fails that check. (internal/cloud/broker.go, share) Fixed in Keep cloud leases alive while in use and bound what the cloud peer keeps #45.
    • No withdrawal after an ambiguous acquire failure. When AcquireLease runs out of retries on a transport error or a bad response, the cloud peer may already hold the request, but the client returns without withdrawing it. That holder is then released only by the idle or lifetime rule. (cmd/errand/leases.go, leaseRunner) Fixed in Settle ambiguous lease requests and keep showing launch progress #43.
    • A 403 on a retried acquire counts as a safe refusal. If the first request's response was lost and the caller lost the lease action before the retry, the 403 sends the client to another supplier while the first lease stays held. A 403 is safe to fall through only before any ambiguous attempt. (internal/client/leases.go) Fixed in Settle ambiguous lease requests and keep showing launch progress #43.

    Generated by Claude Code

  10. lydakis commented on Oct 6, 2026

    @lydakis
    OwnerAuthor

    Four more P2s, from the Codex review of #26 at 7a565c4 (its last commit before merge):


    Generated by Claude Code

  11. lydakis commented on Oct 6, 2026

    @lydakis
    OwnerAuthor

    Two more, from the live Lambda run of #26 and a local run of the suite on main:

    • A relative state directory stalls SSH leases until acquire_timeout. errand serve --state-dir cloud/state (or a relative state_dir) is accepted, but the cloud peer's SSH identity then lives at a relative path, which ssh_pin.go rejects. In the live run the instance booted and errand installed, then the lease sat in "waiting for errand on the machine" with not answering yet: SSH identity file "cloud/state/lambda/lambda_ed25519" must be an absolute path, billing until it was released by hand. The fix is to resolve the state directory to an absolute path at startup, or refuse a relative one. (cmd/errand/main.go, serve) Fixed in main (see below).
    • Two broker tests flake under load. On main, go test -race -count=1 ./... on an M-series Mac failed in internal/cloud on both of two runs: TestFailedLaunchesAreReleased (acquire did not finish within 200ms, the 200ms AcquireTimeout racing a shell script's startup) and TestReleaseRetriesUntilItSucceeds (still releasing after a fixed 100ms sleep). Both pass alone (4/4) and passed in CI. The fix is to wait for the expected progress line instead of sleeping, and give the acquire timeout more headroom. (internal/cloud/broker_test.go) Fixed in Fix the cloud tests broken or flaky on main #41.

    Generated by Claude Code

  12. lydakis commented on Oct 6, 2026

    @lydakis
    OwnerAuthor

    On the two items above:

    • Relative state directory: already fixed on main. cloud.New makes the state directory absolute before any provider sees it (internal/cloud/broker.go:145), and the Lambda key directory is derived from it (internal/cloud/lambda.go:265). The live run that hit this was on an earlier build.
    • Flaky broker tests: fixed in Fix the cloud tests broken or flaky on main #41. Both tests now wait on the broker instead of a fixed time, and six concurrent race runs of internal/cloud pass.

    Generated by Claude Code

  13. lydakis commented on Oct 6, 2026

    @lydakis
    OwnerAuthor

    From #42 (Codex review of a8de1f3), P2:

    • A retried request for a ready lease is not tied to that lease. Since End ready leases only by the idle and lifetime rules #42, handing out a ready lease only refreshes its idle clock and does not record the request ID, so a retry after a lost response is matched again rather than recognised. In practice the retry gets the same ready lease, since it still matches. It differs only if the lease ended between the lost answer and the retry, or another matching lease sorts first; then the retry gets another lease or starts a launch. Possible fix: keep a small, bounded set of recent request IDs on ready handouts. End ready leases only by the idle and lifetime rules #42 (comment)

    #42 also makes these earlier items moot once it merges: the replay-time 403 after ready, holders retired between probes, and "every run gave it up". The "unusable ready lease renewed" item still applies.


    Generated by Claude Code

  14. lydakis commented on Oct 6, 2026

    @lydakis
    OwnerAuthor

    Follow-ups from #47 (the Lambda catalog), noticed while verifying 4a3c7aa. Neither one rents anything:

    • Offers above max_price_per_hour are advertised like any other. As of 4a3c7aa the broker refuses them with the reason before launching, and placement only tries one when no cheaper offer matches. Until then, though, errand peers and errand doctor list them as leasable, and a run prints "leasing from " before the refusal. A possible fix is to carry the reason on proto.Offer, so the client skips those offers and explains them up front. That adds a field to the daemon API, so it needs George's OK.
    • A dev-build cloud peer without errand_binary lists every instance type. Each lease then fails before anything is rented. The same "unavailable, with a reason" field would show this in placement.

    Generated by Claude Code

  15. lydakis commented on Oct 6, 2026

    @lydakis
    OwnerAuthor

    Decided: no unavailable field on advertised offers. An offer that is over max_price_per_hour (or has no errand build on a dev cloud peer) keeps failing at lease time with its reason, so the fix is to raise the limit. Dropped from the follow-up list.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions