Skip to content

TTL/Workspace Schedule is too coupled #2229

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
ammario opened this issue Jun 10, 2022 · 7 comments
Closed
Tracked by #1317

TTL/Workspace Schedule is too coupled #2229

ammario opened this issue Jun 10, 2022 · 7 comments
Assignees
Labels
api Area: HTTP API site Area: frontend dashboard
Milestone

Comments

@ammario
Copy link
Member

ammario commented Jun 10, 2022

So, I have a workspace that it scheduled to shut down in an hour. I want to edit my workspace schedule (which is a separate idea than extending my lease). I change my TTL in the Edit Schedule to one hour, and then boom, my workspace turns off.

I looked at the code a bit and have no idea what's causing this behavior.

The fact that "Edit Schedule" modifies my active lease is very hard to reason about as a user. Why does it add the TTL to the lease vs. adding the TTL to my current time? Why would I expect it to change the lease at all?

Also.. we use the word TTL around the product to mean both the schedule and the active lease. This has been confusing as I navigate the code, and also as a user. (See #2224 issue, which can be interpreted multiple ways).

What I suggest is we remove the ability for "Schedule" edits to affect the active lease. A lease is created on Workspace Start and then can only be modified directly. We can expose the ability for the user to edit the active lease separately from the schedule, as described here.

@ammario ammario added the bug label Jun 10, 2022
@ketang
Copy link
Contributor

ketang commented Jun 10, 2022

In other words, you want to distinguish between extending this workspace incarnation's lifetime versus extending the lifetime for every future incarnation.

@johnstcn
Copy link
Member

johnstcn commented Jun 10, 2022

Thoughts:

Why would I expect it to change the lease at all?

The "change active lease" behaviour was added in #2165, the idea being that users would not necessarily differentiate between the workspace's "active lease" and the workspace's schedule.

I looked at the code a bit and have no idea what's causing this behavior.

What likely happened was that the active lease of the workspace had previously been extended, and updating the workspace TTL clobbered this previous lease. This is definitely not what a user would expect.

Possible solutions:

  1. Make extending the workspace's "active lease" optional and opt-in (UI checkbox / CLI flag)
  2. When updating workspace TTL, do not update the deadline of the active workspace build if it had previously been extended. This can be detected by comparing the time the provisioner job was completed plus the current workspace TTL to the deadline of the active workspace build. Alternatively, only update if the new deadline is after the current deadline, and not before.

We should definitely to 2) in any case; clobbering a previously extended workspace's deadline is not desirable behaviour.

@ammario
Copy link
Member Author

ammario commented Jun 10, 2022

@johnstcn I think we added #2165 because (at the time) there was no other way to extend the active lease. With the time-based approach, we can safely eliminate the coupling.

@johnstcn
Copy link
Member

johnstcn commented Jun 10, 2022

From discussion:

  • When editing a workspace's scheduled shutdown time, the deadline of the active workspace build will no longer be updated.
  • The time preview will be kept, but the CLI "are you sure?" nag is no longer neccessary. Ditto with the UI danger warning when the time goes down low enough.

@johnstcn johnstcn self-assigned this Jun 10, 2022
@ketang
Copy link
Contributor

ketang commented Jun 10, 2022

My understanding (or how I think this should work) is that we only look at the schedule when we create a workspace. After that, we only look at that workspace's countdown. Is that right?

@johnstcn
Copy link
Member

My understanding (or how I think this should work) is that we only look at the schedule when we create a workspace. After that, we only look at that workspace's countdown. Is that right?

Yes, correct. We used to do it that way but in #1783 we decided we should to tightly couple the scheduled shutdown time of a running workspace with the schedule of the workspace -- when the workspace schedule is updated, the actively running workspace's shutdown time also gets updated.

This is essentially reverting part of the work done in that ticket -- other work done in that ticket is still valuable (showing what the actual shutdown time would be based on changing the schedule).

@johnstcn
Copy link
Member

This should be fixed by #2282. Please re-open if not.

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

No branches or pull requests

4 participants