Skip to content

Commit 1c7792d

Browse files
authored
fix(smus): Add status validation for space operations (#8160)
## Description Added status checks for SageMaker space operations to prevent invalid actions. Picture: When opening remote connection: <img width="507" height="302" alt="Screenshot 2025-10-08 at 4 20 19 PM" src="https://github.com/user-attachments/assets/905cb51e-daf0-4db5-91ca-fbbc53de28d5" /> ## fix done 1. The stopSpace function now validates space status before attempting to stop, showing appropriate warning messages for spaces already in Stopped/Stopping states or currently Starting. 2. Also added status refresh before open remote connect ## Testing Done code debug --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent b654eb3 commit 1c7792d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/core/src/awsService/sagemaker/commands.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ export async function stopSpace(
133133
ctx: vscode.ExtensionContext,
134134
sageMakerClient?: SagemakerClient
135135
) {
136+
await tryRefreshNode(node)
137+
if (node.getStatus() === 'Stopped' || node.getStatus() === 'Stopping') {
138+
void vscode.window.showWarningMessage(`Space ${node.spaceApp.SpaceName} is already in Stopped/Stopping state.`)
139+
return
140+
} else if (node.getStatus() === 'Starting') {
141+
void vscode.window.showWarningMessage(
142+
`Space ${node.spaceApp.SpaceName} is in Starting state. Wait until it is Running to attempt stop again.`
143+
)
144+
return
145+
}
136146
const spaceName = node.spaceApp.SpaceName!
137147
const confirmed = await showConfirmationMessage({
138148
prompt: `You are about to stop this space. Any active resource will also be stopped. Are you sure you want to stop the space?`,
@@ -179,7 +189,7 @@ export async function openRemoteConnect(
179189
void vscode.window.showErrorMessage(ConnectFromRemoteWorkspaceMessage)
180190
return
181191
}
182-
192+
await tryRefreshNode(node)
183193
if (node.getStatus() === 'Stopped') {
184194
// In case of SMUS, we pass in a SM Client and for SM AI, it creates a new SM Client.
185195
const client = sageMakerClient ? sageMakerClient : new SagemakerClient(node.regionCode)

0 commit comments

Comments
 (0)