Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
22b9be8
feat: add user maintenance schedule for max_ttl autostop
deansheather Jun 20, 2023
92c05b3
fixup! feat: add user maintenance schedule for max_ttl autostop
deansheather Jun 20, 2023
54d939a
fixup! feat: add user maintenance schedule for max_ttl autostop
deansheather Jun 21, 2023
b274c67
rename maintenance schedule to quiet hours schedule
deansheather Jun 28, 2023
5bf53eb
Merge branch 'main' into dean/user-maintenance-window
deansheather Jun 28, 2023
ede278e
stuff
deansheather Jun 28, 2023
06272e2
progress
deansheather Jun 28, 2023
a1ebbdb
progress
deansheather Jul 6, 2023
780812c
working
deansheather Jul 6, 2023
00e4a0f
tests mostly fixed
deansheather Jul 7, 2023
6cfd270
working!
deansheather Jul 7, 2023
53f5d62
move autostop algorithm to schedule package
deansheather Jul 10, 2023
eb1c1f6
more tests
deansheather Jul 10, 2023
3dbd077
Merge branch 'main' into dean/user-maintenance-window
deansheather Jul 10, 2023
0e9437e
Merge branch 'main' into dean/user-maintenance-window
deansheather Jul 12, 2023
fd26e69
add back max_ttl and put restart_requirement behind feature flag
deansheather Jul 12, 2023
cb9428e
fixup! add back max_ttl and put restart_requirement behind feature flag
deansheather Jul 12, 2023
024233a
fixup! add back max_ttl and put restart_requirement behind feature flag
deansheather Jul 12, 2023
c7ef9cb
fixup! add back max_ttl and put restart_requirement behind feature flag
deansheather Jul 12, 2023
4c70ade
fixup! add back max_ttl and put restart_requirement behind feature flag
deansheather Jul 13, 2023
2fb3053
Merge branch 'main' into dean/user-maintenance-window
deansheather Jul 13, 2023
554e837
Disable quiet hours endpoint if not entitled
deansheather Jul 13, 2023
eb46ae2
add DST and week calculation tests
deansheather Jul 13, 2023
6af3e33
fixup! add DST and week calculation tests
deansheather Jul 13, 2023
159d107
Merge branch 'main' into dean/user-maintenance-window
deansheather Jul 16, 2023
96f5e2e
rename interface methods, merge migrations
deansheather Jul 16, 2023
cd77138
steven comments and test fix
deansheather Jul 16, 2023
87b065b
fixup! steven comments and test fix
deansheather Jul 17, 2023
8658112
remove duration
deansheather Jul 19, 2023
fe26e3f
Merge branch 'main' into dean/user-maintenance-window
deansheather Jul 19, 2023
8cebc67
Merge branch 'main' into dean/user-maintenance-window
deansheather Jul 20, 2023
85142a6
fixup! Merge branch 'main' into dean/user-maintenance-window
deansheather Jul 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! feat: add user maintenance schedule for max_ttl autostop
  • Loading branch information
deansheather committed Jun 20, 2023
commit 92c05b366702344d3b12d20309e0cc7084146d2e
5 changes: 5 additions & 0 deletions coderd/schedule/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package schedule

import (
"context"
"time"

"github.com/google/uuid"

Expand All @@ -19,6 +20,10 @@ type UserMaintenanceScheduleOptions struct {
// maintenance windows should not be used.
Schedule *Schedule
UserSet bool
// Duration is the duration of the maintenance window starting when the cron
// triggers. Workspaces can be stopped for maintenance or due to max_ttl
// during this window.
Duration time.Duration
}

type UserMaintenanceScheduleStore interface {
Expand Down
7 changes: 7 additions & 0 deletions enterprise/coderd/schedule/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package schedule
import (
"context"
"strings"
"time"

"github.com/google/uuid"
"golang.org/x/xerrors"
Expand All @@ -11,6 +12,8 @@ import (
agpl "github.com/coder/coder/coderd/schedule"
)

const userMaintenanceWindowDuration = 4 * time.Hour

// enterpriseUserMaintenanceScheduleStore provides an
// agpl.UserMaintenanceScheduleStore that has all fields implemented for
// enterprise customers.
Expand Down Expand Up @@ -46,6 +49,7 @@ func (s *enterpriseUserMaintenanceScheduleStore) parseSchedule(rawSchedule strin
return agpl.UserMaintenanceScheduleOptions{
Schedule: sched,
UserSet: userSet,
Duration: userMaintenanceWindowDuration,
}, nil
}

Expand Down Expand Up @@ -77,5 +81,8 @@ func (s *enterpriseUserMaintenanceScheduleStore) SetUserMaintenanceScheduleOptio
return agpl.UserMaintenanceScheduleOptions{}, xerrors.Errorf("update user maintenance schedule: %w", err)
}

// TODO: update max_ttl for all active builds for this user to clamp to the
// new schedule.

return opts, nil
}
7 changes: 2 additions & 5 deletions enterprise/coderd/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import (
"github.com/coder/coder/codersdk"
)

// TODO: move this constant
const userMaintenanceWindowDuration = 4 * time.Hour

// @Summary Get user maintenance schedule
// @ID get-user-maintenance-schedule
// @Security CoderSessionToken
Expand Down Expand Up @@ -46,7 +43,7 @@ func (api *API) userMaintenanceSchedule(rw http.ResponseWriter, r *http.Request)
UserSet: opts.UserSet,
Time: opts.Schedule.Time(),
Timezone: opts.Schedule.Location().String(),
Duration: userMaintenanceWindowDuration,
Duration: opts.Duration,
Next: opts.Schedule.Next(time.Now()),
})
}
Expand Down Expand Up @@ -93,7 +90,7 @@ func (api *API) putUserMaintenanceSchedule(rw http.ResponseWriter, r *http.Reque
UserSet: opts.UserSet,
Time: opts.Schedule.Time(),
Timezone: opts.Schedule.Location().String(),
Duration: userMaintenanceWindowDuration,
Duration: opts.Duration,
Next: opts.Schedule.Next(time.Now()),
})
}