Skip to content

feat: add a per-template workspace rename setting - #27558

Merged
aslilac merged 23 commits into
mainfrom
lilac/template-allow-workspace-renames
Aug 25, 2026
Merged

aslilac merged 23 commits into
mainfrom
lilac/template-allow-workspace-renames

Conversation

@aslilac

@aslilac aslilac commented Jul 28, 2026

Copy link
Copy Markdown
Member

Resolves DEVEX-674.

Workspace renames were gated by a single deployment-wide flag, but the workspace settings UI already told users the restriction came from the template. Whether a rename is destructive genuinely depends on the template's Terraform, so the control belongs there.

  • Adds templates.allow_workspace_renames, defaulting to false, exposed on the template create/update APIs and as a checkbox in template general settings.
  • A rename is permitted when the template opts in, or while the deployment flag is set. Deployments that rely on the flag today are unaffected.
  • --allow-workspace-renames / CODER_ALLOW_WORKSPACE_RENAMES is now hidden and marked for removal in v2.41.0.
Design notes

Reconciliation. Effective permission is deployment.AllowWorkspaceRenames || template.allow_workspace_renames. The deployment flag force-enables renames for every template while set. The alternative, seeding new templates from the flag, was rejected as harder to reason about.

Deprecation. serpent's UseInstead only accepts other serpent options, so it cannot point at a template setting. The deprecation notice lives in the option description instead.

Not license-gated. Treated like allow_user_cancel_workspace_jobs, not require_active_version.

Rejected follow-up: static "rename safe" detection at template import. The idea was to scan the plan for references to data.coder_workspace.*.name and auto-enable renames when absent. tfjson.Plan.Config does expose Expression.References and is already parsed by the provisioner, but Terraform's JSON config output omits locals entirely. A template doing:

locals { n = data.coder_workspace.me.name }
resource "docker_volume" "home" { name = local.n }

would scan as rename-safe and is not. A false "safe" causes exactly the data loss this setting exists to prevent. Graph reachability catches locals but cannot distinguish .name from .start_count, which nearly every template uses, so it would report almost nothing as safe. Manual opt-in only.


🤖 Generated by Coder Agents on behalf of @aslilac.

Workspace renames were gated by a single deployment-wide flag, but the
UI attributed the restriction to the template, and whether a rename is
destructive genuinely depends on the template's Terraform.

Adds templates.allow_workspace_renames, exposed on the template create
and update APIs and in the template general settings form. Renames are
permitted when the template opts in, or while the deprecated deployment
flag is set. The deployment flag is now hidden and marked for removal in
v2.41.0.
@aslilac
aslilac requested a review from a team as a code owner July 28, 2026 01:50
@linear-code

linear-code Bot commented Jul 28, 2026

Copy link
Copy Markdown

DEVEX-674

@github-actions

github-actions Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Docs preview

Check off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here.

@coderagents

coderagents Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Check

Updates Needed

  • docs/admin/templates/extending-templates/resource-persistence.md - Addressed in ae736b02, refined in 4a506e42. The page now splits immutable and mutable identifiers and points at the new Workspace renaming section, which documents the deployment.AllowWorkspaceRenames || template.allow_workspace_renames behavior, including that the deployment flag can't be overridden per template.
  • docs/admin/templates/managing-templates/index.md - Addressed in ea1e9603. The grep example now uses the canonical ```sh fence.
  • docs/user-guides/workspace-management.md - Addressed in ea1e9603. The "Workspace name rules and restrictions" section now notes that renaming is off by default and per-template, and cross-links to Workspace renaming.
  • docs/admin/setup/configuration-reference.md - Still open. That page has an explicit deprecation convention ("Deprecated options are listed at the end of each section"), and scripts/configdocgen's isDeprecated already matches this option's Deprecated: ... description. But buildTree skips opt.Hidden before that check, so Hidden: true deletes the Allow workspace renames entry from the reference instead of listing it as deprecated. An admin who has CODER_ALLOW_WORKSPACE_RENAMES set and looks it up in the configuration reference now finds nothing. Dropping Hidden: true gets the deprecated rendering for free. Partly mitigated by the warning in managing-templates/index.md, so this is the last remaining gap.

Automated review via Coder Agents

aslilac added 3 commits July 28, 2026 18:31
Main removed the dynamic parameters checkbox from the template settings
form along with its `Link` and `docs` imports. The new rename setting
uses both, so the merged tree failed to typecheck.

Also renumbers the migration to 000557 to clear the 000554 collision.
aslilac and others added 17 commits July 28, 2026 23:37
Main claimed 000557 with connection_type_tunnel, which made the migrate
driver reject the duplicate version and took down gen, lint, sqlc-vet,
offlinedocs, test-e2e, and test-go-pg.
…workspace-renames

Main added an agents_allowed template column that touches every place
allow_workspace_renames does, so the two settings are interleaved in the
SQL queries, dbgen, modelqueries, audit table, and codersdk structs.
The template settings form was also demui'd, so the rename checkbox is
rewritten in the new Checkbox/Label idiom.

Also folds in review feedback: drops the specific removal version from
the deprecated deployment option, softens the destructiveness wording in
the column comment, SDK docs, and UI copy, and inlines the two-boolean
rename check instead of wrapping it in a helper.

Migration renumbered to 000573.
…enames' into lilac/template-allow-workspace-renames
…e renaming

Replaces the two interaction-only stories with a vitest test file, so the
rename setting is not carried as a pair of visual snapshots.

Adds a "Workspace renaming" section under managing-templates covering why
renames are off by default, how to check whether a template is safe, and
how to enable the setting.
The pull_request-triggered workflows did not fire for ae736b0.
Comment thread codersdk/deployment.go
Flag: "allow-workspace-renames",
Env: "CODER_ALLOW_WORKSPACE_RENAMES",
Default: "false",
Hidden: true,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: sharing a small issue found by local AI agent (it is non-blocking but nice to fix if that makes sense):

Can we drop Hidden: true here?

The flag still works, and for some deployments it's the only reason renames are enabled right now. Hiding it removes it from coder server --help, the CLI reference, and the configuration reference all at once, so an operator who has CODER_ALLOW_WORKSPACE_RENAMES=true set today has no way to find out it's deprecated.

We don't need Hidden to get the deprecation styling. scripts/configdocgen already treats any option whose description starts with "Deprecated" as deprecated — it sorts it to the end of the section and bolds the marker. Your description already starts that way.

I tried it locally: deleting just this line brings the section back as Deprecated: use the per-template ..., and nothing else on the page moves. Needs a make gen for the two goldens and the two docs pages.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

afaict there aren't any options that are deprecated but don't set Hidden

@BobbyHo BobbyHo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm, just shared a NIT (non-blocking) comment.

@aslilac
aslilac merged commit 29995c9 into main Aug 25, 2026
31 checks passed
@aslilac
aslilac deleted the lilac/template-allow-workspace-renames branch August 25, 2026 17:05
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants