Skip to content

Autostop: bump deadline if workspace hits autostart time #2028

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 #11503
johnstcn opened this issue Jun 3, 2022 · 19 comments
Closed
Tracked by #11503

Autostop: bump deadline if workspace hits autostart time #2028

johnstcn opened this issue Jun 3, 2022 · 19 comments
Assignees
Labels
api Area: HTTP API needs decision Needs a higher-level decision to be unblocked.

Comments

@johnstcn
Copy link
Member

johnstcn commented Jun 3, 2022

What is your suggestion?

We may want to change autostop behaviour to bump the workspace deadline when it hits the scheduled autostart time.

Current Behaviour

Given:

  • A workspace exists that has an autostart schedule at e.g. 0900 every day and an autostop schedule for 8 hours after start
  • A user manually starts the workspace at 0200

When:

  • It turns 1000 hours

Then:

  • The workspace is stopped automatically

Desired Behaviour

When:

  • It turns 1000 hours

Then:

  • The workspace's deadline is extended to the autostart time plus normal TTL, and it stops at the "scheduled" time of 1700 hours.

Why do you want this feature?

Some folks were surprised that their workspaces got shut down at the configured time.

Are there any workarounds to get this functionality today?

coder bump my-workspace however-many-hours-you-need

Are you interested in submitting a PR for this?

Yes

@johnstcn johnstcn added new feature ✨ needs decision Needs a higher-level decision to be unblocked. api Area: HTTP API labels Jun 3, 2022
@ammario
Copy link
Member

ammario commented Jun 3, 2022

The desired behavior makes a lot more sense to me, too.

@greyscaled
Copy link
Contributor

greyscaled commented Jun 3, 2022

I agree with the desired behavior. Thinking of this, I wrote some (probably incorrect) pseudo-logic around it in the RFC, that you should only be able to extend your workspace deadline up to the next auto-on time, assuming that at the scheduled auto-on, your deadline would refresh.

I don’t know if this is overkill for the RFC Solution, but I was thinking that we could allow auto-off to be extended until it is ≥ than the auto-on time.

Example:

Grey: 9am → 9pm

If I extend by 12+ hours, the backend will just 201 my request to extend. When 9am hits the following day, my workspace will still be on so that auto-on will no-op.

Logic looks like this:

const startTime = “09:00 2022-03-04” // assume mod 24
const offTime = “21:00 2022-03-04” // assume mod 24

let scheduled = offTime

func extend () {
nextTime = scheduled + “90 minutes”

if nextTime ≥ startTime && nextTime < offTime {
scheduled = offTime + “24 hours” // “21:00 2022-03-05”
return 201
} else {
scheduled = nextTime
return 200
}
}


Revisiting that, I don't know if it's helpful or not (the 201 on further bumping deadline), but I think the desire for deadline to reset if you're still on by the next auto-start time seems like expected behavior, so we're on the right path!

@ammario
Copy link
Member

ammario commented Jun 3, 2022

Hmm why don't limit Auto-Off to start_time_interval - 1?

@kylecarbs kylecarbs changed the title Feat: Autostop: bump deadline if workspace hits autostart time Autostop: bump deadline if workspace hits autostart time Jun 7, 2022
@johnstcn johnstcn self-assigned this Jul 22, 2022
@kylecarbs
Copy link
Member

kylecarbs commented Aug 24, 2022

@johnstcn how complex is this to do? I don't have an idea of it, but if it's trivial it might be nice to add to the EE milestone.

@johnstcn
Copy link
Member Author

johnstcn commented Aug 24, 2022

@johnstcn how complex is this to do? I don't have an idea of it, but if it's trivial it might be nice to add to the EE milestone.

I would hesitate to call this "trivial", but I think enough people have found it annoying for me to try to get it in anyhow!

@johnstcn johnstcn removed their assignment Aug 30, 2022
@kylecarbs
Copy link
Member

We haven't gotten suggestions for this, so I'm closing for now!

@bpmct bpmct closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2022
@johnstcn johnstcn reopened this Jun 6, 2023
@mafredri
Copy link
Member

mafredri commented Jun 6, 2023

I'm in support of making this change. Sometimes I restart the workspace in the evening (say 8pm) and with a normal schedule of 9:30am + 14h, this would result in autostop happening at 10am, at which point the workspace will be stopped when I try to login in the morning.

@bpmct
Copy link
Member

bpmct commented Jun 21, 2023

@deansheather is working on changes related to our scheduling behavior to avoid this. Basically, workspaces will only stop during "quiet hours" to prevent workspaces from stopping at inconvenient times, such as right before an autostart. Going to close in favor of that

@bpmct bpmct closed this as not planned Won't fix, can't repro, duplicate, stale Jun 21, 2023
@ammario
Copy link
Member

ammario commented Jun 22, 2023

@bpmct can you link to more details on how "quiet hours" are defined?

@bpmct
Copy link
Member

bpmct commented Jun 22, 2023

Yep: #8117

@deansheather
Copy link
Member

Quiet hours does not interact with regular TTL (only the "restart requirement") so this needs to be reopened. I think we should just change the activity bumping code to be like:

newDeadline := time.Now().Add(ttl)
if newDeadline.After(nextAutoStartTime) {
  newDeadline = nextAutoStartTime.Add(ttl)
}

@deansheather deansheather reopened this Oct 4, 2023
@deansheather deansheather self-assigned this Oct 4, 2023
@deansheather
Copy link
Member

We also need to change the initial calculation for deadline to have this extra clause too, in autostop.CalculateAutostop()

@bpmct
Copy link
Member

bpmct commented Nov 5, 2023

@deansheather - is this still on your plate

@deansheather
Copy link
Member

I had a PR for this but it went stale due to the offsite and my vacation. I don't think it's super high priority though TBH

@stirby
Copy link
Collaborator

stirby commented Jan 8, 2024

Bumping this and re-opened the PR. We should bring it into this sprint.

@mattlqx
Copy link

mattlqx commented Jan 10, 2024

A couple of our folks have noticed this quirk as well. Not having this breaks the assumption that your workspace will be up from autostart time to autostart time + autostop duration when using an auto-start schedule.

@stirby
Copy link
Collaborator

stirby commented Mar 6, 2024

@bpmct @sreya I think this is a must-do for the upcoming sprint. Several customers have been experiencing unexpected workspace shutoffs due to Autostop issues. Solving this would both improve user experience and expedite debugging of other scheduling issues.

@bpmct
Copy link
Member

bpmct commented Mar 6, 2024

Sounds good to me.

@bpmct bpmct added the must-do Issues that must be completed by the end of the Sprint. Or else. Only humans may set this. label Mar 6, 2024
@Kira-Pilot Kira-Pilot assigned Kira-Pilot and Emyrk and unassigned Kira-Pilot Mar 11, 2024
@stirby
Copy link
Collaborator

stirby commented Mar 11, 2024

We fixed this a while back!
290180b

@stirby stirby closed this as completed Mar 11, 2024
@stirby stirby removed the must-do Issues that must be completed by the end of the Sprint. Or else. Only humans may set this. label Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Area: HTTP API needs decision Needs a higher-level decision to be unblocked.
Projects
None yet
Development

Successfully merging a pull request may close this issue.