Skip to content

Settle ambiguous lease requests and keep showing launch progress - #43

Merged
lydakis merged 7 commits into
mainfrom
claude/errand-fix-acquire
Oct 6, 2026
Merged

lydakis merged 7 commits into
mainfrom
claude/errand-fix-acquire

Conversation

@lydakis

@lydakis lydakis commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Before: if a cloud peer had dropped its offers, a lease request it answered with 404 stopped placement instead of moving on to the next cloud peer. If the answer to a lease request was lost and the retry was refused (for example with 403), the client asked another cloud peer while the first one might already be launching a machine for it. If both attempts went unanswered, the client gave up without withdrawing, so a launch it never heard about kept running until idle. Once a launch printed more than 100 progress lines, the client stopped showing new ones.

After: a 404 from a cloud peer with no offers is a refusal like 403, 412 and 429, and the next cloud peer is asked. A refusal only counts when it answers the request's first attempt. When an attempt's answer was lost and the retry does not bring the lease back, the run withdraws the request (which cancels a launch no other run waits for), says what became of it, and asks no other cloud peer. Launch progress keeps printing however long the launch log grows.

How: AcquireLease marks a failure that follows an unanswered attempt as uncertain (client.LeaseUncertain), which LeaseRefused never treats as a refusal; leaseRunner withdraws on it. WithdrawLeaseRequest reads a 404 as "no lease recorded for this request". Leases carry an internal progress_seq (the broker counts every progress line it adds), and followLease prints the lines numbered after the last one it showed instead of tracking the tail's length. Nothing changes for runs without --where or with no cloud peers, and there are no extra round trips on a successful acquire. A withdrawal request (up to 15s) is added only after an acquire whose answer was lost.

Closes items in #33: "A broker that dropped its offers stops placement", "A 403 on a retried acquire counts as a safe refusal", "No withdrawal after an ambiguous acquire failure", "progress tail rotation" / "Launch progress stops showing after 100 lines".

🤖 Generated with Claude Code

https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6


Generated by Claude Code

A refusal now lets the client ask the next cloud peer only when it
answers the request's first attempt; a 404 from a cloud peer that dropped
its offers counts as one. A request whose answer was lost and whose retry
did not bring the lease back is withdrawn, since the cloud peer may hold a
launching lease for it. Leases number their progress lines, so a client
following a launch keeps printing new lines after the bounded tail fills.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6

lydakis commented Oct 6, 2026

Copy link
Copy Markdown
Owner Author

github-advanced-security fails on GitHub's side (Copilot autofind quota/model error), as on every PR in this repo; it isn't this change, and a re-run returns 403 from here. CodeQL itself runs as a separate check.


Generated by Claude Code

@lydakis
lydakis marked this pull request as ready for review October 6, 2026 01:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T02:51:59.543959Z 8c350d5 New commits
🔒 Security Review ✅ Completed 2026-10-06T02:29:15.487945Z ccfe22a New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1597348425

ℹ️ 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".

Comment thread internal/client/leases.go Resolved
Comment thread cmd/errand/leases.go Resolved
A withdrawal can overtake a lost acquire attempt still on its way to the
cloud peer. The broker now remembers, in memory and bounded by count and
age, requests withdrawn before any lease was handed to them, and refuses
them with 410 if they arrive later, so they start no lease nobody waits
for. Clients count 410 as a refusal.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 60ed203074

ℹ️ 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".

Comment thread internal/cloud/withdrawn.go Resolved
One caller's flood of withdrawals for unknown requests could evict
another owner's live record of a withdrawn request. Each owner now has
its own cap, and evictions stay within that owner's entries; the number
of owners is capped separately so memory stays bounded.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ccfe22a10e

ℹ️ 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".

Comment thread internal/cloud/withdrawn.go Resolved
claude added 2 commits October 6, 2026 02:28
Owners include whoever the tailnet policy grants the lease action, which
the runner does not bound, so any eviction of a live record could be
forced by others. The record now drops entries only once they expire. A
withdrawal that finds no room (128 per owner, 4,096 in all) is refused
with 503 instead of being acknowledged; the client asks again within its
withdrawal budget and otherwise reports that the lease may exist.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

claude added 2 commits October 6, 2026 02:47
An aborted first attempt's handler can still be running when the retry
arrives, so the counter they share must be atomic.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@lydakis
lydakis merged commit a79211b into main Oct 6, 2026
7 of 8 checks passed
@lydakis
lydakis deleted the claude/errand-fix-acquire branch October 6, 2026 02:48

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8c350d5345

ℹ️ 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".

Comment thread internal/cloud/broker.go
Comment on lines 551 to +554
if l == nil {
// The request may still be on its way: unless it is remembered,
// the withdrawal settles nothing.
full := requestID != "" && !b.withdrawn.add(owner, requestID, time.Now())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Tombstone requests even when their first lease exists

Fresh evidence beyond the earlier tombstone fix is this l == nil guard: if the first POST created a lease but lost its response, a timed-out retry may still be executing when DELETE finds that first lease. The withdrawal removes the request without recording a tombstone, so the delayed retry can subsequently enter Acquire; it can rejoin a shared launch or, after the first lease starts releasing and capacity permits, create another paid lease after the client has exited. Record the withdrawn request even when a matching lease was found, with ordering that prevents a concurrent acquire from re-adding it.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants