Repository navigation
Description
edits by @bpmct:
Problem statement
In Coder Classic, some parameters for workspaces are editable after the workspace is created, providing a helpful utility to users. Examples of these parameters are:
- image
- cpu allocation
- memory allocation
- disk size
Some parameters have specific rules when editing:
- disk size can only be increased, not decreased
Others cannot be edited, as Coder does support migrations and it would result in data loss:
- workspace provider
- CVM (true/false)
In Coder OSS, there is currently:
- no way to edit parameters for an existing workspace via the web dashboard
- no prompt in the dashboard when new variables are added to a template version and they "update" their workspace Pressing "Update" on a workspace does not prompt for newly-created variables #2660
- a way to dangerously edit ALL parameters for an existing workspace with
coder update --always-prompt <workspace-name>- If I change the "region" of an existing workspace, it will delete the disk in one region and recreate it in another. The user looses the files in their home directory.
- no way to see what your existing parameters are. users need to re-select them from scratch.
Definition of done
Coder has documented (or implemented) best practices for disabling/handling "dangerous" parameters.
- Admins would likely have to indicate which variables are destructive, as every template differs
Users can safely edit their workspace's parameters from the web dashboard and CLI.
- Users can also see what their current parameters are in their workspace
Users are prompted in the web dashboard and CLI when they "update" their workspace and new variables are added to a template version
- Pressing "Update" on a workspace does not prompt for newly-created variables #2660
- This currently happens in the CLI, but not the web dashboard
Current workarounds
-
Terraform's
prevent_destroyandignore_changesmeta-arguments can be added to templates to ensure that changes to "destructive" parameters will not destroy critical resources, such as a home volume or persistent VM. However, this UX is not well-handled into Coder and will lead to confusing behaviors:User changes the
regionafter a workspace is created,ignore_changesdoes not change the resources, user is confused why their change did not work and reports it to their Coder admin. While this prevented the workspace from deleting, the action didn't lead to the desired result.User changes the
regionafter a workspace is created,prevent_destroyensures the volume is not deleted, but the rebuild has failed. When viewing the logs, the user sees that the volume cannot be destroyed but doesn't understand that their change led to a failed workspaceprevent_destroywould also prevent the workspace from being deleted, since it cannot be referenced conditionally ("Variables may not be used here" forprevent_destroyhashicorp/terraform#22544). Thanks @kylecarbs
-
User can dangerously edit their workspace with
coder update --always-prompt <workspace-name>and has to remember / write down their previous values if they want to carry them over.
Archive
Old issue description
To discourage edits, this will be called the Workspace Settings page and be used for viewing parameters and potentially editing them.
Reuse Workspace Create form.
- add warning that changing parameters may cause problems
- add Delete Workspace button
- disable any forms that can't be edited
- hook up api to edit
- hook up api to rebuild u pon submit
- test that a workspace is edited
- test that workspace is rebuilt
Activity
presleyp commentedon Apr 1, 2022
@kylecarbs @tjcran would the workspace edit page need to be any different from the workspace create page (like, are there some fields that can't be edited)? And should an edited workspace automatically be rebuilt?
kylecarbs commentedon Apr 1, 2022
I don't think we need the update view either, similarly to the edit page.
misskniss commentedon Apr 26, 2022
@presleyp do you have what need answered for this one?
[-]Frontend Workspace Update[/-][+]Frontend Workspace Edit[/+]BrunoQuaresma commentedon May 27, 2022
@kylecarbs Do we have the endpoint that returns the values for the current input parameters? I was not able to find anything related to that. If we don't have one, would make sense to make it
/api/v2/workspaces/:id/settings?18 remaining items
presleyp commentedon Aug 8, 2022
@bpmct @deansheather this feels like multiple issues to me:
Should we turn this ticket into an epic and write out those issues? I can write 3 and 4 but don't understand 1 and 2 very well.
deansheather commentedon Aug 8, 2022
For 1 I think we just want to make people set ignore_changes to mark fields as immutable
For 2 it would be as simple as just printing the value with
(immutable)next to it when editing values instead of allowing inputI can write tickets for both if you like
bpmct commentedon Aug 8, 2022
@presleyp that decomposition sounds good!
@deansheather
ignore_changesis set on the resource but refers to a variable. Some form of dependency parsing would probably be necessary to figure out which variables should be immutable. I think it's perfectly sane to disable a variable if it's mentioned anywhere byignore_changes, even if a variable could potentially modify one resource and not the other. wdyt?bpmct commentedon Aug 8, 2022
@deansheather @Emyrk thoughts on
coder workspace edit <name>essentially being an alias forcoder workspace update --always-prompt <name>for a similar "edit" experience as the dashboard? Then specific parameters can be marked as immutable, just as the Ui in both fields.bpmct commentedon Aug 8, 2022
Also, the edit fields should likely show the parameter variable value. Is this possible?
bpmct commentedon Aug 10, 2022
Some notes from a call with Steven, Presley, and David:
sensitive = trueare both template-scoped AND sensitive. we should not return these and they are not editable or overridable by the workspace ownersensitive = falseare both workspace-scoped AND insensitive. it is OK to return these values to the user, and we make it clear this is the case in the docsThese concepts are coupled due to Terraform's lack of variable extensibility. At some point, we could decouple them (#2719, #3056) if it comes up but for now we can safely assume:
sensitive = true- do not expose this value to the user or API. users cannot edit these variablessensitive = fakse- you can expose this value to the user and API. users can edit these variablesThis is different from the stuff around
ignore_changesand dangerous variables that delete a disk, for example. It just has to do with showing users the previous values for variables they can EDITmattlqx commentedon Aug 12, 2022
Just wanted to note that I'm happy this is being worked on. Some variables are pretty trivial things and it'd be great to be able to edit them and update the workspace rather than having to delete and create a new one.
misskniss commentedon Aug 16, 2022
@deansheather @bpmct @presleyp sounds like we should parking lot this to finish and refresh the convo around it.
presleyp commentedon Sep 6, 2022
Closing to replace with the tickets this has been broken down into.