Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: allow new immutable parameters for existing workspaces#18579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Emyrk merged 2 commits intomainfromstevenmasley/immutable_param
Jun 25, 2025

Conversation

Emyrk
Copy link
Member

Closes#18578

This was a somewhat conscience choice to prevent new immutable parameters. In an ideal world, immutable parameters can only be set at creation time. The example to illustrate this is:

  1. A template exists that provisions workspaces tous-east1
  2. WorkspaceEast-1 is created.
  3. Template is updated to include aregions parameter with the defaultus-west1.
  4. Workspace is updated, and now moved tous-west1. Volumes do not transfer, and this workspace is either broken, or wiped.

If we disallow new immutable parameters, then the fix would be to letregions bemutable. Push an update, update the the workspace, then make it immutable.

Since the workaround has no more protection than the original problem, it's probably best to just allow new immutable parameters. If at some point in the future we allow some first class flow to handling this case, we can change back this enforcement.

Notes

  • Added a mock for the renderer so I can test this with less setup.

Comment on lines +172 to +180
originalValue, ok := originalValues[parameter.Name]
// Immutable parameters should not be changed after the first build.
// They can match the original value though!
if parameter.Value.AsString() != originalValues[parameter.Name].Value {
// If the value matches the original value, that is fine.
//
// If the original value is not set, that means this is a new parameter. New
// immutable parameters are allowed. This is an opinionated choice to prevent
// workspaces failing to update or delete. Ideally we would block this, as
// immutable parameters should only be able to be set at creation time.
if ok && parameter.Value.AsString() != originalValue.Value {
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

This is the change. The rest is testing

Copy link
Contributor

@dannykoppingdannykopping left a comment

Choose a reason for hiding this comment

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

Would it be a lot of trouble to add a test to cover the scenario mentioned in the issue?

@Emyrk
Copy link
MemberAuthor

Would it be a lot of trouble to add a test to cover the scenario mentioned in the issue?

You mean a more e2e test? Like from coderd, template versions, etc?

The test I did write is pretty locally scoped to the parameter validation logic.

@dannykopping
Copy link
Contributor

Doesn't have to be e2e necessarily;coderd/workspaces_test.go would probably suffice.

  1. Create template version
  2. Create workspace
  3. Update version with immutable param
  4. Don't update workspace
  5. Try delete workspace
  6. Succeeds

@EmyrkEmyrk requested a review fromdannykoppingJune 25, 2025 15:31
@Emyrk
Copy link
MemberAuthor

Emyrk commentedJun 25, 2025
edited
Loading

Doesn't have to be e2e necessarily;coderd/workspaces_test.go would probably suffice.

  1. Create template version
  2. Create workspace
  3. Update version with immutable param
  4. Don't update workspace
  5. Try delete workspace
  6. Succeeds

Added!aa2a809

Test ran on main failed with: (as expected and matches the issue)

    dynamicparameters_test.go:341:         Error Trace:/home/steven/go/src/github.com/coder/coder/enterprise/coderd/dynamicparameters_test.go:341        Error:      Received unexpected error:                    POST http://localhost:44413/api/v2/workspaces/6ea8dbda-9e21-4e9a-a388-189119dbdbf9/builds: unexpected status code 400: Unable to validate parameters                    immutable: Immutable parameter changed; Parameter "immutable" is not mutable, so it can't be updated after creating a workspace.

Copy link
Contributor

@dannykoppingdannykopping left a comment

Choose a reason for hiding this comment

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

LGTM!

@EmyrkEmyrkenabled auto-merge (squash)June 25, 2025 15:38
@EmyrkEmyrk merged commite396b06 intomainJun 25, 2025
34 checks passed
@EmyrkEmyrk deleted the stevenmasley/immutable_param branchJune 25, 2025 15:41
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJun 25, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@dannykoppingdannykoppingdannykopping approved these changes

Assignees

@EmyrkEmyrk

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

bug: workspace deletion fails when template has new immutable parameters
2 participants
@Emyrk@dannykopping

[8]ページ先頭

©2009-2025 Movatter.jp