Skip to content

feat: fill an empty placeholder serving-CA Secret instead of creating it - #146

Merged
ThomasK33 merged 4 commits into
mainfrom
feat/servingcert-placeholder
Sep 25, 2026
Merged

ThomasK33 merged 4 commits into
mainfrom
feat/servingcert-placeholder

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

Refs #143. Step 2 of 3.

The aggregated API server can now fill an empty placeholder coder-k8s-apiserver-tls Secret instead of creating one. That lets a future standalone ServiceAccount work with only get and update on this one Secret. create on Secrets cannot be limited by name, and a namespace-wide create would let that identity mint tokens for other ServiceAccounts in the namespace. Existing installs are unaffected: when the Secret is missing, the server still creates it as before.

What changed

  • servingcert.IsPlaceholder: true only when the type is coder.com/aggregated-apiserver-serving-ca and there are zero data keys. Every other Secret is still parsed, and invalid material stays corrupt: startup fails and nothing is overwritten.
  • Manager.Ensure:
    • It fills a placeholder with a new CA through an update guarded by the fetched resourceVersion.
    • On a conflict, it re-reads and uses the CA of the replica that won.
    • An empty resourceVersion fails with an assertion failed: error instead of risking an unconditional overwrite.
  • If creating the Secret is refused, the error explains how to provide the placeholder.
  • The docs describe the placeholder, and the "unusable Secret" rule now excludes it.

Tests

New tests cover:

  • filling a placeholder with nil and with empty data, with the update carrying the fetched resourceVersion;
  • losing the fill race to another replica;
  • a placeholder without a resourceVersion;
  • a refused create;
  • six kinds of Secret that are not placeholders, which stay corrupt;
  • the unchanged create path when the Secret is missing (exactly [get, create]).

9 of 9 mutations are caught: wrong-type placeholder accepted, filling a Secret that has data (2 variants), update without resourceVersion, assertion removed, conflict treated as an error, create hint dropped, fill via create, and fill with no data.

The fake clientset does not enforce resourceVersion conflicts. Step 3 adds envtest proofs against a real API server, along with the standalone ServiceAccount, its namespaced Role and the manifests.

Validation

On the exact tree cb181d102fd63260f50e48029fc99b46e5c8f024, these pass: make verify-vendor, make build, make test, make lint, make test-integration and mkdocs build --strict.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: medium

An identity that may only get and update the coder-k8s-apiserver-tls
Secret cannot create it. Namespace-wide create on Secrets would let such
an identity mint tokens for other ServiceAccounts in the namespace, so
the server now also accepts an existing placeholder: exactly the managed
type and zero data keys. It fills the placeholder with a new CA through
a resourceVersion-guarded update and adopts another replica's fill on
conflict. Every other state stays corrupt and is never overwritten. When
create is forbidden, the error explains how to provide the placeholder.
The create path for a missing Secret is unchanged.

Refs #143

Change-Id: I9c2cd26f46f0b6f694fcf42fc41bd0b8ea60fefd
Signed-off-by: Thomas Kosiewski <tk@coder.com>
Refs #143

Change-Id: Ia833dd8819aa71f59555ce68b3b90ce19efc33cb
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 Sep 25, 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-09-25T12:59:44.132852Z 3ceda81 Manual request
🔒 Security Review ✅ Completed 2026-09-25T13:02:16.179415Z 3ceda81 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: 138786258e

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: 138786258e

ℹ️ 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/aggregated/servingcert/manager.go
Comment thread internal/aggregated/servingcert/manager.go
Comment thread docs/how-to/deploy-aggregated-apiserver.md Outdated
…rors

Codex review on #146: a filled placeholder now carries the managed
labels, like a created Secret, and troubleshooting names the permission
behind each get, create, fill and update error.

Refs #143

Change-Id: I4deb2b7e8f8dfeb7f37409d646c95d50139aa6a3
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: 905a80e6ba

ℹ️ 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/aggregated/servingcert/servingcert.go Outdated
Comment thread docs/how-to/deploy-aggregated-apiserver.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: 905a80e6ba

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.

Codex review on #146: Kubernetes forbids data changes on an immutable
Secret, so an immutable empty placeholder can never be filled. It now
fails startup with a message saying to recreate it without immutable.

Refs #143

Change-Id: Ie7977f7613e066af889bca836232928db847e3eb
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. Keep it up!

Reviewed commit: 3ceda81a94

ℹ️ 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: 3ceda81a94

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 Sep 25, 2026
Merged via the queue into main with commit c956172 Sep 25, 2026
13 checks passed
@ThomasK33
ThomasK33 deleted the feat/servingcert-placeholder branch September 25, 2026 13:13
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