Skip to content

fix: set prebuilds lifecycle parameters on creation and claim #19252

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ssncferreira
Copy link
Contributor

@ssncferreira ssncferreira commented Aug 8, 2025

Description

This PR ensures that prebuilt workspaces are properly excluded from the lifecycle executor and treated as a separate class of workspaces, fully managed by the prebuild reconciliation loop.

It introduces two lifecycle guarantees:

  • When a prebuilt workspace is created (i.e., when the workspace build completes), all lifecycle-related fields are unset, ensuring the workspace does not participate in TTL, autostop, autostart, dormancy, or auto-deletion logic.
  • When a prebuilt workspace is claimed, it transitions into a regular user workspace. At this point, all lifecycle fields are correctly populated according to template-level configurations, allowing the workspace to be managed by the lifecycle executor as expected.

Changes

  • Prebuilt workspaces now have all lifecycle-relevant fields unset during creation
  • When a prebuild is claimed:
  • Lifecycle fields are set based on template and workspace level configurations. This ensures a clean transition into the standard workspace lifecycle flow.
  • Updated lifecycle-related SQL update queries to explicitly exclude prebuilt workspaces.

Relates

Related issue: #18898

To reduce the scope of this PR and make the review process more manageable, the original implementation has been split into the following focused PRs:

These PRs should be reviewed in conjunction with this one to understand the complete set of lifecycle separation changes for prebuilt workspaces.

@ssncferreira ssncferreira force-pushed the ssncferreira/fix-prebuilds-lifecycle-params branch 4 times, most recently from ec09fd8 to dd57747 Compare August 8, 2025 11:48
@ssncferreira ssncferreira changed the title fix: prebuilds lifecycle parameters on creation and claim fix: set prebuilds lifecycle parameters on creation and claim Aug 8, 2025
@ssncferreira ssncferreira force-pushed the ssncferreira/fix-prebuilds-lifecycle-params branch from dd57747 to 6415069 Compare August 8, 2025 14:34
@ssncferreira ssncferreira marked this pull request as ready for review August 8, 2025 14:34
@@ -521,6 +524,9 @@ WHERE
id = $1;
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: make it impossible by adding AND owner_id != ...

Copy link
Contributor Author

@ssncferreira ssncferreira Aug 8, 2025

Choose a reason for hiding this comment

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

Yeah, I wasn’t sure at first whether to enforce it at the database level or just in the application layer, but I agree it makes more sense to make it impossible by adding a DB-level constraint.

Addressed in 4c847c9 and I’ve updated the other relevant queries as well to align with it.

@ssncferreira
Copy link
Contributor Author

As suggested, the scope of this PR was reduced by splitting the original implementation into smaller, more focused PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants