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

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
johnstcn merged 17 commits intomainfromcj/prebuild-template-upgrade
Jun 23, 2025
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
17 commits
Select commitHold shift + click to select a range
9443453
chore: TestUpdate: remove extraneous cli invocation
johnstcnJun 17, 2025
594d1d7
assert previous build state when updating workspace
johnstcnJun 17, 2025
873794f
chore: coderdtest: change argument types to remove unnecessary conver…
johnstcnJun 17, 2025
f73b3f6
cli: stop before starting on update
johnstcnJun 17, 2025
8a48d85
chore: refactor and extract stopWorkspace function
johnstcnJun 18, 2025
123b51f
update cli usage doc
johnstcnJun 18, 2025
3d6106f
confirm before stop
johnstcnJun 18, 2025
f25c333
Revert "confirm before stop"
johnstcnJun 18, 2025
9bf5141
ui: make update button stop before start
johnstcnJun 18, 2025
8dd13d3
make fmt
johnstcnJun 18, 2025
be0c176
site: fix some tests
johnstcnJun 18, 2025
1c703ca
fixup! site: fix some tests
johnstcnJun 18, 2025
da8bd12
reduce button explosion
johnstcnJun 19, 2025
ed6399a
adjust icons
johnstcnJun 19, 2025
0cf0110
add testid to bulk update button and fix bulk update tests
johnstcnJun 19, 2025
d4529c8
fix e2e race
johnstcnJun 20, 2025
cc236ab
Merge branch 'main' into cj/prebuild-template-upgrade
johnstcnJun 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
ui: make update button stop before start
  • Loading branch information
@johnstcn
johnstcn committedJun 19, 2025
commit9bf51410ef30af3766687907f7f86f3810a671f9
14 changes: 14 additions & 0 deletionssite/src/api/api.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2237,6 +2237,7 @@ class ApiMethods {
* - Update the build parameters and check if there are missed parameters for
* the newest version
* - If there are missing parameters raise an error
* - Stop the workspace with the current template version if it is already running
* - Create a build with the latest version and updated build parameters
*/
updateWorkspace = async (
Expand DownExpand Up@@ -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 theAPI 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.

if (workspace.latest_build.status === "running") {
const stopBuild = await this.stopWorkspace(workspace.id);
const awaitedStopBuild = await this.waitForBuild(stopBuild);
// If the stop is canceled halfway through, we bail.
// This is the same behaviour as restartWorkspace.
if (awaitedStopBuild?.status === "canceled") {
return Promise.reject(
new Error("Workspace stop was canceled, not proceeding with update."),
);
}
}

return this.postWorkspaceBuild(workspace.id, {
transition: "start",
template_version_id: activeVersionId,
Expand Down
19 changes: 11 additions & 8 deletionssite/src/modules/workspaces/actions.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,16 +6,19 @@ import type { Workspace } from "api/typesGenerated";
const actionTypes = [
"start",
"starting",
// Replaces start when an update isrequired.
// Replaces start when an update isavailable.
"updateAndStart",
// Replaces start when an update is required.
"updateAndStartRequireActiveVersion",
"stop",
"stopping",
"restart",
"restarting",
// Replaces restart when an update isrequired.
// Replaces restart when an update isavailable.
"updateAndRestart",
// Replaces restart when an update is required.
"updateAndRestartRequireActiveVersion",
"deleting",
"update",
"updating",
"activate",
"activating",
Expand DownExpand Up@@ -74,10 +77,10 @@ export const abilitiesByWorkspaceStatus = (
const actions: ActionType[] = ["stop"];

if (workspace.template_require_active_version && workspace.outdated) {
actions.push("updateAndRestart");
actions.push("updateAndRestartRequireActiveVersion");
} else {
if (workspace.outdated) {
actions.unshift("update");
actions.unshift("updateAndRestart");
}
actions.push("restart");
}
Expand All@@ -99,10 +102,10 @@ export const abilitiesByWorkspaceStatus = (
const actions: ActionType[] = [];

if (workspace.template_require_active_version && workspace.outdated) {
actions.push("updateAndStart");
actions.push("updateAndStartRequireActiveVersion");
} else {
if (workspace.outdated) {
actions.unshift("update");
actions.unshift("updateAndStart");
}
actions.push("start");
}
Expand All@@ -128,7 +131,7 @@ export const abilitiesByWorkspaceStatus = (
}

if (workspace.outdated) {
actions.unshift("update");
actions.unshift("updateAndStart");
}

return {
Expand Down
50 changes: 35 additions & 15 deletionssite/src/pages/WorkspacePage/WorkspaceActions/Buttons.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,19 +21,39 @@ export interface ActionButtonProps {
tooltipText?: string;
}

export constUpdateButton: FC<ActionButtonProps> = ({
export constUpdateAndStartButton: FC<ActionButtonProps> = ({
handleAction,
loading,
}) => {
return (
<TopbarButton
disabled={loading}
data-testid="workspace-update-button"
onClick={() => handleAction()}
>
<CloudIcon />
{loading ? <>Updating&hellip;</> : <>Update&hellip;</>}
</TopbarButton>
<Tooltip title="Start workspace with the latest template version.">
<TopbarButton
disabled={loading}
data-testid="workspace-update-button"
onClick={() => handleAction()}
>
<CirclePlayIcon />
{loading ? <>Updating&hellip;</> : <>Update&hellip;</>}
</TopbarButton>
</Tooltip>
);
};

export const UpdateAndRestartButton: FC<ActionButtonProps> = ({
handleAction,
loading,
}) => {
return (
<Tooltip title="Stop workspace, if running, and restart it with the latest template version.">
<TopbarButton
disabled={loading}
data-testid="workspace-update-and-restart-button"
onClick={() => handleAction()}
>
<RotateCcwIcon />
{loading ? <>Updating&hellip;</> : <>Update and restart&hellip;</>}
</TopbarButton>
</Tooltip>
);
};

Expand DownExpand Up@@ -84,9 +104,9 @@ export const StartButton: FC<ActionButtonPropsWithWorkspace> = ({
);
};

export constUpdateAndStartButton: FC<ActionButtonProps> = ({
handleAction,
}) => {
export constUpdateAndStartButtonRequireActiveVersion: FC<
ActionButtonProps
> = ({ handleAction}) => {
return (
<Tooltip title="This template requires automatic updates on workspace startup. Contact your administrator if you want to preserve the template version.">
<TopbarButton onClick={() => handleAction()}>
Expand DownExpand Up@@ -138,9 +158,9 @@ export const RestartButton: FC<ActionButtonPropsWithWorkspace> = ({
);
};

export constUpdateAndRestartButton: FC<ActionButtonProps> = ({
handleAction,
}) => {
export constUpdateAndRestartButtonRequireActiveVersion: FC<
ActionButtonProps
> = ({ handleAction}) => {
return (
<Tooltip title="This template requires automatic updates on workspace startup. Contact your administrator if you want to preserve the template version.">
<TopbarButton onClick={() => handleAction()}>
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,9 +18,10 @@ import {
RestartButton,
StartButton,
StopButton,
UpdateAndRestartButtonRequireActiveVersion,
UpdateAndRestartButton,
UpdateAndStartButtonRequireActiveVersion,
UpdateAndStartButton,
UpdateButton,
} from "./Buttons";
import { DebugButton } from "./DebugButton";
import { RetryButton } from "./RetryButton";
Expand DownExpand Up@@ -81,10 +82,15 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({

// A mapping of button type to the corresponding React component
const buttonMapping: Record<ActionType, ReactNode> = {
update: <UpdateButton handleAction={handleUpdate} />,
updateAndStart: <UpdateAndStartButton handleAction={handleUpdate} />,
updateAndStartRequireActiveVersion: (
<UpdateAndStartButtonRequireActiveVersion handleAction={handleUpdate} />
),
updateAndRestart: <UpdateAndRestartButton handleAction={handleUpdate} />,
updating: <UpdateButton loading handleAction={handleUpdate} />,
updateAndRestartRequireActiveVersion: (
<UpdateAndRestartButtonRequireActiveVersion handleAction={handleUpdate} />
),
updating: <UpdateAndStartButton loading handleAction={handleUpdate} />,
start: (
<StartButton
workspace={workspace}
Expand Down

[8]ページ先頭

©2009-2026 Movatter.jp