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: delete pending canceled prebuilds#20499

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

Conversation

@ssncferreira
Copy link
Contributor

@ssncferreirassncferreira commentedOct 27, 2025
edited
Loading

Description

PR#20387 introduced canceling pending prebuild jobs from inactive template versions to avoid provisioning obsolete workspaces. However, the associated prebuilds remained in the database with "Canceled" status, visible in the UI.

This PR now orphan-deletes these canceled prebuilt workspaces. Since the canceled jobs were never processed by a provisioner, no Terraform resources were created, making orphan deletion safe.

Orphan deletion always creates a provisioner job, but behaves differently based on provisioner availability:

  • If no provisioner daemon is available, the job is immediately marked as completed and the workspace is marked as deleted without any provisioner processing
  • If a provisioner daemon is available, it processes the delete job with empty Terraform state (no actual resources to destroy)

The job cancellation and workspace deletion occur atomically in the same transaction. We don't split this into two separate reconciliation runs because there's no way to distinguish between system-canceled prebuilds and user-canceled workspaces. If we deleted canceled workspaces in a later run, we'd delete user-canceled workspaces that users may want to keep for troubleshooting.

Note: This only applies to system-generated prebuilds from inactive template versions.

Changes

  • UpdateUpdatePrebuildProvisionerJobWithCancel query to return job ID, workspace ID, template ID, and template version preset ID
  • AddDeprovisionMode enum to support orphan deletion in the provision flow
  • UpdateActionTypeCancelPending handler to cancel jobs and orphan-delete associated workspaces atomically

@ssncferreirassncferreira changed the titlefeat: orphan delete pending canceled prebuildsfeat: delete orphan pending canceled prebuildsOct 27, 2025
@ssncferreirassncferreira changed the titlefeat: delete orphan pending canceled prebuildsfeat: delete pending canceled prebuildsOct 27, 2025
@ssncferreirassncferreiraforce-pushed thessncferreira/feat-delete-canceled-prebuilds branch 4 times, most recently fromd45515d to85f8107CompareOctober 28, 2025 12:30
@ssncferreirassncferreiraforce-pushed thessncferreira/feat-delete-canceled-prebuilds branch from85f8107 tob0cde3bCompareOctober 28, 2025 12:55
database.ProvisionerJobStatusCanceling,
},
templateVersionActive: []bool{true,false},
templateVersionActive: []bool{true},
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

There seems to be an issue with this test: when a template version is inactive (templateVersionActive = false), any prebuilds in thedatabase.ProvisionerJobStatusRunning state should be deleted.

From some quick debugging, it looks like the reconciliation loop isn’t picking up running prebuilds, theGetRunningPrebuiltWorkspaces query is returning 0 rows. I suspect this might be related to the agent not being properly marked as “ready”, which would cause those prebuilds to be excluded from the query results.

I’ll investigate this further and address the test in a follow-up PR.

Copy link
Member

Choose a reason for hiding this comment

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

Can you add a TODO for this?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Can you add a TODO for this?

Added inb135381

@ssncferreirassncferreira marked this pull request as ready for reviewOctober 28, 2025 13:01
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.

I don't have any blocking comments.

Comment on lines +717 to +720
workspace,err:=db.GetWorkspaceByID(ctx,workspaceID)
iferr!=nil {
returnxerrors.Errorf("get workspace by ID: %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.

I was going to mention that since you changed theUpdatePrebuildProvisionerJobWithCancel query to return workspace_id, we could also returnowner_id there as well so we can use it here. Unfortunately it looks likewsbuilder needs the workspace in any case.

database.ProvisionerJobStatusCanceling,
},
templateVersionActive: []bool{true,false},
templateVersionActive: []bool{true},
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a TODO for this?

@ssncferreirassncferreira merged commitc3e3bb5 intomainOct 29, 2025
30 checks passed
@ssncferreirassncferreira deleted the ssncferreira/feat-delete-canceled-prebuilds branchOctober 29, 2025 10:37
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsOct 29, 2025
@ssncferreirassncferreira added cherry-pick/v2.28Needs to be cherry-picked to the 2.28 release branch and removed cherry-pick/v2.28Needs to be cherry-picked to the 2.28 release branch labelsOct 29, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@johnstcnjohnstcnjohnstcn approved these changes

@SasSwartSasSwartAwaiting requested review from SasSwart

Assignees

@ssncferreirassncferreira

Labels

cherry-pick/v2.28Needs to be cherry-picked to the 2.28 release branch

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@ssncferreira@johnstcn

[8]ページ先頭

©2009-2025 Movatter.jp