Skip to content

feat: add inactivity cleanup and failure cleanup configuration fields to Template Schedule Form #7402

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 24 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
744e476
added workspace actions entitlement
Kira-Pilot May 1, 2023
e6e1ec6
added workspace actions experiment
Kira-Pilot May 1, 2023
c049e9e
added new route for template enterprise meta
Kira-Pilot May 3, 2023
537ced7
removing new route; repurposing old
Kira-Pilot May 3, 2023
cd6a485
add new fields to get endpoints
Kira-Pilot May 3, 2023
6c984fa
Merge remote-tracking branch 'origin/main' into workspace-actions-tem…
Kira-Pilot May 3, 2023
57a9de7
removed workspace actions experiment
Kira-Pilot May 3, 2023
07cb07c
added logic to enterprise template store
Kira-Pilot May 3, 2023
7091fc1
added new form fields
Kira-Pilot May 3, 2023
e565225
feature flagged new fields
Kira-Pilot May 3, 2023
3d9f6f5
fix validation
Kira-Pilot May 4, 2023
abab4c8
fixed submit btn
Kira-Pilot May 4, 2023
ad37203
Merge remote-tracking branch 'origin/main' into workspace-actions-tem…
Kira-Pilot May 4, 2023
240f297
fix tests
Kira-Pilot May 4, 2023
be512ee
changed ttl defaults
Kira-Pilot May 4, 2023
8536b75
added FE tests
Kira-Pilot May 4, 2023
a05eb6c
added BE tests
Kira-Pilot May 4, 2023
0478e07
fixed lint
Kira-Pilot May 4, 2023
bba4722
adjusted comment language
Kira-Pilot May 4, 2023
c76a0f4
fixing unstaged changes check
Kira-Pilot May 4, 2023
9db6b13
fix test
Kira-Pilot May 4, 2023
a2a38f0
Merge branch 'main' into workspace-actions-template-route/kira-pilot
Kira-Pilot May 4, 2023
9fa9c5b
Update coderd/database/migrations/000122_add_template_cleanup_ttls.do…
Kira-Pilot May 5, 2023
43a2267
Update coderd/database/migrations/000122_add_template_cleanup_ttls.up…
Kira-Pilot May 5, 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
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"Dsts",
"embeddedpostgres",
"enablements",
"enterprisemeta",
"errgroup",
"eventsourcemock",
"Failf",
Expand Down
15 changes: 15 additions & 0 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions coderd/database/dbfake/databasefake.go
Original file line number Diff line number Diff line change
Expand Up @@ -1945,6 +1945,8 @@ func (q *fakeQuerier) UpdateTemplateScheduleByID(_ context.Context, arg database
tpl.UpdatedAt = database.Now()
tpl.DefaultTTL = arg.DefaultTTL
tpl.MaxTTL = arg.MaxTTL
tpl.FailureTTL = arg.FailureTTL
tpl.InactivityTTL = arg.InactivityTTL
q.templates[idx] = tpl
return tpl.DeepCopy(), nil
}
Expand Down
4 changes: 3 additions & 1 deletion coderd/database/dump.sql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BEGIN;
ALTER TABLE ONLY templates DROP COLUMN IF EXISTS failure_ttl;
ALTER TABLE ONLY templates DROP COLUMN IF EXISTS inactivity_ttl;
COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BEGIN;
ALTER TABLE ONLY templates ADD COLUMN IF NOT EXISTS failure_ttl BIGINT NOT NULL DEFAULT 0;
ALTER TABLE ONLY templates ADD COLUMN IF NOT EXISTS inactivity_ttl BIGINT NOT NULL DEFAULT 0;
COMMIT;
2 changes: 2 additions & 0 deletions coderd/database/modelqueries.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ func (q *sqlQuerier) GetAuthorizedTemplates(ctx context.Context, arg GetTemplate
&i.MaxTTL,
&i.AllowUserAutostart,
&i.AllowUserAutostop,
&i.FailureTTL,
&i.InactivityTTL,
); err != nil {
return nil, err
}
Expand Down
4 changes: 3 additions & 1 deletion coderd/database/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 31 additions & 9 deletions coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion coderd/database/queries/templates.sql
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ SET
allow_user_autostart = $3,
allow_user_autostop = $4,
default_ttl = $5,
max_ttl = $6
max_ttl = $6,
failure_ttl = $7,
inactivity_ttl = $8
WHERE
id = $1
RETURNING
Expand Down
2 changes: 2 additions & 0 deletions coderd/database/sqlc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ overrides:
template_max_ttl: TemplateMaxTTL
motd_file: MOTDFile
uuid: UUID
failure_ttl: FailureTTL
inactivity_ttl: InactivityTTL

sql:
- schema: "./dump.sql"
Expand Down
14 changes: 11 additions & 3 deletions coderd/schedule/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ type TemplateScheduleOptions struct {
//
// If set, users cannot disable automatic workspace shutdown.
MaxTTL time.Duration `json:"max_ttl"`
// If FailureTTL is set, all failed workspaces will be stopped automatically after this time has elapsed.
FailureTTL time.Duration `json:"failure_ttl"`
// If InactivityTTL is set, all inactive workspaces will be deleted automatically after this time has elapsed.
InactivityTTL time.Duration `json:"inactivity_ttl"`
}

// TemplateScheduleStore provides an interface for retrieving template
Expand Down Expand Up @@ -47,9 +51,11 @@ func (*agplTemplateScheduleStore) GetTemplateScheduleOptions(ctx context.Context
UserAutostartEnabled: true,
UserAutostopEnabled: true,
DefaultTTL: time.Duration(tpl.DefaultTTL),
// Disregard the value in the database, since MaxTTL is an enterprise
// feature.
MaxTTL: 0,
// Disregard the values in the database, since MaxTTL, FailureTTL, and InactivityTTL are enterprise
// features.
MaxTTL: 0,
FailureTTL: 0,
InactivityTTL: 0,
}, nil
}

Expand All @@ -68,5 +74,7 @@ func (*agplTemplateScheduleStore) SetTemplateScheduleOptions(ctx context.Context
AllowUserAutostart: tpl.AllowUserAutostart,
AllowUserAutostop: tpl.AllowUserAutostop,
MaxTTL: tpl.MaxTTL,
FailureTTL: tpl.FailureTTL,
InactivityTTL: tpl.InactivityTTL,
})
}
Loading