Repository navigation
feat: set workspace secrets on workspace builds - #30250
Conversation
a970b35 to
daf45ed
Compare
3beba2d to
3a43ddc
Compare
daf45ed to
35c7bbb
Compare
0a37eee to
7f09f79
Compare
35c7bbb to
e214652
Compare
e214652 to
f9db4b2
Compare
7f09f79 to
d0eaabe
Compare
f9db4b2 to
88c4bfd
Compare
1dbfe65 to
2ce6bf7
Compare
88c4bfd to
21dacb4
Compare
4a8b7cc to
b9ebc8b
Compare
21dacb4 to
f21bd7c
Compare
b9ebc8b to
8ae63e0
Compare
f21bd7c to
2eb9e1b
Compare
|
/coder-agents-review |
|
Chat: Review posted | View chat Review history
deep-review v0.13.0 | Round 1 | Last posted: Round 1, 31 findings (1 P1, 6 P2, 11 P3, 8 P4, 5 Nit), REQUEST_CHANGES. Review Finding inventoryFinding inventory: PR #30250Findings
Contested and acknowledgedRound logRound 1Round 1, full panel. Netero: 2 P3, 2 P4, 1 Nit, no P0. Law not run (632 effective additions). About deep-reviewCRF = Coder Review Finding (P0-P4, Nit, Note)
|
There was a problem hiding this comment.
This PR accepts secrets on workspace create and build requests and persists them per build in wsbuilder. Findings: 1 P1, 6 P2, 11 P3, 8 P4, 5 Nit.
CI reports 21 failed jobs; the job logs could not be read from this environment. Locally, go build ./coderd/... ./codersdk/... ./enterprise/... and the new tests pass.
Out of scope (needs a ticket or explicit acceptance by a human):
coderd/database/migrations/000613_workspace_secrets.up.sql:94: the per-build limit trigger measures stored ciphertext, so dbcrypt changes the effective caps anddbcrypt rotatecan leave rows over them (the trigger is BEFORE INSERT only).coderd/usersecrets.go:52: theDisableUserSecretFilePathflag now also governs workspace secrets, but its name says user secrets.coderd/autobuild/lifecycle_executor_test.go:60: about 11 existingptr.Refcalls were not migrated tonew(expr), so new code keeps copying them.codersdk/organizations.go:263: theRichParameterValuescomment is padded.
Notes:
coderd/workspacesecrets.go:16: once #30251 delivers secrets,organization-adminandownerwithNoOwnerWorkspaceExeccan run code as the workspace user through afile_pathsuch as~/.bashrc. Template pushes already allow this, so it is a second path, not a new capability.codersdk/workspaces.go:132:secretsships ungated on two public request types; if a release includes this PR without #30251, secrets are accepted and never delivered.coderd/wsbuilder/wsbuilder.go:689: copy-forward adds one row per non-ephemeral secret per build and nothing purges them. Query cost stays flat (partial live index); table size andGetWorkspaceSecretsHistorygrow.codersdk/workspacesecrets.go:28: ephemeral secrets are lost if the build they were set on fails or is canceled, so a retry must resend them.
🤖 This review was automatically generated with Coder Agents.
4999a47 to
8e32030
Compare
33819cd to
f7cb17f
Compare
8e32030 to
4c6093f
Compare
f7cb17f to
b0321fb
Compare
4c6093f to
a72ce46
Compare
5f7311b to
b51bf01
Compare
84cc16c to
22b2580
Compare
0a0afe6 to
c5daedf
Compare
Addressed all feedback
Encrypts workspace secret values at rest with the existing database encryption keys, and adds workspace secrets to the `coder server dbcrypt` commands. Part of [RELAY-7](https://linear.app/codercom/issue/RELAY-7/agent-relay-deliver-provider-credentials-via-coder-secrets-instead-of). **Stack** (design decisions in #30248) 1. #30248 Database schema, queries, and RBAC 2. **#30249 Encryption at rest (this PR)** 3. #30250 Set secrets on workspace builds 4. #30251 Deliver secrets to the agent 5. #30252 Docs 6. #30388 List a build's secrets 7. #30459 Audit a build's secrets - Values are encrypted when a secret is written and decrypted when it is read. - `dbcrypt rotate` and `dbcrypt decrypt` re-encrypt or decrypt workspace secrets, 1,000 at a time. - `dbcrypt delete` clears workspace secret values instead of deleting the rows, so build history is kept. <details> <summary>Implementation details</summary> - `InsertWorkspaceSecret` and `UpdateEncryptedWorkspaceSecretValue` encrypt, and `ListActiveWorkspaceSecrets` and `GetWorkspaceSecrets` decrypt. Only live rows reach these paths, so there is no NULL handling. - Rotate and decrypt page through `GetWorkspaceSecrets` by `id`, so memory is bounded on large deployments. Only live rows are listed, about one set per workspace. - If a build clears a row between the list and the update, the update matches no row and that row is skipped. - Secret size limits count stored ciphertext bytes, the same as user secrets. Fixing that for both is tracked in #30441. </details> --- *Created by Coder Agents on behalf of @Emyrk.*
The previous build's agent can keep running until the new build's job completes, and it refreshes its secrets on every reconnect. Clearing at build creation left that agent without its secrets during the shutdown window.
c5daedf to
93d0747
Compare

Lets clients set secrets when creating a workspace or a build. Secrets are saved with the build and are never sent to the provisioner. Part of RELAY-7.
Stack (design decisions in #30248)
secretsis a new field on the create workspace and create build requests.ephemeralsecrets last for one build only.valueremoves a secret, which needsupdatepermission on the owner's workspace secrets.Secrets are stored but not delivered to the agent until #30251.
Example request
Implementation details
ephemeralAsWorkspaceSecretManager, so autostart and other system-initiated builds work without secret permissions. Requested secrets are authorized as the build's actor.source(requestorcarry_forward).provisionerdserver, or an orphan delete in the builder, clears the workspace's values and keeps the rows.Created by Coder Agents on behalf of @Emyrk.