Skip to content

Ability to disable unprivileged users from canceling workspace builds at the template level? #5035

Closed

Description

@kconley-sq

Our workspace templates use some Terraform tricks that we believe sometimes cause workspaces to be left in a bad state if a user clicks the "Cancel" button during a start or stop workspace build such that a subsequent "start" build always fails until an admin can manually fix the workspace's resources outside of Coder and Terraform.

This has happened a few times when a user thinks their workspace build is stuck and isn't familiar with how to access the workspace build logs on the Coder website or how to interpret the Terraform output to understand its progress, so they click the "Cancel" button thinking that a subsequent retry may be successful. I think the new workspace build progress bar may help users better understand how long a workspace build normally takes, but I also understand it may not always be able to provide that information to users (e.g. #4676).

Ideally we could make our workspace templates robust to workspace build interruptions, but I think our use cases aren't really supported by Terraform and the provider plugin we use at the moment, and I'm nervous that there may always be aspects of any off-the-shelf Terraform provider plugin or external state that we can't control that would make Coder workspace build cancellations for particular templates/situations unsafe.

We're intrigued about the conversations around adding support to Coder for other workspace provisioners like Pulumi (#4528) which might support our use cases better than Terraform, but we're also nervous that Pulumi may not be any safer with respect to workspace build interruptions: https://www.pulumi.com/docs/reference/cli/pulumi_cancel/

This command cancels the update currently being applied to a stack if any exists. Note that this operation is very dangerous, and may leave the stack in an inconsistent state if a resource operation was pending when the update was canceled.

What do you all think about introducing a configuration option for workspace templates that would allow template admins to disable the ability for unprivileged users to cancel workspace builds? In our case we'd rather force users to wait for their workspace build to reach a natural conclusion and, if the build really is stuck, to reach out to an admin who would still have the power to cancel it if that's the best course of action.

Activity

  1. changed the title [-]Ability to disable unprivileged users from cancelling workspace builds at the template level?[/-] [+]Ability to disable unprivileged users from canceling workspace builds at the template level?[/+] on Nov 11, 2022
  2. bpmct commented on Nov 14, 2022

    @bpmct
    Member

    Ahh, I have also run into cases where canceling does more harm than good as well, particularly for users who are unable to go into the cloud provider and fix the resources themselves. This is a good setting for "edit template" and coder templates edit!

  3. self-assigned this
    on Nov 14, 2022
  4. mtojek commented on Nov 16, 2022

    @mtojek
    Member

    Looking into this

  5. mtojek commented on Nov 16, 2022

    @mtojek
    Member

    I have researched this issue for a bit, and we may want to discuss the CLI design for coder templates edit. I can see a few options:

    1. Simple, single flag:
    coder templates edit <name> --allow-user-cancel-workspace-build
    
    • a rather long CLI flag ;)
    • can be set to true by default
    1. Grants (or permissions):
    coder templates edit <name> --grants user:CancelWorkplaceBuild
    
    • more sophisticated, can distinguish 2 basic roles like admin or users
    • similar to AWS IAM
    1. Enterprise only. Maybe we should pair it with RBAC, and allow specific groups to perform operations. CLI would be similar to option 2., but behind the scenes, it would be more advanced:
    coder templates edit <name> \
       --grants <group>:<action>
       --grants DevOps:CancelWorkplaceBuild
       --grants Contractors:CancelWorkplaceBuild
    

    Please let me know your thoughts, @bpmct! I guess that it depends if we want to use the concept of permissions. Alternatively, we can go with option 1., and deprecate it later in favor of option 2.

    EDIT:

    I received good feedback from @mafredri (thanks!). We can go with --add-grant and --remove-grant, so that we don't have to pass all grants everytime via coder templates edit.

  6. bpmct commented on Nov 16, 2022

    @bpmct
    Member

    @mtojek - I'm in favor of your grants approach. I'd like @kylecarbs to review as well since the project may be too early for us to know if this would be the right abstraction (or the right time to add one). However, there are some other use cases that grants could solve for:

    coder templates edit \
      --remove-grant user:ReadTemplateTar \ # currently every user can fetch the .tar.gz of a template (anticipated)
      --remove-grant user:AutoStart \ # disable auto start for all users (anticipated)
      --remove-grant user:EditStop \ # disable modifying/disabling the autostop time (#3630)
      --add grant    DataScience:EditStop \ # exception to keep workspace alive for long running jobs (v1 feature request)

    An open question I have is: do we plan on integrating grants with the current "template permissions" behavior, where a user or group can be given be given permission to use or edit a given template?

    One confusing thing about the current "template permissions" behavior is it may be unclear that the "template manager, admin, and owner" role also has read/write access to all templates, but it is not displayed on that page.

  7. mtojek commented on Nov 16, 2022

    @mtojek
    Member

    However, there are some other use cases that grants could solve for:

    Correct me if I'm wrong, but the current "template permissions" model doesn't seem to be flexible enough to easily extend it with grants. On the other hand, grants could include the "permissions" to use and edit templates.

    Now, I'm thinking that this could be a separate feature:

    coder templates grants <name> \
      --remove-grant ... \
      --add-grant ... 
    
  8. mtojek commented on Nov 16, 2022

    @mtojek
    Member

    We had a good chat with @bpmct and @kylecarbs. We agreed to keep it single for now:

    1. Introduce the extra flag --allow-user-cancel-workspace-jobs
    2. Add checkbox to UI: [ ] Allow users to cancel in-progress jobs

    The concept of grants will be tracked in the separate issue.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions