Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

autostart/autostop: move to traditional 5-valued cron string for compatibility#1049

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
johnstcn merged 6 commits intomainfromcj/schedule-compat
Apr 18, 2022

Conversation

johnstcn
Copy link
Member

This PR modfies the original 3-valued cron strings used in packageschedule to be traditional 5-valued cron strings.

  • schedule.Weekly will validate that themonth anddom fields are equal to*
  • cli autostart/autostop will attempt to detect local timezone usingTZ env var, defaulting to UTC
  • cli autostart/autostop no longer accepts a raw schedule -- instead use the--minute,--hour,--dow, and--tz arguments. Default schedules are provided that should suffice for most users.

Fixes#993

@johnstcnjohnstcn self-assigned thisApr 16, 2022
@johnstcnjohnstcn requested a review froma team as acode ownerApril 16, 2022 17:48
@codecov
Copy link

codecovbot commentedApr 16, 2022
edited
Loading

Codecov Report

Merging#1049 (be426af) intomain (cf8a20d) willincrease coverage by0.13%.
The diff coverage is100.00%.

@@            Coverage Diff             @@##             main    #1049      +/-   ##==========================================+ Coverage   67.31%   67.45%   +0.13%==========================================  Files         259      259                Lines       15061    15100      +39       Branches      152      152              ==========================================+ Hits        10139    10185      +46+ Misses       3899     3896       -3+ Partials     1023     1019       -4
FlagCoverage Δ
unittest-go-macos-latest53.76% <100.00%> (+0.13%)⬆️
unittest-go-postgres-66.69% <100.00%> (+0.07%)⬆️
unittest-go-ubuntu-latest56.26% <100.00%> (+0.15%)⬆️
unittest-go-windows-202253.16% <100.00%> (+0.14%)⬆️
unittest-js67.96% <100.00%> (-0.14%)⬇️
Impacted FilesCoverage Δ
site/src/test_helpers/entities.ts100.00% <ø> (ø)
site/src/util/schedule.ts100.00% <ø> (ø)
cli/workspaceautostart.go80.76% <100.00%> (-0.19%)⬇️
cli/workspaceautostop.go80.76% <100.00%> (-0.19%)⬇️
coderd/autostart/schedule/schedule.go90.90% <100.00%> (+7.57%)⬆️
...ite/src/components/Workspace/WorkspaceSchedule.tsx75.00% <100.00%> (ø)
provisionersdk/serve.go35.13% <0.00%> (-8.11%)⬇️
codersdk/provisionerdaemons.go59.70% <0.00%> (-5.98%)⬇️
... and7 more

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last updatecf8a20d...be426af. Read thecomment docs.

Copy link
Member

@kylecarbskylecarbs left a comment

Choose a reason for hiding this comment

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

Minor nits. LGTM

RunE: func(cmd *cobra.Command, args []string) error {
client, err := createClient(cmd)
if err != nil {
return err
}

workspace, err := client.WorkspaceByName(cmd.Context(), codersdk.Me, args[0])
spec := fmt.Sprintf("CRON_TZ=%s %s %s * * %s", autostartTimezone, autostartMinute, autostartHour, autostartDayOfWeek)
Copy link
Contributor

Choose a reason for hiding this comment

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

praise: nice!

Comment on lines +77 to +80
tzEnv := os.Getenv("TZ")
if tzEnv == "" {
tzEnv = "UTC"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

praise: nice 😎


cmd.Flags().StringVar(&autostopMinute, "minute", "0", "autostop minute")
cmd.Flags().StringVar(&autostopHour, "hour", "18", "autostop hour")
cmd.Flags().StringVar(&autostopDayOfWeek, "dow", "1-5", "autostop hour")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cmd.Flags().StringVar(&autostopDayOfWeek,"dow","1-5","autostophour")
cmd.Flags().StringVar(&autostopDayOfWeek,"dow","1-5","autostopday(s) of week")

at: time.Time{},
expectedNext: time.Time{},
expectedError: "validate weekly schedule: expected month and dom to be *",
},
Copy link
Contributor

Choose a reason for hiding this comment

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

praise: Great tests

@greyscaled
Copy link
Contributor

greyscaled commentedApr 18, 2022
edited
Loading

@johnstcn we're seeing a parse failure in our Storybook. I think we need to update these here to have* for month and day of month:

exportconstMockWorkspaceAutostartDisabled:WorkspaceAutostartRequest={
schedule:"",
}
exportconstMockWorkspaceAutostartEnabled:WorkspaceAutostartRequest={
// Runs at 9:30am Monday through Friday using Canada/Eastern
// (America/Toronto) time
schedule:"CRON_TZ=Canada/Eastern 30 9 1-5",
}
exportconstMockWorkspaceAutostopDisabled:WorkspaceAutostartRequest={
schedule:"",
}
exportconstMockWorkspaceAutostopEnabled:WorkspaceAutostartRequest={
// Runs at 9:30pm Monday through Friday using America/Toronto
schedule:"CRON_TZ=America/Toronto 30 21 1-5",
}

@johnstcn
Copy link
MemberAuthor

@johnstcn we're seeing a parse failure in our Storybook. I think we need to update these here to have* for month and day of month:

exportconstMockWorkspaceAutostartDisabled:WorkspaceAutostartRequest={
schedule:"",
}
exportconstMockWorkspaceAutostartEnabled:WorkspaceAutostartRequest={
// Runs at 9:30am Monday through Friday using Canada/Eastern
// (America/Toronto) time
schedule:"CRON_TZ=Canada/Eastern 30 9 1-5",
}
exportconstMockWorkspaceAutostopDisabled:WorkspaceAutostartRequest={
schedule:"",
}
exportconstMockWorkspaceAutostopEnabled:WorkspaceAutostartRequest={
// Runs at 9:30pm Monday through Friday using America/Toronto
schedule:"CRON_TZ=America/Toronto 30 21 1-5",
}

ack

@johnstcnjohnstcn merged commitaf67280 intomainApr 18, 2022
@johnstcnjohnstcn deleted the cj/schedule-compat branchApril 18, 2022 16:04
@missknissmisskniss added this to theV2 Beta milestoneMay 15, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@kylecarbskylecarbskylecarbs approved these changes

@greyscaledgreyscaledgreyscaled approved these changes

Assignees

@johnstcnjohnstcn

Labels
None yet
Projects
None yet
Milestone
V2 Beta
Development

Successfully merging this pull request may close these issues.

autostart: make schedule cron string a full 5-valued for compatibility
4 participants
@johnstcn@greyscaled@kylecarbs@misskniss

[8]ページ先頭

©2009-2025 Movatter.jp