Skip to content

If you update 'time until shutdown' in a running workspace, the workspace UI has the old value #1783

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tracked by #1317
johnstcn opened this issue May 26, 2022 · 5 comments · Fixed by #2165
Closed
Tracked by #1317
Assignees
Labels
api Area: HTTP API site Area: frontend dashboard
Milestone

Comments

@johnstcn
Copy link
Member

johnstcn commented May 26, 2022

In #1778 we added support for setting a deadline on a single workspace build. In that implementation, the deadline can only increase monotonically. Changes to workspace TTL do not affect the deadline of an active workspace build.

So what will be the behavior when the user changes the TTL on a running workspace? Will you add functionality to the CLI so we also update the deadline to be closer to the new TTL?

Originally posted by @deansheather in #1778 (review) (paraphrased)

Seems like this would be useful behaviour, but there are some ins and outs to this we need to think through:

  • If the workspace is not running, there is nothing to do here.
  • If the workspace is running and the build does not have a deadline set, we would need to set the deadline. Users would need to be warned that this would affect running builds of their workspace.
    • Time should be measured from the workspace start time.
    • In the client interfaces (UI/CLI), show a message "This operation will cause the workspace to shut down at HH:MM".
  • If the workspace is running and the build has a deadline set and the new deadline based on the TTL would cause the workspace to stop (i.e. new deadline would be at or before now), the user should DEFINITELY be warned of this.
    • Time should be measured from the workspace start time.
    • In the client interfaces (UI/CLI), show a message "This operation will cause the workspace to shut down immediately".
  • If the workspace is running and the build has a deadline set and the new deadline based on the TTL would cause the user to hit the 30-minute notifcation, that's probably fine.
  • (New issue): Make applying the updated deadline optional (i.e. prompt the user) (Edit: TTL/Workspace Schedule is too coupled #2229)

Acceptance Criteria:

  1. Given a user has a workspace with no deadline/TTL set and the workspace is not running
    When the user updates the workspace TTL
    Then: the TTL is updated

  2. Given a user has a workspace with a deadline set and the workspace is running
    When the user updates the workspace TTL such that the updated deadline would affect a running workspace
    Then: the user is notified about the effect of the change (workspace will be stopped at X time) and be prompted to confirm.

  3. Given a user has a workspace with a deadline set and the workspace is running
    When: the user updates the workspace TTL such at the updated deadline would cause the running workspace to be stopped
    Then: the user is notified about the effect of the change (workspace will be stopped immediately) and be prompted to confirm.

Implementation Notes:

  • WorkspaceScheduleForm
    • Pass in workspace to WorkspaceScheduleFormValues
    • Add function to (workspace, startTime) -> use dayJS to check next schedule
    • Add a warning message to the ttl TextField
    • Use Language component of WorkspaceSchedule
@johnstcn johnstcn added missing details 👀 site Area: frontend dashboard api Area: HTTP API labels May 26, 2022
@johnstcn johnstcn changed the title feat: autostop: update workspace build deadline when updating workspace TTL change: autostop: update workspace build deadline when updating workspace TTL May 26, 2022
@johnstcn johnstcn changed the title change: autostop: update workspace build deadline when updating workspace TTL change: autostop: update active workspace build deadline when updating workspace TTL May 26, 2022
@ketang
Copy link
Contributor

ketang commented May 26, 2022

  • If the workspace is running and the build has a deadline set and the new deadline based on the TTL would cause the workspace to stop (i.e. new deadline would be at or before now), the user should DEFINITELY be warned of this.
  • If the workspace is running and the build has a deadline set and the new deadline based on the TTL would cause the user to hit the 30-second notifcation, that's probably fine.

I think we can combine treat these: if the shutdown time is less than 5 minutes in the future, we warn. I don't know why someone would want a scheduled shutoff in 2 minutes, so if that use case is mildly inelegant (confirm on change and confirm on imminent shutdown) that's oka.

@greyscaled
Copy link
Contributor

greyscaled commented May 26, 2022

This issue relates to #1779 <-- Neither block each-other, but should be thought about together.

@johnstcn and I will co-ordinate

@greyscaled
Copy link
Contributor

This got duplicated as a bug in #2055 , meaning it's tripping users up.

Here's @mtm20176 's comment:

OS Information

  • OS:
  • Browser (if applicable):
  • Architecture:
  • coder --version: 0.6.0

Steps to Reproduce

  1. Have Time until shutdown already configured e.g., 8 hours

  2. The workspace is running

  3. Change the Time until shutdown to 1 hour

  4. The workspace UI says 7 hours remaining (the leftover part from the original 8 hours)

Expected

Not quite sure, but something based on the new Time until shutdown - so maybe 1 hour in this example

Actual

The shutdown remaining in workspace UI is based on the previous Time until shutdown

Logs

Screenshot

image

image

Notes

Nope

@greyscaled
Copy link
Contributor

Here's @ketang 's comment from the dupe:

I poked at this to see how it behaved. To start more from scratch:

  1. create a workspace
  2. set its shutdown time to 3 hours
  3. start the workspace
  4. when it is starting or has started, change the schedule to shut down after an hour
    Result: the workspaces page still shows "SHUTDOWN: 3 hours after start."

Doing a hard page reload doesn't change anything; it still shows 3 hours. However, if I hit the "Stop" button, then schedule card then shows "1 hour after start" 🤷🏾‍♂️

@greyscaled greyscaled changed the title change: autostop: update active workspace build deadline when updating workspace TTL Bug: If you update 'time until shutdown' in a running workspace, the workspace UI has the old value Jun 6, 2022
@greyscaled greyscaled assigned johnstcn and greyscaled and unassigned johnstcn and greyscaled Jun 6, 2022
@greyscaled
Copy link
Contributor

Please add your planning poker estimate with ZenHub @johnstcn

@kylecarbs kylecarbs changed the title Bug: If you update 'time until shutdown' in a running workspace, the workspace UI has the old value If you update 'time until shutdown' in a running workspace, the workspace UI has the old value Jun 7, 2022
@kylecarbs kylecarbs added the bug label Jun 7, 2022
@johnstcn johnstcn self-assigned this Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Area: HTTP API site Area: frontend dashboard
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants