Skip to content

🤖 fix: hold a deleted CoderControlPlane while CoderMCPServer objects still use it - #384

Merged
ThomasK33 merged 4 commits into
mainfrom
mcp-controlplane-hold
Oct 14, 2026
Merged

ThomasK33 merged 4 commits into
mainfrom
mcp-controlplane-hold

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Summary

A deleted CoderControlPlane now waits for the CoderMCPServer objects that use it, as #362 made it wait for CoderAIGatewayKey and CoderAIProvider objects. Coder keeps running while it waits, so each MCP server delete reaches Coder and retries on failure. Before this PR the control plane went at once. The MCP server then made one 10-second delete attempt or released with ControlPlaneGone, and its config could stay in Coder, enabled and with its stored credential.

What changes

  1. controlPlaneDependents (internal/controller/controlplane_hold.go) also lists CoderMCPServer objects that reference the control plane and are being deleted with their cleanup finalizer, plus live ones for the first 30 seconds, the same rule as the other two kinds. The per-kind count for the grace period covers the new kind, and the grace period uses the largest bounded delete timeout of the three kinds (all are 10 s).
  2. requestForDependentControlPlane maps a CoderMCPServer to its control plane, and the control plane controller watches CoderMCPServer removals (dependentRemoved), so a waiting control plane goes at once.
  3. The CoderMCPServer delete path checks controlPlaneHolds, as the CoderAIProvider delete path does. While the control plane holds for it, it takes the normal path (retry every 60 s, capped at the hold end) instead of one bounded attempt and a release. Without this step, the hold would keep Coder running but a failed attempt would still release at once.
    Under the hold, the pass runs with a context deadline at the hold end, so a slow Coder cannot stretch it past the hold. The bounded pass after the hold then fits in the grace period. The retry counts from the end of the pass, so it lands right after the hold end (review rounds 2 and 3).
  4. The how-to "Delete a server" section describes the hold and when the control plane does not wait (namespace deletion, foreground deletion, after 10 minutes).
  5. How-to fix from the 🤖 feat: activate the CoderMCPServer controller #381 assessment: a name in access.groups that is not a valid Coder group name stalls with GroupNotFound and no requeue (codermcpserver_acl.go:147). The doc said that it checks again every 10 minutes. It now says that the object is not checked again until the spec changes. The API server refuses such names, so this applies only when admission was bypassed.

Validation

  • TestCoderMCPServerDeleteUnderControlPlaneHold (envtest): with a control plane that is being deleted and an applied CoderMCPServer that is being deleted, the control plane keeps its finalizer. A failed DELETE (502) keeps the MCP finalizer with CoderUnavailable and a 60 s requeue, and the control plane still waits. The retry deletes the config, the MCP object goes, and then the control plane goes. Red before the fix: "the control plane waits for the MCP server" failed.
  • TestMCPServerDeleteUnderHoldEndsAtHoldEnd (unit, fake client): with a hold that ends in 5 s and a Coder that hangs, the pass ends near the hold end with CoderUnavailable, keeps the finalizer, and requeues right after the hold end. Without the deadline it waits for the 30 s request timeout (mutation checked).
  • TestRequestForDependentControlPlane (unit): each of the three dependent kinds maps to its control plane, and another kind maps to nothing.
  • Mutation checks: removing the CoderMCPServer case of the mapper fails the unit test, forcing the bounded path in the MCP delete fails the envtest test, and dropping the hold-end deadline fails the unit test above.
  • The existing TestCoderMCPServerDeleteWhileControlPlaneDeletes, TestControlPlane*, TestCoderAIProviderDelete* and TestCoderAIGatewayKeyDelete* tests pass unchanged.
  • Local gates on the final head (859d6bc7): make verify-vendor, make build, make lint, GOFLAGS=-mod=vendor go tool govulncheck ./..., make test, make test-integration, go test -race ./internal/controller/, and make docs-check pass. make codegen, make manifests, make build-installer and make docs-reference leave no diff. RBAC does not change: the manager role already grants get, list and watch on codermcpservers.
  • The full Kind E2E runs in CI on this head (the path filter matches internal/controller/codermcpserver* and controlplane_hold.go).

Not in this PR

Size

199 changed lines: 65 in the controllers, 129 in tests and 5 in the how-to.

Fixes #382
Refs #353
Refs #155


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $224.47

…still use it

Fixes #382
Refs #353
Refs #155

Change-Id: Ia046b07473f403eb059177a7a1c437002a60f041
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-14T20:27:15.344069Z 859d6bc Manual request
🔒 Security Review ✅ Completed 2026-10-14T20:28:48.048889Z 859d6bc 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 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: a4409ed173

ℹ️ 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 docs/how-to/manage-mcp-servers.md Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

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

Reviewed commit: a4409ed173

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: Id1e2e4a197291d2db02e0bea3e729702cc882a80
Signed-off-by: Thomas Kosiewski <tk@coder.com>
@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: 05a47b6e2b

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: 05a47b6e2b

ℹ️ 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/controlplane_hold.go
…at the hold end

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

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@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: cf8651d124

ℹ️ 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/codermcpserver_delete.go Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

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

Reviewed commit: cf8651d124

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.

… of the pass

Change-Id: I8de8cb92e215f1879c2192913ffe49c83a84f4ee
Signed-off-by: Thomas Kosiewski <tk@coder.com>
@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. Already looking forward to the next diff.

Reviewed commit: 859d6bc714

ℹ️ 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: 859d6bc714

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.

@ThomasK33
ThomasK33 added this pull request to the merge queue Oct 14, 2026
Merged via the queue into main with commit e867e09 Oct 14, 2026
13 checks passed
@ThomasK33
ThomasK33 deleted the mcp-controlplane-hold branch October 14, 2026 20:57
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.

Hold a deleted CoderControlPlane while CoderMCPServer objects still use it

1 participant