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

Skip to content

feat: add crontab package for supporting autostart/stop. #844

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

Merged
merged 9 commits into from
Apr 4, 2022

Conversation

johnstcn
Copy link
Member

@johnstcn johnstcn commented Apr 4, 2022

This is basically a small wrapper around robfig/cron/v3.

Fixes #817.

This is basically a small wrapper around robfig/cron/v3.

Fixes #817.
@johnstcn johnstcn self-assigned this Apr 4, 2022
@codecov
Copy link

codecov bot commented Apr 4, 2022

Codecov Report

Merging #844 (32f0cb2) into main (315676b) will increase coverage by 0.12%.
The diff coverage is 83.33%.

@@            Coverage Diff             @@
##             main     #844      +/-   ##
==========================================
+ Coverage   65.72%   65.85%   +0.12%     
==========================================
  Files         202      203       +1     
  Lines       13209    13227      +18     
  Branches       87       87              
==========================================
+ Hits         8681     8710      +29     
+ Misses       3637     3626      -11     
  Partials      891      891              
Flag Coverage Δ
unittest-go- 65.40% <83.33%> (+0.20%) ⬆️
unittest-go-macos-latest 52.37% <83.33%> (+0.07%) ⬆️
unittest-go-ubuntu-latest 55.11% <83.33%> (+0.02%) ⬆️
unittest-go-windows-2022 51.77% <83.33%> (-0.02%) ⬇️
unittest-js 62.63% <ø> (ø)
Impacted Files Coverage Δ
coderd/autostart/schedule/schedule.go 83.33% <83.33%> (ø)
provisionersdk/serve.go 35.13% <0.00%> (-8.11%) ⬇️
cli/cliui/agent.go 77.19% <0.00%> (-5.27%) ⬇️
coderd/workspaceresources.go 59.34% <0.00%> (-1.63%) ⬇️
peerbroker/proxy.go 57.55% <0.00%> (-0.59%) ⬇️
provisionerd/provisionerd.go 79.29% <0.00%> (+0.14%) ⬆️
peer/conn.go 79.44% <0.00%> (+0.76%) ⬆️
provisioner/echo/serve.go 56.80% <0.00%> (+2.39%) ⬆️
coderd/provisionerdaemons.go 62.05% <0.00%> (+2.52%) ⬆️
provisionersdk/transport.go 85.10% <0.00%> (+6.38%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 315676b...32f0cb2. Read the comment docs.

@johnstcn johnstcn marked this pull request as ready for review April 4, 2022 11:34
Copy link
Member

@kylecarbs kylecarbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm nervous about generalizing a CRON package with the single use-case in mind. It's not that this is the wrong abstraction, but it's guesswork on my part to tell if it's the right one since it's not plugged into anything.

You likely have a clearer picture of how this will play out than I do, so I shall approve regardless. It looks well tested and structurally aligned, but it's hard to truly know until we use it!


// WeeklySchedule represents a weekly cron schedule.
// It's essentially a thin wrapper for robfig/cron/v3 that implements Stringer.
type WeeklySchedule struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This weekly schedule feels pretty specified to autostart/stop. Could we add this to the autostart/stop package once that's in (assuming it'll be inside it's own package)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I'm not sure this needs to have Weekly as a prefix. That seems like part of the parsing logic, not the struct functionality.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can move this to coderd/autostart/schedule if that works?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on what's here, I'd say that makes sense. I'm uncertain what structurally makes sense until we have more of the implementation worked out, but as long as we're not opposed to moving this afterwards, I'm good with it!

@johnstcn johnstcn merged commit 8a1ae18 into main Apr 4, 2022
@johnstcn johnstcn deleted the cj/crontabtz branch April 4, 2022 20:34
greyscaled added a commit that referenced this pull request Apr 13, 2022
Summary:

This adds the client-side implementation to match the types introduced
in #879 and #844 as well as a card in the Workspaces page to present
workspace the data.

Details:

* Added a convenient line break in the example schedule.Weekly
* Added missing `json:""` annotations in codersdk/workspaces.go
* Installed cronstrue for displaying human-friendly cron strings
* Adjusted/Added client-side types to match codersdk/workspaces.go
* Added new component WorkspaceSchedule.tsx

Next Steps:

The WorkspaceSchedule.tsx card only presents data (on purpose). In order
to make it PUT/modify data, a few changes will be made:

- a form for updating workspace schedule will be created
- the form will wrapped in a dialog or modal
- the WorkspaceSchedule card will have a way of opening the modal which
will likely be generalized up to WorkspaceSection.tsx

Impact:

This is user-facing

This does not fully resolve either #274 or #275 (I may further decompose
that work to reflect reality and keep things in small deliverable
increments), but adds significant progress towards both.
greyscaled added a commit that referenced this pull request Apr 14, 2022
Summary:

This adds the client-side implementation to match the types introduced
in #879 and #844 as well as a card in the Workspaces page to present
workspace the data.

Details:

* Added a convenient line break in the example schedule.Weekly
* Added missing `json:""` annotations in codersdk/workspaces.go
* Installed cronstrue for displaying human-friendly cron strings
* Adjusted/Added client-side types to match codersdk/workspaces.go
* Added new component WorkspaceSchedule.tsx

Next Steps:

The WorkspaceSchedule.tsx card only presents data (on purpose). In order
to make it PUT/modify data, a few changes will be made:

- a form for updating workspace schedule will be created
- the form will wrapped in a dialog or modal
- the WorkspaceSchedule card will have a way of opening the modal which
will likely be generalized up to WorkspaceSection.tsx

Impact:

This is user-facing

This does not fully resolve either #274 or #275 (I may further decompose
that work to reflect reality and keep things in small deliverable
increments), but adds significant progress towards both.
@misskniss misskniss added this to the V2 Beta milestone May 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

create cron-style library or wrapper for workspace autostart / autostop
5 participants