Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add migrations and queries to support prebuilds#16891

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

Merged
SasSwart merged 77 commits intomainfromprebuilds-db
Apr 3, 2025

Conversation

SasSwart
Copy link
Contributor

@SasSwartSasSwart commentedMar 12, 2025
edited by dannykopping
Loading

Depends on#16916(change base tomain once it is merged)

Closescoder/internal#514

This is one of several PRs to decompose thedk/prebuilds feature branch into separate PRs to merge intomain.

SasSwart

This comment was marked as outdated.

@@ -12,6 +12,8 @@ const (
LockIDDBPurge
LockIDNotificationsReportGenerator
LockIDCryptoKeyRotation
LockIDReconcileTemplatePrebuilds
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We need two separate locks because we'll have awider reconciliation loop which must hold a global lock, and an inner lock which is used to protect the piece where wedetermine the state. The latter can be called outside of a reconciliation loop (as in the metrics collection).

@dannykoppingdannykopping changed the base branch frommain toprebuilds-system-userMarch 13, 2025 21:01
@dannykoppingdannykoppingforce-pushed theprebuilds-db branch 2 times, most recently from2024110 to390a1fdCompareMarch 13, 2025 21:22
@evgeniy-scherbina
Copy link
Contributor

Do we want to add unit-tests on DB level in this PR to make sure VIEWs and SQL queries are correct?

@dannykopping
Copy link
Contributor

Do we want to add unit-tests on DB level in this PR to make sure VIEWs and SQL queries are correct?

Feels like overkill to me, since we have tests which rely on the views indirectly, but if you feel it'd add value then go ahead 👍

@SasSwartSasSwartforce-pushed theprebuilds-db branch 3 times, most recently from70ecdcc to7e062e2CompareMarch 17, 2025 08:14
SasSwartand others added7 commitsMarch 17, 2025 12:11
Signed-off-by: Danny Kopping <dannykopping@gmail.com>
Signed-off-by: Danny Kopping <dannykopping@gmail.com>
Signed-off-by: Danny Kopping <dannykopping@gmail.com>
Signed-off-by: Danny Kopping <dannykopping@gmail.com>
appeasing linterSigned-off-by: Danny Kopping <dannykopping@gmail.com>
Signed-off-by: Danny Kopping <dannykopping@gmail.com>
Signed-off-by: Danny Kopping <dannykopping@gmail.com>
Copy link
Member

@EmyrkEmyrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

👍 on the RBAC checks.@spikecurtis no ResourceSystem is now used.

Resource<Type>.All() is used in almost all of these because there is no filter for orgs or a user. The reconciliation loop queries across all orgs.

The queries should succeed or fail as an entire set, rather then be filtered. Based on how they are used. In the future, if we add more views for prebuilds, we can update these queries to filter and apply the appropriate checks. Similar to how we filter workspaces & templates today.

spikecurtis reacted with thumbs up emoji
Comment on lines +1148 to +1160
workspaceObject := rbac.ResourceWorkspace.WithOwner(arg.NewUserID.String()).InOrg(preset.OrganizationID)
err = q.authorizeContext(ctx, policy.ActionCreate, workspaceObject.RBACObject())
if err != nil {
return empty, err
}

tpl, err := q.GetTemplateByID(ctx, preset.TemplateID.UUID)
if err != nil {
return empty, xerrors.Errorf("verify template by id: %w", err)
}
if err := q.authorizeContext(ctx, policy.ActionUse, tpl); err != nil {
return empty, xerrors.Errorf("use template for workspace: %w", err)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Just leave a comment this should matchInsertWorkspace

Comment on lines +1186 to +1191
func (q *querier) CountInProgressPrebuilds(ctx context.Context) ([]database.CountInProgressPrebuildsRow, error) {
if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceWorkspace.All()); err != nil {
return nil, err
}
return q.db.CountInProgressPrebuilds(ctx)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This query spans all organizations, and prebuilds are just workspaces 👍

Comment on lines +2200 to +2206
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 {
return nil, err
}
return q.db.GetPresetsBackoff(ctx, lookback)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@spikecurtis we decided to just lump in the preset metrics with template insights. Since template insights are metrics related to a template, prebuild metrics metadata is essentially the same imo.

@SasSwartSasSwart merged commit99c6f23 intomainApr 3, 2025
29 checks passed
@SasSwartSasSwart deleted the prebuilds-db branchApril 3, 2025 08:58
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsApr 3, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@dannykoppingdannykoppingdannykopping left review comments

@evgeniy-scherbinaevgeniy-scherbinaevgeniy-scherbina left review comments

@spikecurtisspikecurtisspikecurtis approved these changes

@EmyrkEmyrkEmyrk approved these changes

@johnstcnjohnstcnAwaiting requested review from johnstcn

@mtojekmtojekAwaiting requested review from mtojek

Assignees

@SasSwartSasSwart

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Add support for prebuilds to the database
5 participants
@SasSwart@evgeniy-scherbina@dannykopping@Emyrk@spikecurtis

[8]ページ先頭

©2009-2025 Movatter.jp