- Notifications
You must be signed in to change notification settings - Fork905
fix: reduce cost of prebuild failure#17697
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
Changes fromall commits
fcb3e5d
701e2a8
0fdd096
13c0e28
29e9cff
1d51dfc
5c60065
b0248c3
08b18b0
0fd347a
08981a4
0e4600c
107879b
2dea5ab
e252093
906ceb9
3a0284f
13fb1af
108ea0a
7cd2799
f9148e2
315acfa
1679ac9
d9c9d17
c47ddaa
c19f28a
b18730f
37173b0
0e3cc40
784adba
50bd9b4
8a33ac8
9439fa1
e667dad
8a51702
a793e18
a0fb69c
c6f209c
9dccf3e
c19ae04
4b145cc
80f3677
2144d13
79725b3
7e8b4b6
ab5acfb
7c09465
b7a34c5
e1e141d
354aeb4
7564178
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2226,6 +2226,15 @@ func (q *querier) GetPresetParametersByTemplateVersionID(ctx context.Context, ar | ||
return q.db.GetPresetParametersByTemplateVersionID(ctx, args) | ||
} | ||
func (q *querier) GetPresetsAtFailureLimit(ctx context.Context, hardLimit int64) ([]database.GetPresetsAtFailureLimitRow, error) { | ||
// GetPresetsAtFailureLimit returns a list of template version presets that have reached the hard failure limit. | ||
// Request the same authorization permissions as GetPresetsBackoff, since the methods are similar. | ||
if err := q.authorizeContext(ctx, policy.ActionViewInsights, rbac.ResourceTemplate.All()); err != nil { | ||
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. I still think "insights" is a weird auth context to use here. ContributorAuthor
| ||
return nil, err | ||
} | ||
return q.db.GetPresetsAtFailureLimit(ctx, hardLimit) | ||
} | ||
func (q *querier) GetPresetsBackoff(ctx context.Context, lookback time.Time) ([]database.GetPresetsBackoffRow, error) { | ||
// GetPresetsBackoff returns a list of template version presets along with metadata such as the number of failed prebuilds. | ||
if err := q.authorizeContext(ctx, policy.ActionViewInsights, rbac.ResourceTemplate.All()); err != nil { | ||
@@ -4201,6 +4210,24 @@ func (q *querier) UpdateOrganizationDeletedByID(ctx context.Context, arg databas | ||
return deleteQ(q.log, q.auth, q.db.GetOrganizationByID, deleteF)(ctx, arg.ID) | ||
} | ||
func (q *querier) UpdatePresetPrebuildStatus(ctx context.Context, arg database.UpdatePresetPrebuildStatusParams) error { | ||
preset, err := q.db.GetPresetByID(ctx, arg.PresetID) | ||
if err != nil { | ||
return err | ||
} | ||
object := rbac.ResourceTemplate. | ||
WithID(preset.TemplateID.UUID). | ||
InOrg(preset.OrganizationID) | ||
err = q.authorizeContext(ctx, policy.ActionUpdate, object) | ||
if err != nil { | ||
return err | ||
} | ||
return q.db.UpdatePresetPrebuildStatus(ctx, arg) | ||
} | ||
func (q *querier) UpdateProvisionerDaemonLastSeenAt(ctx context.Context, arg database.UpdateProvisionerDaemonLastSeenAtParams) error { | ||
if err := q.authorizeContext(ctx, policy.ActionUpdate, rbac.ResourceProvisionerDaemon); err != nil { | ||
return err | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DELETE FROM notification_templates WHERE id = '414d9331-c1fc-4761-b40c-d1f4702279eb'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
INSERT INTO notification_templates | ||
(id, name, title_template, body_template, "group", actions) | ||
VALUES ('414d9331-c1fc-4761-b40c-d1f4702279eb', | ||
'Prebuild Failure Limit Reached', | ||
E'There is a problem creating prebuilt workspaces', | ||
$$ | ||
The number of failed prebuild attempts has reached the hard limit for template **{{ .Labels.template }}** and preset **{{ .Labels.preset }}**. | ||
To resume prebuilds, fix the underlying issue and upload a new template version. | ||
dannykopping marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
Refer to the documentation for more details: | ||
- [Troubleshooting templates](https://coder.com/docs/admin/templates/troubleshooting) | ||
- [Troubleshooting of prebuilt workspaces](https://coder.com/docs/admin/templates/extending-templates/prebuilt-workspaces#administration-and-troubleshooting) | ||
$$, | ||
'Template Events', | ||
'[ | ||
{ | ||
"label": "View failed prebuilt workspaces", | ||
"url": "{{base_url}}/workspaces?filter=owner:prebuilds+status:failed+template:{{.Labels.template}}" | ||
}, | ||
{ | ||
"label": "View template version", | ||
"url": "{{base_url}}/templates/{{.Labels.org}}/{{.Labels.template}}/versions/{{.Labels.template_version}}" | ||
} | ||
]'::jsonb); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- Remove the column from the table first (must happen before dropping the enum type) | ||
ALTER TABLE template_version_presets DROP COLUMN prebuild_status; | ||
-- Then drop the enum type | ||
DROP TYPE prebuild_status; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CREATE TYPE prebuild_status AS ENUM ( | ||
'healthy', -- Prebuilds are working as expected; this is the default, healthy state. | ||
'hard_limited', -- Prebuilds have failed repeatedly and hit the configured hard failure limit; won't be retried anymore. | ||
dannykopping marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
'validation_failed' -- Prebuilds failed due to a non-retryable validation error (e.g. template misconfiguration); won't be retried. | ||
); | ||
ALTER TABLE template_version_presets ADD COLUMN prebuild_status prebuild_status NOT NULL DEFAULT 'healthy'::prebuild_status; |
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.