Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Decision] Standardize auto start crontab format #1429

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 May 13, 2022 · 17 comments
Closed
Tracked by #1317

[Decision] Standardize auto start crontab format #1429

ammario opened this issue May 13, 2022 · 17 comments
Labels
api Area: HTTP API needs decision Needs a higher-level decision to be unblocked. site Area: frontend dashboard
Milestone

Comments

@ammario
Copy link
Member

ammario commented May 13, 2022

The standard crontab format is already well documented throughout the internet, and something most DevOps people (our ideal configurer) will be familiar with. If we want to help them a little, we could include a link to crontab.guru.

This is in the spirit of invent as little as possible and as a last resort.

Originally posted by @ammario in #813 (comment)

@johnstcn johnstcn self-assigned this May 13, 2022
@johnstcn
Copy link
Member

@ammario FWIW, the reason behind templating the crontab is that we explicitly do not allow schedules that specify either day-of-month or month, as we expect schedules to be applicable weekly.
Should we also relax that restriction and allow users to build their workspace on the 29th of February?

@ammario
Copy link
Member Author

ammario commented May 13, 2022

Haha, well is there a technical reason for the restriction or is it that we consider it a very-unlikely use case?

@johnstcn
Copy link
Member

johnstcn commented May 13, 2022

I really can't think of any technical reason against -- just that someone could configure a workspace to stay running for one leap year.

@ammario
Copy link
Member Author

ammario commented May 13, 2022

Haha, I think we give them the full power of cron. It would be odd for them to start a workspace every leap year, but it's less cognitive overhead for them to use a familiar format.

I could see why one would want a monthly auto-stop. It's like a last resort measure to save costs.

@greyscaled
Copy link
Contributor

Please include me on this breakout/decision -- I need to understand the UX and UI impact (@johnstcn ).

We can have a separate discussion for this from the one that will occur for #1433 and #634 , even if they're in the same meeting/back-to-back.

I think they're separate concerns.

@greyscaled
Copy link
Contributor

Please add your planning poker estimate with ZenHub @johnstcn

@greyscaled greyscaled self-assigned this May 14, 2022
@greyscaled greyscaled added needs grooming ๐Ÿช’ site Area: frontend dashboard api Area: HTTP API cli Area: CLI labels May 14, 2022
@misskniss misskniss added this to the Community MVP milestone May 17, 2022
@johnstcn
Copy link
Member

For the moment we are going to maintain the current restrictions around crontab format as unlocking month and day-of-month options causes more complexity down the line.

@greyscaled
Copy link
Contributor

For the moment we are going to maintain the current restrictions around crontab format as unlocking month and day-of-month options causes more complexity down the line.

Based on this comment, I'm going to close this as complete. I'll add [Decision] into the labels/title to reflect our decision.

We are going with

  • autostart_schedule as a weekly schedule (HH:mm days-of-week)
  • ttl --> time to live (duration)

@greyscaled greyscaled added invalid ๐Ÿ˜ฟ and removed missing details ๐Ÿ‘€ site Area: frontend dashboard api Area: HTTP API cli Area: CLI labels May 18, 2022
@greyscaled greyscaled changed the title Standardize auto start crontab format [Decision] Standardize auto start crontab format May 18, 2022
@ammario
Copy link
Member Author

ammario commented May 18, 2022

Hold up one sec. There is also a timezone field in autostart_schedule, right?

And, is TTL bounded at all? Obviously if it's above 24h bugs ensue. Why use TTL instead of a fixed "Auto Stop" schedule? Does TTL apply if the user manually started the workspace?

@ammario ammario reopened this May 18, 2022
@johnstcn
Copy link
Member

johnstcn commented May 18, 2022

(EDIT: formatting)

There is also a timezone field in autostart_schedule, right?

Correct. This defaults to UTC. Users can specify a timezone.

And, is TTL bounded at all?

It can be unset, and if set, we have not agreed on a set upper bound (apart from ~290 days which is the upper bound of the underlying data representation).

Obviously if it's above 24h bugs ensue.

Can you please enumerate some of the possible bugs you anticipate?
We will only use the TTL for automated workspace shutdowns, and Autostart Schedule only for automated workspace startups; both are idempotent operations.
If you're expecting DST-related timezone bugs, what do you imagine the expected vs actual behaviour to be in these cases?
Allowing workflows such as autostarting twice a day with a TTL of 2 hours could be purposefully and intended behaviour on the part of a user.

Why use TTL instead of a fixed "Auto Stop" schedule?

For the following reasons:

  • (+) It makes the implementation of template-level thresholds simpler.
  • (=) There has been no clear customer preference expressed that point to either a separate start and stop schedules, or a start schedule plus TTL.
  • (+) The intent (at least what I percieve) behind "auto stop" is "do not leave workspaces running unnecessarily", and an autostop schedule does not map as cleanly to this concept.

Does TTL apply if the user manually started the workspace?

Autostop, if set, would apply if the user manually started the workspace, so TTL, if set, would also apply in this case.

@ammario
Copy link
Member Author

ammario commented May 19, 2022

Cool, I think the TTL is the right approach.

I see no "bugs" exactly, just behavior that isn't clear to me at first glance.

For example, if the TTL was set to 48 hours but the Auto Start starts the workspace start every 24 hours, would the workspace still turn off every 48 hours, or would each Auto Start reset the TTL timer?

@johnstcn
Copy link
Member

For example, if the TTL was set to 48 hours but the Auto Start starts the workspace start every 24 hours, would the workspace still turn off every 48 hours, or would each Auto Start reset the TTL timer?

The only valid transition from a running workspace is to a stopped state, and vice-versa for a stopped state.
If the workspace is running, we check the TTL. If the workspace is stopped, we check the autostart schedule.
So, in the case you outline above, the workspace would remain running for 48 hours before stopping.

@ammario
Copy link
Member Author

ammario commented May 19, 2022

For example, if the TTL was set to 48 hours but the Auto Start starts the workspace start every 24 hours, would the workspace still turn off every 48 hours, or would each Auto Start reset the TTL timer?

The only valid transition from a running workspace is to a stopped state, and vice-versa for a stopped state. If the workspace is running, we check the TTL. If the workspace is stopped, we check the autostart schedule. So, in the case you outline above, the workspace would remain running for 48 hours before stopping.

If the TTL is an integer multiple of 24, then it could potentially stop the workspace right before it's started or stop the workspace right after it's started. To me this seems like behavior becomes more undefined as TTL approaches a 24 hour multiple.

We don't have to solve this issue now, I'm just making sure I understand the algorithm.

@johnstcn
Copy link
Member

or stop the workspace right after it's started.

We measure TTL from the updated_at timestamp of the workspace's last build. If, for some reason, the provisioner failed to set that field correctly, we could potentially enter that situation. Unfortunately that's currently the only way I'm aware of to know how long a workspace has been up.

@ammario
Copy link
Member Author

ammario commented May 19, 2022

Ok... All makes sense to me.

@ammario ammario closed this as completed May 19, 2022
@johnstcn
Copy link
Member

Thanks @ammario for double-checking and making sure we have all our bases covered!

@greyscaled
Copy link
Contributor

Thanks all, this was a fun data-centric problem to sort out

๐ŸŒฎ ๐ŸŽ‰ @ammario @johnstcn and support from @spikecurtis and @ketang

Of course I'm missing various folx that helped along the way and reviewed the RFC too!

@misskniss misskniss added needs decision Needs a higher-level decision to be unblocked. site Area: frontend dashboard api Area: HTTP API labels Jun 14, 2022
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. site Area: frontend dashboard
Projects
None yet
Development

No branches or pull requests

4 participants