Repository navigation
Keep cloud leases alive while in use and bound what the cloud peer keeps - #45
Conversation
A ready lease's idle clock is now kept in memory, so a busy observation is never lost to a failed write, and naming a lease to let a device in restarts it as a hand-out does. A ready lease is handed out only after the broker reaches its runner and finds it still matching; one that fails is passed over without a new idle window. Before an idle release the broker has the runner refuse new jobs through the quiesce hold errand setup uses, so a job admitted after the idle check keeps the lease; a runner that cannot be held (over the tailnet) is released on the idle check alone. Requests handed a ready lease are remembered (the latest 32), so a retry gets the same lease, and a retry is recognised before the broker refuses for having no offers. A lease admits at most 16 keys. Ended leases have no worker, and only the 32 newest are kept for a week. waitReady no longer reads the lease record without the lock. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
Probing a ready lease before each hand-out added an SSH round trip to every reuse. The watch's periodic probe now asks with the lease's where and records on the in-memory lease whether the machine answered and still matches. A hand-out reads that instead. A lease just made ready counts as checked by its launch. A lease whose latest probe failed is passed over, without a new idle window, until a probe succeeds again. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
|
Generated by Claude Code |
The runner grants the quiesce hold only to its own user on its local socket, so a tailnet lease was released on the idle check alone. A Lambda tailnet machine now also takes SSH, from the cloud peer's key only. The cloud peer already logs in with that key to install errand and has root there. The provider records an SSH drain target with the pinned host key, which the broker uses for the hold while clients keep using the tailnet. No new config key or authorization rule. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f516998047
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
…o run on An idle release now skips the hold only when no one can be holding the machine: it has no SSH route, its runner refuses the hold, or the cloud peer's probe could not reach it. A hold that fails otherwise keeps the lease and is tried again at the next idle check. Ready leases restored after a restart are not handed out, by request or by name, until the worker's first probe reaches them. Admit refuses a lease its latest probe found unusable (409), as Acquire passes it over. Pruning keeps the ended leases that ended last. A run that names a ready lease with --on now asks the cloud peer for it through admission, which starts a full idle window. Commands that only read keep resolving the name from the cloud peer's info alone. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 33d5079b01
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A drain of a drainable runner that keeps failing no longer keeps the lease until max_lifetime: once holds have failed for one more idle_timeout while the runner stayed idle, the lease is released without the hold, with a progress line saying so. A runner seen busy resets this. end() read the lease's owner after unlocking while the worker rewrites the record under the lock; the check now happens under the lock. TestUnusableReadyLeaseNotHandedOut counted probes before the watch's first probe could have run, so that probe and the one the hand-out wakes could both land after the count. It now waits for the watch's first probe. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
The Lambda drain target uses lambdaUser, which replaced the user setting. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
Letting a device into a lease no longer claims it: the admit request's use field, set only by a run naming the lease, restarts the idle window and refuses a lease the cloud peer found unusable, in the same request. A read-only command never extends a lease, whether or not the device was let in before. A drain that finds the runner busy is the only sight of a job admitted after the idle probe, so it now restarts the idle window too. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1dfdb4a1fd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Acquire keeps main's two passes around the catalog refresh, with the replay lookup before the no-offers refusal and ready leases whose latest probe failed passed over; the passed-over note is written once, by the pass that answers. A lease keeps both its offer and its probe and hold state. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
|
You have reached your Codex usage limits for security reviews. Please try again later. |
acquire refuses a withdrawn request after the replay lookup and before the no-offers refusal; hand-outs keep going through shareLocked, which also ties a ready lease to its request. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
…usy drain; claim --on leases late The idle release's hold now goes with the lease into releasing: its token is recorded, and the releasing worker renews it every minute until the provider confirms the machine is gone, across cloud peer restarts. The runner renews a live hold by its token and grants a lapsed one afresh only while idle; a runner that took work after its hold lapsed is released anyway, with a progress line saying the hold was lost. A drain that ends past max_lifetime no longer keeps the lease, whatever it found. A run naming a lease with --on claims it at the late resolution point, after local preparation, as a rented machine is acquired, so a run that fails locally never renews the lease. DESIGN.md lease guarantee 4 now states the lease lifecycle as one table. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
Admit keeps main's key check, allowing an empty key for a claim, and record.admit compares keys without comments while keeping the per-lease cap. Test keys are well-formed, and the Lambda drain target is checked against the new host key and key path. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d65f600f5b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ing it A run's claim on a lease it names now goes through a BeforeSubmit hook that runs after every local step (change state, project ID, snapshot negotiation, the submission mark), right before the submit request, and before the create request for a workspace, instead of with target resolution. The cloud peer now chooses the hold's token and records it, with when, before asking the runner, which takes or renews a hold under the caller's token. Taking, renewing and lifting are repeatable by that token, so no stop of the cloud peer can leave a hold it does not know about: a ready lease with a recorded hold has it lifted before it is handed out again, or waits out the runner's five minutes when it cannot be lifted. DESIGN.md's lifecycle table gains this crash point and how each recorded step survives a restart. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3d83c8f849
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Whether a lease can be handed out, to a run asking for a machine or one naming it to run on, is now one function of the recorded state: a lease that is not ready, has a hold recorded that has not lapsed, or whose latest check failed is refused, whatever the runner last answered. A drain whose answer was lost or timed out therefore keeps the lease withheld until the next idle check lifts the hold or it lapses. On the client, the use claim runs as the last step before the request that places work goes out, after every selection check, once per attempt; retries of the request do not claim again. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed09d5d369
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
You have reached your Codex usage limits for security reviews. Please try again later. |
1 similar comment
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 938050faf3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The hold an idle release took on the runner, its recorded token, renewal and lifting, the drain target, the named quiesce on the runner and the tailnet machine's SSH transport are removed; they continue on their own branch as a separate decision. An idle release is again recorded through the update path once releaseReason holds, under the same lock a run's claim of the lease takes, so whichever is recorded first wins and a claim that comes second is refused. errand push --on <lease> now claims the lease, once per push, right before its first request that changes the workspace, as runs and workspace creation do; a push that fails before then does not renew it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d1dc2c283e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A command's claim of a lease now runs after its request is built, right before it is sent: for runs and workspace creation after every check, and for push after the upload negotiation and every local step, before the upload or the apply, once per push. A lease the idle or lifetime rule would release now is refused like any other, so the hand-out rule and the release rule cannot disagree between idle checks. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 21d3b864ca
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A claim of a lease past its idle deadline but not yet released is safe: it restarts the idle window under the lock the release is decided under, so the lease then stays. Only the lifetime, which no claim extends, makes a ready lease refused before its worker releases it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7c554d816f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex security review Generated by Claude Code |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex security review Generated by Claude Code |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
|
@codex security review Generated by Claude Code |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex security review Generated by Claude Code |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
1 similar comment
|
You have reached your Codex usage limits for security reviews. Please try again later. |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex security review Generated by Claude Code |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Before: a busy lease could be released soon after its job ended if one write of its idle clock failed. A device let into a lease at its idle deadline could see the lease released before it submitted, and a run, workspace creation or push named on a lease with
--ondid not renew its idle window. A ready lease whose machine had become unreachable, or stopped matching, kept being handed out, and each hand-out renewed it. A retried request for a ready lease was matched again rather than recognised, and a retry that reached a cloud peer that had lost its offers was refused instead. Each ended lease kept a goroutine for a week, the lease history and each lease's admitted keys grew without bound, and the launch check and release read the lease record without its lock.After: a lease stays up while its machine has work, even when its record cannot be written. Naming a lease with
--on, from any device, to run on, create a workspace on, or push to gives a full idle window, as a hand-out does, claimed right before the command submits. Commands that only read, such aserrand psorerrand logs, don't renew it, even from a new device they let in, and neither does a command that fails before it can submit. A ready lease is handed out only if the cloud peer's latest check of it, at launch or at the last idle check, reached the machine and found it still matching. A lease whose latest check failed is not handed out (the run gets another lease or a new launch), and--onrefuses it with the reason. Its idle window is not renewed, so it ends once idle. After a cloud peer restart, ready leases wait for their first check. Reusing a ready lease costs no extra round trip. A claim of a lease and its idle release are decided under one lock: whichever is recorded first wins, so a claim past the idle deadline but before the release keeps the lease, and a claim once the release is recorded gets 409, so the command places no work there. No claim extendsmax_lifetime: a lease at it is refused. A request asked again gets the lease it was handed, even after the cloud peer's offers are removed, if that lease may still be handed out; otherwise it is answered as a new request. A lease lets in at most 16 devices. The cloud peer keeps the 32 leases that ended last, for up to a week, and no worker for them. A release the provider is still confirming is shown once in the lease's progress, not at every poll.The idle-release hold (the cloud peer having the runner refuse new jobs before releasing it, kept through the release) was split out to branch
claude/errand-lease-holdas a separate decision. The admission race at the idle deadline is handled here by the claim. What remains is the case of a job submitted to the machine without a claim, after the last idle check and before the release, which can still be lost with the machine.How:
LastBusyis kept in memory only. A restart already starts a full idle window, so nothing is lost by not writing it. The watch's periodic probe of a ready lease now asks with the lease'swhere. It records on the in-memory lease whether the machine answered and still matches, or why not. Whether a lease can be handed out is one function of that record (lease.refusal): a lease that is not ready, at or past its lifetime (before the worker has released it), or whose latest check failed or has not happened since a restart, is refused.Acquire(including a request asked again), andAdmitwithuse, go through it;Acquirereads the recorded check instead of probing, so a hand-out adds no round trip. A lease just made ready counts as good, since its launch has just checked it. A lease passed over gets a progress line saying why. Passing it over, rather than ending it, keeps lease guarantee 5 for runs that may still be using it after a transient failure on the cloud peer's side. A later successful probe makes it eligible again. The idle release is recorded through the update path, which re-evaluatesreleaseReasonagainst the record under the broker lock, the same lockAdmitwithusesetsLastBusyunder. A command that names a ready lease with--onasks the cloud peer for it through the existing admission request (POST /v0/leases/<id>/ssh-keys), with a new internalusefield set. The client's own key is sent, and none is needed for a tailnet lease. Only a command placing work setsuse, from aBeforeSubmithook. It runs once the request is built, right before it is sent, after every local step, read and check. For runs and workspace creation that is after change state, project ID, snapshot negotiation, the selection check and the submission mark, once per attempt (retrying the request, or re-shipping a full snapshot, does not claim again). Forerrand pushit is once per push (each batch of a watch), after the checkpoint and upload negotiations, right before the first request that changes the workspace: the upload, or the apply when the upload was already staged or an interrupted apply is being finished. Another command naming a lease from a new device sends only its key, which neither renews the lease nor is refused. Ready hand-outs append their request ID toRequests, keeping the latest 32, and the replay lookup now runs before the no-offers refusal. Ended leases are pruned by count, ranked by when they ended, and by age, when a lease ends, at start-up and on list.waitReadytakes thewherecaptured under the lock, and release checks the lease's owner under it.Closes items in #33: busy observation lost on a failed write; idle lease released during admission (by the claim); admitted keys per lease are unbounded; ended leases keep a worker for 7 days; unlocked read of
l.Wherein waitReady; request replay after offers are removed; a retried request for a ready lease is not tied to that lease; a ready lease that stops working keeps being handed out.🤖 Generated with Claude Code
https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
Generated by Claude Code