Skip to content

Safe way to edit workspace parameters via dashboard and CLI #802

Closed as not planned

Description

@presleyp

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

Current workarounds

  • Terraform's prevent_destroy and ignore_changes meta-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 region after a workspace is created, ignore_changes does 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 region after a workspace is created, prevent_destroy ensures 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 workspace

  • 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

  1. self-assigned this
    on Apr 1, 2022
  2. added this to the V2 Beta milestone on Apr 1, 2022
  3. presleyp commented on Apr 1, 2022

    @presleyp
    ContributorAuthor

    @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?

  4. kylecarbs commented on Apr 1, 2022

    @kylecarbs
    Member

    I don't think we need the update view either, similarly to the edit page.

  5. misskniss commented on Apr 26, 2022

    @misskniss

    @presleyp do you have what need answered for this one?

  6. changed the title [-]Frontend Workspace Update[/-] [+]Frontend Workspace Edit[/+] on May 12, 2022
  7. BrunoQuaresma commented on May 27, 2022

    @BrunoQuaresma
    Contributor

    @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?

  8. 18 remaining items

  9. presleyp commented on Aug 8, 2022

    @presleyp
    ContributorAuthor

    @bpmct @deansheather this feels like multiple issues to me:

    1. we need a way to mark parameters as not-editable
    2. we need that CLI command to not edit uneditable parameters
    3. we need a view/edit parameters page in the UI (per workspace). It needs to disable changes to uneditable parameters.
    4. we need Update to prompt for missing parameters in the UI

    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.

  10. deansheather commented on Aug 8, 2022

    @deansheather
    Collaborator

    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 input

    I can write tickets for both if you like

  11. bpmct commented on Aug 8, 2022

    @bpmct
    Member

    @presleyp that decomposition sounds good!

    For 1 I think we just want to make people set ignore_changes to mark fields as immutable

    @deansheather ignore_changes is 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 by ignore_changes, even if a variable could potentially modify one resource and not the other. wdyt?

  12. bpmct commented on Aug 8, 2022

    @bpmct
    Member

    @deansheather @Emyrk thoughts on coder workspace edit <name> essentially being an alias for coder 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.

  13. bpmct commented on Aug 8, 2022

    @bpmct
    Member

    Also, the edit fields should likely show the parameter variable value. Is this possible?

  14. bpmct commented on Aug 10, 2022

    @bpmct
    Member

    Some notes from a call with Steven, Presley, and David:

    • variables in the template with sensitive = true are both template-scoped AND sensitive. we should not return these and they are not editable or overridable by the workspace owner
    • variables in the template with sensitive = false are 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 docs

    These 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 variables
    • sensitive = fakse - you can expose this value to the user and API. users can edit these variables

    This is different from the stuff around ignore_changes and dangerous variables that delete a disk, for example. It just has to do with showing users the previous values for variables they can EDIT

  15. mattlqx commented on Aug 12, 2022

    @mattlqx

    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.

  16. misskniss commented on Aug 16, 2022

    @misskniss

    @deansheather @bpmct @presleyp sounds like we should parking lot this to finish and refresh the convo around it.

  17. added this to the EE milestone on Aug 22, 2022
  18. presleyp commented on Sep 6, 2022

    @presleyp
    ContributorAuthor

    Closing to replace with the tickets this has been broken down into.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

siteArea: frontend dashboard

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions