Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix!: stop workspace before update #18425

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

Merged
merged 17 commits into from
Jun 23, 2025
Merged

fix!: stop workspace before update #18425

merged 17 commits into from
Jun 23, 2025

Conversation

johnstcn
Copy link
Member

@johnstcn johnstcn commented Jun 18, 2025

Fixes #17840

NOTE: calling this out as a breaking change so that it is highly visible in the changelog.

  • CLI: Modifies coder update to stop the workspace if already running.
  • UI: Modifies "update" button to always stop the workspace if already running.

@johnstcn johnstcn changed the title Cj/prebuild template upgrade fix: stop workspace before update Jun 18, 2025
@johnstcn johnstcn changed the title fix: stop workspace before update fix!: stop workspace before update Jun 18, 2025
@johnstcn johnstcn force-pushed the cj/prebuild-template-upgrade branch from 42420b1 to fa2d4eb Compare June 18, 2025 15:17
@johnstcn johnstcn added the release/breaking This label is applied to PRs to detect breaking changes as part of the release process label Jun 18, 2025
@dannykopping dannykopping self-requested a review June 19, 2025 09:04
Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

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

No notes, awesome work @johnstcn 💪

@johnstcn johnstcn force-pushed the cj/prebuild-template-upgrade branch from ce577e1 to da8bd12 Compare June 19, 2025 15:15
@@ -1245,16 +1245,16 @@ func CreateWorkspace(t testing.TB, client *codersdk.Client, templateID uuid.UUID
}

// TransitionWorkspace is a convenience method for transitioning a workspace from one state to another.
func MustTransitionWorkspace(t testing.TB, client *codersdk.Client, workspaceID uuid.UUID, from, to database.WorkspaceTransition, muts ...func(req *codersdk.CreateWorkspaceBuildRequest)) codersdk.Workspace {
func MustTransitionWorkspace(t testing.TB, client *codersdk.Client, workspaceID uuid.UUID, from, to codersdk.WorkspaceTransition, muts ...func(req *codersdk.CreateWorkspaceBuildRequest)) codersdk.Workspace {
Copy link
Member Author

@johnstcn johnstcn Jun 20, 2025

Choose a reason for hiding this comment

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

review: This is annoying to have as a database type, so migrated to use the codersdk type instead. This inflated the diff a bit but removes an unnecessary conversion.

@johnstcn johnstcn marked this pull request as ready for review June 20, 2025 14:33
@johnstcn johnstcn requested a review from aslilac June 20, 2025 14:34
Copy link
Member

@aslilac aslilac left a comment

Choose a reason for hiding this comment

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

The react code looks good

I took a bit of a closer look this time tho, and I'm wondering if this should be handled by the backend rather than the clients? The CLI and the frontend are now both responsible for producing this behavior correctly, and I worry about them getting out of sync or needing to add this in even more places, like the VSCode extension or the JetBrains plugin.

@@ -2274,6 +2275,19 @@ class ApiMethods {
throw new MissingBuildParameters(missingParameters, activeVersionId);
}

// Stop the workspace if it is already running.
Copy link
Member

Choose a reason for hiding this comment

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

hmm. I'm a bit worried about adding this directly inside the API method. most everything in here is 1:1 with a backend endpoint, occasionally with minimal logic to convert from an options object to a query string or whatever. but this is actual application logic leaking in here.

@johnstcn
Copy link
Member Author

I'm wondering if this should be handled by the backend rather than the clients? The CLI and the frontend are now both responsible for producing this behavior correctly, and I worry about them getting out of sync or needing to add this in even more places, like the VSCode extension or the JetBrains plugin.

Yeah, that's a valid concern. The main difficulty there is that there's no 'restart' transition in our current workspace transition model. Ideally we would have something like a 'restart' type provisioner job that would handle both the stop and start stages (or maybe perform a stop and enqueue a start build upon completion). I'd like us to do that eventually as it would greatly simplify the whole implementation here and let us model both restart and update as the same kind of state transition.

Would you be OK with making this a follow-up item in the interest of expediency?

@dannykopping
Copy link
Contributor

I'm wondering if this should be handled by the backend rather than the clients? The CLI and the frontend are now both responsible for producing this behavior correctly, and I worry about them getting out of sync or needing to add this in even more places, like the VSCode extension or the JetBrains plugin.

Yeah, that's a valid concern. The main difficulty there is that there's no 'restart' transition in our current workspace transition model. Ideally we would have something like a 'restart' type provisioner job that would handle both the stop and start stages (or maybe perform a stop and enqueue a start build upon completion). I'd like us to do that eventually as it would greatly simplify the whole implementation here and let us model both restart and update as the same kind of state transition.

Would you be OK with making this a follow-up item in the interest of expediency?

#14857

I vote for later, but soon™️

@aslilac
Copy link
Member

aslilac commented Jun 22, 2025

yeah, that sounds like a good follow up solution 👍

@johnstcn johnstcn merged commit 49fcffc into main Jun 23, 2025
39 of 41 checks passed
@johnstcn johnstcn deleted the cj/prebuild-template-upgrade branch June 23, 2025 08:12
@github-actions github-actions bot locked and limited conversation to collaborators Jun 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release/breaking This label is applied to PRs to detect breaking changes as part of the release process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: template upgrade fails on claimed prebuilt workspace
3 participants