Skip to content

🤖 feat: create CoderWorkspacePool members on demand for waiting claims, keep claims of a missing pool, and mark a claim Lost when its workspace is deleted - #388

Merged
ThomasK33 merged 8 commits into
mainfrom
feat/workspace-pool-claim-lifecycle
Oct 15, 2026
Merged

ThomasK33 merged 8 commits into
mainfrom
feat/workspace-pool-claim-lifecycle

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Summary

This PR finishes the claim side of the dormant CoderWorkspacePool reconcilers (plan 6.2 step 11 rule 3, 6.3 steps 7 and 10, decision D4). Nothing registers the reconcilers yet, so no user sees a change.

  1. On-demand creation. The pool now wants spec.replicas plus the waiting claims, for both creates and scale-down deletes. A waiting claim is one that no member holds, that is not deleting, and that is not Lost. So a pool at replicas: 0 creates one member per waiting claim, binds it once it is ready, and then wants nothing more.
  2. PoolNotFound. A reconcile for a pool that is gone or being deleted writes the status of its claims. A claim that a member holds stays as its member says, so a bound claim stays Bound after its pool is deleted: the claim, not the pool, controls the bound member. The other claims wait with Pending PoolNotFound. The same holds for a claim on a pool that never existed.
  3. Bound-member watch (Lost). After the one extension at bind, a bound member keeps reading its workspace every 60 s, with the identity checks. Builds by the claimant, a stop included, change nothing. Once Coder answers 410 (the workspace is deleted), the member fails with WorkspaceDeleted=True, and its claim becomes Lost (Stalled=True, reason WorkspaceDeleted). Lost is final: the claim never binds again, also after its failed member is gone.

Refs #153

Background

This is PR 11b of the CoderWorkspacePool stack (#153). It stacks on PR 11a (#387).

Before this PR, a bound member stopped reconciling after the bind extension (RequeueAfter: 0). It now polls every 60 s, as a ready unclaimed member does. TestPoolMemberExtendsOnceAtBind expects that now. Rule 2 (the latest build must be the start build) still runs for a bound member before its extension, because it is the provenance check before that write. After the extension, the member returns before rule 2, so a claimant's builds never fail it.

Validation

New tests (coderworkspacepool_claim_lifecycle_test.go). I wrote them first and ran them on PR 11a: all 3 failed, as did the changed TestPoolMemberExtendsOnceAtBind. With this PR they pass.

  • TestPoolCreatesOnDemand: replicas: 0 and no claim give no member. One claim gives exactly one member. Once it is ready, the claim binds it, and the pool creates no more.

  • TestPoolDeleteKeepsBoundClaims: one member bound to the older of two claims, then the pool is deleted. The bound member keeps the claim as its controller, and its claim stays Bound with its workspace name and owner. The other claim waits with PoolNotFound, and so does a claim on a pool that never existed.

  • TestPoolClaimLostWhenWorkspaceDeleted: a real workspace, bound and extended. The member requeues after 60 s. A stop build by the claimant leaves the member Ready. After Coder deletes the workspace, the member fails with WorkspaceDeleted=True, and the claim becomes Lost with WorkspaceDeleted. After the failed member is gone, a new ready member is not bound to the Lost claim.

  • Changed: TestPoolBindsOldestClaimFirst now expects 3 members (the bound member, a replacement for replicas: 1, and one for the waiting claim).

  • TestPoolOrphanClaimKeepsOwnerName (round 1): the bind lands, the reconcile then fails, and the pool is deleted. The orphan reconcile shows Bound with owner tester.

  • TestPoolClaimLostWhenWorkspaceDeleted also runs a reconcile whose claim list shows the Lost claim without status, after its failed member is gone: no bind.

Codex review round 1: 4277241744 (a Lost claim on a stale cache) and 4277241752 (the owner name of an orphaned claim after a crash) are fixed in #387 (c4824691: the uncached claim read before a bind, and the owner name stored before the bind) and tested here in 23e6281d. Both tests failed on the previous head.

Codex review round 2: 4277392817 (a stale Lost claim counted as demand when no member was free) is fixed in #387 (c8c6095d: every waiting claim is read again without the cache before poolWant) and tested here in e6eb14ff: TestPoolClaimLostWhenWorkspaceDeleted runs a stale-cache reconcile with no free member, and no member is created. It failed on the previous head.

Mutation checks: I removed one control at a time, and each removal made a named test fail (10 of 10): the claims in want, counting only waiting claims in want, the missing-pool reconcile, keeping bound claims of a missing pool, setting Lost, never binding a Lost claim, the bound member's read after the extension, the early return before rule 2 after the extension, the owner name stored before the bind, and the uncached claim read for a Lost claim.

Gates on the final commit: drift (codegen, manifests, installer, API reference: no diff), make docs-check, dormant-CRD guard, docs lint and spelling, make verify-vendor, make build, make lint, actionlint, make test, make test-integration, make vuln, race. All passed.

Size

286 hand-written lines (114 production, 172 test, counting removals). No generated files.

Risks

None for users. The reconcilers are dormant. Recorded for PR 12: a workspace that the claimant renames fails the identity check of a bound member (OwnershipUnknown), so its claim shows Bound with Ready=False.


Generated with mux • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $173.65

…nd write the claim status

Change-Id: Ia47cdccaaad51b9a7cfa069a5e5de45de22be757
Signed-off-by: Thomas Kosiewski <tk@coder.com>
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 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-15T00:05:17.840761Z 380bae8 Manual request
🔒 Security Review ✅ Completed 2026-10-15T00:05:04.187187Z 380bae8 Manual request
ℹ️ 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

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 18ab922fb4

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@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: 18ab922fb4

ℹ️ 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/controller/coderworkspacepool_claim.go Outdated
Comment thread internal/controller/coderworkspacepool_claim.go
…pool, repair the pool label, and store the owner name before the bind

Change-Id: Id61727ee0e9898f2def86bd569dbc814c6b44fa4
Signed-off-by: Thomas Kosiewski <tk@coder.com>
@ThomasK33
ThomasK33 force-pushed the feat/workspace-pool-claim-lifecycle branch from 18ab922 to 23e6281 Compare October 14, 2026 23:28
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 23e6281d96

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@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: 23e6281d96

ℹ️ 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/controller/coderworkspacepool_claim.go
…eplaced claim, and check the holder again before Lost

Change-Id: I536b0015fc519c2ffd84a81fb4b055c5f0a0b871
Signed-off-by: Thomas Kosiewski <tk@coder.com>
@ThomasK33
ThomasK33 force-pushed the feat/workspace-pool-claim-lifecycle branch from 23e6281 to e6eb14f Compare October 14, 2026 23:46
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: e6eb14ff5c

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

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: e6eb14ff5c

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Change-Id: I06dd83d03cfd1e061e4d3a03940ac6e5a2be9934
Signed-off-by: Thomas Kosiewski <tk@coder.com>
… keep claims of a missing pool, and mark a claim Lost when its workspace is deleted

Change-Id: I8d928c5ca1c5e31df6c36afa8e0be93a80e21196
Signed-off-by: Thomas Kosiewski <tk@coder.com>
…claim on a stale cache

Change-Id: I25dde40a2810039dbba49609db691c95cbda2a0f
Signed-off-by: Thomas Kosiewski <tk@coder.com>
…iting

Change-Id: I16d396849262720a8302f0f2acfb7505e7808013
Signed-off-by: Thomas Kosiewski <tk@coder.com>
@ThomasK33
ThomasK33 force-pushed the feat/workspace-pool-claim-lifecycle branch from e6eb14f to 380bae8 Compare October 15, 2026 00:01
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 380bae885c

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 380bae885c

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

Base automatically changed from feat/workspace-pool-claims to main October 15, 2026 00:41
…laim-lifecycle

Change-Id: I9df386f9465b999df9f6fcb0860f45ec4fa8db69
Signed-off-by: Thomas Kosiewski <tk@coder.com>
@ThomasK33
ThomasK33 added this pull request to the merge queue Oct 15, 2026
Merged via the queue into main with commit 62ac374 Oct 15, 2026
10 checks passed
@ThomasK33
ThomasK33 deleted the feat/workspace-pool-claim-lifecycle branch October 15, 2026 01:07
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.

1 participant