- Notifications
You must be signed in to change notification settings - Fork1.2k
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
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
9443453594d1d7873794ff73b3f68a48d85123b51f3d6106ff25c3339bf51418dd13d3be0c1761c703cada8bd12ed6399a0cf0110d4529c8cc236abFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 ( | ||
| @@ -2274,6 +2275,19 @@ class ApiMethods { | ||
| throw new MissingBuildParameters(missingParameters, activeVersionId); | ||
| } | ||
| // Stop the workspace if it is already running. | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. hmm. I'm a bit worried about adding this directly inside the | ||
| 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, | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -21,19 +21,39 @@ export interface ActionButtonProps { | ||
| tooltipText?: string; | ||
| } | ||
| export constUpdateAndStartButton: FC<ActionButtonProps> = ({ | ||
johnstcn marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| handleAction, | ||
| loading, | ||
| }) => { | ||
| return ( | ||
| <Tooltip title="Start workspace with the latest template version."> | ||
| <TopbarButton | ||
| disabled={loading} | ||
| data-testid="workspace-update-button" | ||
| onClick={() => handleAction()} | ||
| > | ||
| <CirclePlayIcon /> | ||
| {loading ? <>Updating…</> : <>Update…</>} | ||
| </TopbarButton> | ||
| </Tooltip> | ||
| ); | ||
| }; | ||
| export const UpdateAndRestartButton: FC<ActionButtonProps> = ({ | ||
| handleAction, | ||
| loading, | ||
| }) => { | ||
| return ( | ||
| <Tooltip title="Stop workspace, if running, and restart it with the latest template version."> | ||
johnstcn marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| <TopbarButton | ||
| disabled={loading} | ||
| data-testid="workspace-update-and-restart-button" | ||
| onClick={() => handleAction()} | ||
| > | ||
| <RotateCcwIcon /> | ||
| {loading ? <>Updating…</> : <>Update and restart…</>} | ||
| </TopbarButton> | ||
| </Tooltip> | ||
| ); | ||
| }; | ||
| @@ -84,9 +104,9 @@ export const StartButton: FC<ActionButtonPropsWithWorkspace> = ({ | ||
| ); | ||
| }; | ||
| export constUpdateAndStartButtonRequireActiveVersion: FC< | ||
johnstcn marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| 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()}> | ||
| @@ -138,9 +158,9 @@ export const RestartButton: FC<ActionButtonPropsWithWorkspace> = ({ | ||
| ); | ||
| }; | ||
| 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()}> | ||