-
Notifications
You must be signed in to change notification settings - Fork 914
feat: implement autoscaling mechanism for prebuilds #18126
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
base: main
Are you sure you want to change the base?
Changes from all commits
47cb6fc
0f4d521
b957eb6
de920b8
5d31b43
b3130a8
0565fb7
99d76e5
bdfcd9e
ea7766f
1e78317
5d99ef1
158b92e
396d080
12dba6c
3fa98b2
8a063ff
12d3d88
3facaf2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1259,11 +1259,22 @@ func Preset(t testing.TB, db database.Store, seed database.InsertPresetParams) d | |||||
CreatedAt: takeFirst(seed.CreatedAt, dbtime.Now()), | ||||||
DesiredInstances: seed.DesiredInstances, | ||||||
InvalidateAfterSecs: seed.InvalidateAfterSecs, | ||||||
AutoscalingTimezone: seed.AutoscalingTimezone, | ||||||
}) | ||||||
require.NoError(t, err, "insert preset") | ||||||
return preset | ||||||
} | ||||||
|
||||||
func PresetPrebuildSchedule(t testing.TB, db database.Store, seed database.InsertPresetPrebuildScheduleParams) database.TemplateVersionPresetPrebuildSchedule { | ||||||
schedule, err := db.InsertPresetPrebuildSchedule(genCtx, database.InsertPresetPrebuildScheduleParams{ | ||||||
PresetID: seed.PresetID, | ||||||
CronExpression: seed.CronExpression, | ||||||
Instances: seed.Instances, | ||||||
}) | ||||||
require.NoError(t, err, "insert preset") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return schedule | ||||||
} | ||||||
|
||||||
func PresetParameter(t testing.TB, db database.Store, seed database.InsertPresetParametersParams) []database.TemplateVersionPresetParameter { | ||||||
parameters, err := db.InsertPresetParameters(genCtx, database.InsertPresetParametersParams{ | ||||||
TemplateVersionPresetID: takeFirst(seed.TemplateVersionPresetID, uuid.New()), | ||||||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,6 @@ | ||
-- Drop the autoscaling schedules table | ||
DROP TABLE template_version_preset_prebuild_schedules; | ||
|
||
-- Remove autoscaling_timezone column from template_version_presets table | ||
ALTER TABLE template_version_presets | ||
DROP COLUMN autoscaling_timezone; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-- Add autoscaling_timezone column to template_version_presets table | ||
ALTER TABLE template_version_presets | ||
ADD COLUMN autoscaling_timezone TEXT DEFAULT 'UTC' NOT NULL; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make more sense to co-locate the timezone with the cron expression in the |
||
|
||
-- Add table for autoscaling schedules | ||
CREATE TABLE template_version_preset_prebuild_schedules ( | ||
id UUID PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | ||
preset_id UUID NOT NULL, | ||
cron_expression TEXT NOT NULL, | ||
instances INTEGER NOT NULL, | ||
FOREIGN KEY (preset_id) REFERENCES template_version_presets (id) ON DELETE CASCADE | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
INSERT INTO | ||
template_version_preset_prebuild_schedules ( | ||
id, | ||
preset_id, | ||
cron_expression, | ||
instances | ||
) | ||
VALUES ( | ||
'e387cac1-9bf1-4fb6-8a34-db8cfb750dd0', | ||
'28b42cc0-c4fe-4907-a0fe-e4d20f1e9bfe', | ||
'* 8-18 * * 1-5', | ||
1 | ||
); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically
dbgen
help funcs define default values whenseed
is a zero value. Can you add those please?