Description
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:
-
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 -
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. -
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