Skip to content

Commit 8658112

Browse files
committed
remove duration
1 parent 87b065b commit 8658112

File tree

23 files changed

+18
-117
lines changed

23 files changed

+18
-117
lines changed

cli/testdata/coder_server_--help.golden

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,6 @@ workspaces stopping during the day due to template max TTL.
388388
one hour and minute can be specified (ranges or comma separated values
389389
are not supported).
390390

391-
--quiet-hours-window-duration duration, $CODER_QUIET_HOURS_WINDOW_DURATION (default: 4h0m0s)
392-
The duration of quiet hours windows when triggered by cron. Workspaces
393-
can only be stopped due to max TTL during this window. Must be at
394-
least 1 hour.
395-
396391
⚠️ Dangerous Options
397392
--dangerous-allow-path-app-sharing bool, $CODER_DANGEROUS_ALLOW_PATH_APP_SHARING
398393
Allow workspace apps that are not served from subdomains to be shared.

cli/testdata/server-config.yaml.golden

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,3 @@ userQuietHoursSchedule:
378378
# values are not supported).
379379
# (default: <unset>, type: string)
380380
defaultQuietHoursSchedule: ""
381-
# The duration of quiet hours windows when triggered by cron. Workspaces can only
382-
# be stopped due to max TTL during this window. Must be at least 1 hour.
383-
# (default: 4h0m0s, type: duration)
384-
quietHoursWindowDuration: 4h0m0s

coderd/apidoc/docs.go

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/provisionerdserver/provisionerdserver_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,6 @@ func TestCompleteJob(t *testing.T) {
12611261
return schedule.UserQuietHoursScheduleOptions{
12621262
Schedule: sched,
12631263
UserSet: false,
1264-
Duration: 4 * time.Hour,
12651264
}, nil
12661265
},
12671266
}

coderd/schedule/autostop.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ func GetMondayOfWeek(loc *time.Location, n int64) (time.Time, error) {
286286
y, m, d := monday.Date()
287287
monday = time.Date(y, m, d, 0, 0, 0, 0, loc)
288288
if monday.Weekday() != time.Monday {
289+
// This condition should never be hit, but we have a check for it just
290+
// in case.
289291
return time.Time{}, xerrors.Errorf("calculated incorrect Monday for week %v since epoch (actual weekday %q)", n, monday.Weekday())
290292
}
291293
return monday, nil
@@ -313,7 +315,8 @@ func GetNextApplicableMondayOfNWeeks(now time.Time, n int64) (time.Time, error)
313315
return now, nil
314316
}
315317

316-
// Loop until we find a week that doesn't fail.
318+
// Loop until we find a week that doesn't fail. This should never loop, but
319+
// we account for failures just in case.
317320
var lastErr error
318321
for i := int64(0); i < 3; i++ {
319322
monday, err := GetMondayOfWeek(now.Location(), week+i)

coderd/schedule/autostop_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,6 @@ func TestCalculateAutoStop(t *testing.T) {
439439
return schedule.UserQuietHoursScheduleOptions{
440440
Schedule: sched,
441441
UserSet: false,
442-
Duration: 4 * time.Hour,
443442
}, nil
444443
},
445444
}

coderd/schedule/template.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,6 @@ type TemplateRestartRequirement struct {
5252
Weeks int64
5353
}
5454

55-
// Days returns the days of the week that the workspace must be restarted.
56-
func (r TemplateRestartRequirement) Days() []time.Weekday {
57-
days := make([]time.Weekday, 0, 7)
58-
for i, day := range DaysOfWeek {
59-
if r.DaysOfWeek&(1<<uint(i)) != 0 {
60-
days = append(days, day)
61-
}
62-
}
63-
return days
64-
}
65-
6655
// DaysMap returns a map of the days of the week that the workspace must be
6756
// restarted.
6857
func (r TemplateRestartRequirement) DaysMap() map[time.Weekday]bool {

coderd/schedule/user.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package schedule
22

33
import (
44
"context"
5-
"time"
65

76
"github.com/google/uuid"
87

@@ -20,10 +19,6 @@ type UserQuietHoursScheduleOptions struct {
2019
// quiet hours windows should not be used.
2120
Schedule *Schedule
2221
UserSet bool
23-
// Duration is the duration of the quiet hours window starting when the cron
24-
// triggers. Workspaces can be stopped for maintenance or due to template
25-
// restart requirements during this window.
26-
Duration time.Duration
2722
}
2823

2924
type UserQuietHoursScheduleStore interface {
@@ -53,7 +48,6 @@ func (*agplUserQuietHoursScheduleStore) Get(_ context.Context, _ database.Store,
5348
return UserQuietHoursScheduleOptions{
5449
Schedule: nil,
5550
UserSet: false,
56-
Duration: 0,
5751
}, nil
5852
}
5953

@@ -62,6 +56,5 @@ func (*agplUserQuietHoursScheduleStore) Set(_ context.Context, _ database.Store,
6256
return UserQuietHoursScheduleOptions{
6357
Schedule: nil,
6458
UserSet: false,
65-
Duration: 0,
6659
}, nil
6760
}

codersdk/deployment.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,10 @@ type DangerousConfig struct {
346346
}
347347

348348
type UserQuietHoursScheduleConfig struct {
349-
DefaultSchedule clibase.String `json:"default_schedule" typescript:",notnull"`
350-
WindowDuration clibase.Duration `json:"window_duration" typescript:",notnull"`
349+
DefaultSchedule clibase.String `json:"default_schedule" typescript:",notnull"`
350+
// TODO: add WindowDuration and the ability to postpone max_deadline by this
351+
// amount
352+
// WindowDuration clibase.Duration `json:"window_duration" typescript:",notnull"`
351353
}
352354

353355
const (
@@ -1592,16 +1594,6 @@ Write out the current server config as YAML to stdout.`,
15921594
Group: &deploymentGroupUserQuietHoursSchedule,
15931595
YAML: "defaultQuietHoursSchedule",
15941596
},
1595-
{
1596-
Name: "Quiet Hours Window Duration",
1597-
Description: "The duration of quiet hours windows when triggered by cron. Workspaces can only be stopped due to max TTL during this window. Must be at least 1 hour.",
1598-
Flag: "quiet-hours-window-duration",
1599-
Env: "CODER_QUIET_HOURS_WINDOW_DURATION",
1600-
Default: (4 * time.Hour).String(),
1601-
Value: &c.UserQuietHoursSchedule.WindowDuration,
1602-
Group: &deploymentGroupUserQuietHoursSchedule,
1603-
YAML: "quietHoursWindowDuration",
1604-
},
16051597
}
16061598
return opts
16071599
}

0 commit comments

Comments
 (0)