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: claim prebuilds based on workspace parameters instead of preset id#19279

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 10 commits intomainfromjjs/18356
Aug 20, 2025

Conversation

SasSwart
Copy link
Contributor

@SasSwartSasSwart commentedAug 11, 2025
edited
Loading

Closes#18356.

This change finds and selects a matching preset if one was not chosen during workspace creation. This solidifies the relationship between presets and parameters.

When a workspace is created without in explicitly chosen preset, it will now still be eligible to claim a prebuilt workspace if one is available.

@SasSwartSasSwart changed the titleJjs/18356feat: claim prebuilds based on workspace parameters instead of preset idAug 11, 2025
@SasSwartSasSwartforce-pushed thejjs/18356 branch 3 times, most recently frome999a58 tof07ccccCompareAugust 15, 2025 09:18
Copy link
ContributorAuthor

@SasSwartSasSwart left a comment

Choose a reason for hiding this comment

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

Self Review

}

func (q*querier)FindMatchingPresetID(ctx context.Context,arg database.FindMatchingPresetIDParams) (uuid.UUID,error) {
_,err:=q.GetTemplateVersionByID(ctx,arg.TemplateVersionID)
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I don't like this, but I can't find a better way and there is precedent for this approach. Open to alternatives.

Copy link
Member

Choose a reason for hiding this comment

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

The alternative is to essentially duplicate the logic inGetTemplateVersionByID, which I'm less a fan of.

returnerr
}

ifb.templateVersionPresetID==uuid.Nil {
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

This is not strictly necessary for when a prebuilt workspace is claimed, but it ensures that a workspace build always has a preset ID set if one matches.

johnstcn reacted with thumbs up emoji
@SasSwartSasSwart marked this pull request as ready for reviewAugust 15, 2025 12:14
Copy link
Member

@johnstcnjohnstcn left a comment

Choose a reason for hiding this comment

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

Tests look good to me, I'm just slightly worried about the current policy returning the prebuild with the most specific set of parameters.

}

func (q*querier)FindMatchingPresetID(ctx context.Context,arg database.FindMatchingPresetIDParams) (uuid.UUID,error) {
_,err:=q.GetTemplateVersionByID(ctx,arg.TemplateVersionID)
Copy link
Member

Choose a reason for hiding this comment

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

The alternative is to essentially duplicate the logic inGetTemplateVersionByID, which I'm less a fan of.

Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

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

Minor nits on the query side, otherwise LGTM.

Comment on lines 255 to 256
SELECT unnest(@parameter_names::text[])AS name,
unnest(@parameter_values::text[])AS value
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
SELECT unnest(@parameter_names::text[])AS name,
unnest(@parameter_values::text[])AS value
SELECT
unnest(@parameter_names::text[])AS name,
unnest(@parameter_values::text[])AS value

I suggest avoiding alignment, and if needed, line-break so indentation can be used.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

done.

COALESCE(COUNT(tvpp.name),0)AS total_preset_params,
COALESCE(COUNT(pp.name),0)AS matching_params
FROM template_version_presets tvp
LEFT JOIN template_version_preset_parameters tvppONtvpp.template_version_preset_id=tvp.id
Copy link
Member

Choose a reason for hiding this comment

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

These left join suggests there is merit in including presets with no parameters as well as zero matches with provided params, why would we want this?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Presets that define 0 parameters are valid. They're used in more trivial templates, usually docker based, where there really isn't much to change but one still wants prebuilds. In this case one would define a preset with no parameters that desiresn prebuilt workspaces. This form of the query allows a workspace in such a template to still match a preset and therefore claim a prebuilt workspace.

mafredri reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

This is useful for simpler parameters where one wants prebuilds without specifying any parameters. You could define a preset that sets no parameters. If such a preset exists, it would be selected automatically by this.

iferr!=nil {
returnBuildError{http.StatusInternalServerError,"find matching preset",err}
}
b.templateVersionPresetID=presetID
Copy link
Member

Choose a reason for hiding this comment

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

This code path could suggest to the reader that there will always be a match, a comment mentioning it will be nil if none is found may be beneficial to avoid wrong assumptions (since we're not returning error from find).

@SasSwartSasSwart merged commitf9a6adc intomainAug 20, 2025
28 checks passed
@SasSwartSasSwart deleted the jjs/18356 branchAugust 20, 2025 09:02
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsAug 20, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@mafredrimafredrimafredri approved these changes

@johnstcnjohnstcnjohnstcn approved these changes

Assignees

@SasSwartSasSwart

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Prebuilt workspaces should be claimed based on the set of chosen parameters
3 participants
@SasSwart@mafredri@johnstcn

[8]ページ先頭

©2009-2025 Movatter.jp