Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions patches/sagemaker.series
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ web-server/embedding-events.diff
web-server/proxy-uri.diff
web-server/display-language.diff
web-server/signature-verification.diff
sagemaker/update-csp.diff
sagemaker/sagemaker-extension.diff
sagemaker/update-csp.diff
sagemaker/sagemaker-integration.diff
sagemaker/base-path-compatibility.diff
sagemaker/sagemaker-idle-extension.diff
sagemaker/terminal-crash-mitigation.diff
sagemaker/sagemaker-open-notebook-extension.diff
sagemaker/sagemaker-ui-dark-theme.diff
sagemaker/sagemaker-ui-post-startup.diff
sagemaker/sagemaker-extension-smus-support.diff
sagemaker/post-startup-notifications.diff
sagemaker/sagemaker-extensions-sync.diff
sagemaker/sagemaker-ui-post-startup.diff
sagemaker/sagemaker-integration.diff
sagemaker/sagemaker-idle-extension.diff
sagemaker/base-path-compatibility.diff
62 changes: 29 additions & 33 deletions patches/sagemaker/sagemaker-idle-extension.diff
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ Index: third-party-src/build/gulpfile.extensions.js
'extensions/simple-browser/tsconfig.json',
'extensions/sagemaker-extension/tsconfig.json',
+ 'extensions/sagemaker-idle-extension/tsconfig.json',
'extensions/sagemaker-terminal-crash-mitigation/tsconfig.json',
'extensions/sagemaker-extensions-sync/tsconfig.json',
'extensions/sagemaker-open-notebook-extension/tsconfig.json',
'extensions/tunnel-forwarding/tsconfig.json',
'extensions/typescript-language-features/test-workspace/tsconfig.json',
'extensions/typescript-language-features/web/tsconfig.json',
Index: third-party-src/build/npm/dirs.js
===================================================================
--- third-party-src.orig/build/npm/dirs.js
Expand All @@ -272,71 +272,67 @@ Index: third-party-src/build/npm/dirs.js
'extensions/references-view',
'extensions/sagemaker-extension',
+ 'extensions/sagemaker-idle-extension',
'extensions/sagemaker-terminal-crash-mitigation',
'extensions/sagemaker-extensions-sync',
'extensions/sagemaker-open-notebook-extension',
'extensions/search-result',
'extensions/simple-browser',
'extensions/tunnel-forwarding',
Index: third-party-src/src/vs/server/node/webClientServer.ts
===================================================================
--- third-party-src.orig/src/vs/server/node/webClientServer.ts
+++ third-party-src/src/vs/server/node/webClientServer.ts
@@ -3,7 +3,9 @@
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

-import { createReadStream, promises } from 'fs';
+import { createReadStream, existsSync, writeFileSync, promises } from 'fs';
+import {readFile } from 'fs/promises';
+import * as path from 'path';
import { spawn } from 'child_process';
import * as fs from 'fs';
+import { createReadStream, promises, existsSync, writeFileSync } from 'fs';
import * as http from 'http';
@@ -103,6 +104,7 @@
import * as url from 'url';
import * as cookie from 'cookie';
@@ -96,6 +96,7 @@ const APP_ROOT = dirname(FileAccess.asFi
const STATIC_PATH = `/static`;
const CALLBACK_PATH = `/callback`;
const WEB_EXTENSION_PATH = `/web-extension-resource`;
const POST_STARTUP_SCRIPT_ROUTE = `/api/poststartup`;
+const IDLE_ROUTE = `/api/idle`;
+const IDLE_EXTENSION_PATH = `/api/idle`;

export class WebClientServer {

@@ -147,6 +149,9 @@ export class WebClientServer {
if (pathname === POST_STARTUP_SCRIPT_ROUTE) {
return this._handlePostStartupScriptInvocation(req, res);
@@ -133,6 +134,9 @@ export class WebClientServer {
// callback support
return this._handleCallback(res);
}
+ if (pathname === IDLE_ROUTE) {
+ if (pathname === IDLE_EXTENSION_PATH) {
+ return this._handleIdle(req, res);
+ }

return serveError(req, res, 404, 'Not found.');
} catch (error) {
@@ -515,6 +520,31 @@ export class WebClientServer {
if (pathname.startsWith(WEB_EXTENSION_PATH) && pathname.charCodeAt(WEB_EXTENSION_PATH.length) === CharCode.Slash) {
// extension resource support
return this._handleWebExtensionResource(req, res, pathname.substring(WEB_EXTENSION_PATH.length));
@@ -505,6 +509,31 @@ export class WebClientServer {
});
return void res.end(data);
}
+
+ /**
+ * Handles API requests to retrieve the last activity timestamp.
+ */
+ private async _handleIdle(req: http.IncomingMessage, res: http.ServerResponse): Promise<void> {
+ * Handles API requests to retrieve the last activity timestamp.
+ */
+ private async _handleIdle(req: http.IncomingMessage, res: http.ServerResponse): Promise<void> {
+ try {
+ const tmpDirectory = '/tmp/'
+ const idleFilePath = path.join(tmpDirectory, '.sagemaker-last-active-timestamp');
+
+ const idleFilePath = join(tmpDirectory, '.sagemaker-last-active-timestamp');
+
+ // If idle shutdown file does not exist, this indicates the app UI may never been opened
+ // Create the initial metadata file
+ if (!existsSync(idleFilePath)) {
+ const timestamp = new Date().toISOString();
+ writeFileSync(idleFilePath, timestamp);
+ }
+
+
+ const data = await promises.readFile(idleFilePath, 'utf8');
+
+
+ res.statusCode = 200;
+ res.setHeader('Content-Type', 'application/json');
+ res.end(JSON.stringify({ lastActiveTimestamp: data }));
+ } catch (error) {
+ serveError(req, res, 500, error.message)
+ }
+ }

/**
* Handles API requests to run the post-startup script in SMD.
}
19 changes: 10 additions & 9 deletions patches/sagemaker/sagemaker-ui-dark-theme.diff
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,19 @@ Index: third-party-src/.vscode-test.js
===================================================================
--- third-party-src.orig/.vscode-test.js
+++ third-party-src/.vscode-test.js
@@ -79,6 +79,11 @@ const extensions = [
workspaceFolder: `extensions/vscode-api-tests/testworkspace.code-workspace`,
mocha: { timeout: 60_000 },
files: 'extensions/vscode-api-tests/out/workspace-tests/**/*.test.js',
+ },
+ {
@@ -63,6 +63,11 @@ const extensions = [
mocha: { timeout: 60_000 }
},
{
+ label: 'sagemaker-ui-dark-theme',
+ workspaceFolder: `extensions/sagemaker-ui-dark-theme/test-workspace`,
+ mocha: { timeout: 60_000 }
}
];

+ },
+ {
label: 'microsoft-authentication',
mocha: { timeout: 60_000 }
},

Index: third-party-src/extensions/sagemaker-ui-dark-theme/src/test/extension.test.ts
===================================================================
--- /dev/null
Expand Down
80 changes: 39 additions & 41 deletions patches/sagemaker/sagemaker-ui-post-startup.diff
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ Index: third-party-src/src/vs/server/node/webClientServer.ts
===================================================================
--- third-party-src.orig/src/vs/server/node/webClientServer.ts
+++ third-party-src/src/vs/server/node/webClientServer.ts
@@ -4,6 +4,8 @@
*--------------------------------------------------------------------------------------------*/
@@ -5,6 +5,8 @@

import { createReadStream, promises } from 'fs';
import { createReadStream, promises, existsSync, writeFileSync } from 'fs';
import * as http from 'http';
+import { spawn } from 'child_process';
+import * as fs from 'fs';
import * as http from 'http';
import * as url from 'url';
import * as cookie from 'cookie';
import * as crypto from 'crypto';
@@ -38,6 +40,10 @@ const textMimeType: { [ext: string]: str
'.svg': 'image/svg+xml',
};
Expand All @@ -22,55 +22,55 @@ Index: third-party-src/src/vs/server/node/webClientServer.ts
/**
* Return an error to the client.
*/
@@ -96,6 +102,7 @@
const STATIC_PATH = `/static`;
@@ -97,6 +103,7 @@ const STATIC_PATH = `/static`;
const CALLBACK_PATH = `/callback`;
const WEB_EXTENSION_PATH = `/web-extension-resource`;
+const POST_STARTUP_SCRIPT_ROUTE = `/api/poststartup`;
const IDLE_EXTENSION_PATH = `/api/idle`;
+const POST_STARTUP_SCRIPT_PATH = `/api/poststartup`;

export class WebClientServer {

@@ -137,6 +144,9 @@ export class WebClientServer {
// extension resource support
return this._handleWebExtensionResource(req, res, pathname.substring(WEB_EXTENSION_PATH.length));
if (pathname === IDLE_EXTENSION_PATH) {
return this._handleIdle(req, res);
}
+ if (pathname === POST_STARTUP_SCRIPT_ROUTE) {
+ if (pathname === POST_STARTUP_SCRIPT_PATH) {
+ return this._handlePostStartupScriptInvocation(req, res);
+ }

return serveError(req, res, 404, 'Not found.');
} catch (error) {
@@ -505,6 +515,41 @@ export class WebClientServer {
});
return void res.end(data);
if (pathname.startsWith(WEB_EXTENSION_PATH) && pathname.charCodeAt(WEB_EXTENSION_PATH.length) === CharCode.Slash) {
// extension resource support
return this._handleWebExtensionResource(req, res, pathname.substring(WEB_EXTENSION_PATH.length));
@@ -534,6 +544,41 @@ export class WebClientServer {
serveError(req, res, 500, error.message)
}
}
+
+ /**
+ * Handles API requests to run the post-startup script in SMD.
+ */
+ private async _handlePostStartupScriptInvocation(req: http.IncomingMessage, res: http.ServerResponse): Promise<void> {
+ const postStartupScriptPath = '/etc/sagemaker-ui/sagemaker_ui_post_startup.sh'
+ const logPath = '/var/log/apps/post_startup_default.log';
+ const logStream = fs.createWriteStream(logPath, { flags: 'a' });
+ /**
+ * Handles API requests to run the post-startup script in SMD.
+ */
+ private async _handlePostStartupScriptInvocation(req: http.IncomingMessage, res: http.ServerResponse): Promise<void> {
+ const postStartupScriptPath = '/etc/sagemaker-ui/sagemaker_ui_post_startup.sh'
+ const logPath = '/var/log/apps/post_startup_default.log';
+ const logStream = fs.createWriteStream(logPath, { flags: 'a' });
+
+ // Only trigger post-startup script invocation for SageMakerUnifiedStudio app.
+ if (process.env['SERVICE_NAME'] != ServiceName.SAGEMAKER_UNIFIED_STUDIO) {
+ return serveError(req, res, 403, 'Forbidden');
+ } else {
+ //If postStartupScriptFile doesn't exist, it will throw FileNotFoundError (404)
+ //If exists, it will start the execution and add the execution logs in logFile.
+ try {
+ if (fs.existsSync(postStartupScriptPath)) {
+ // Adding 0o755 to make script file executable
+ fs.chmodSync(postStartupScriptPath, 0o755);
+ // Only trigger post-startup script invocation for SageMakerUnifiedStudio app.
+ if (process.env['SERVICE_NAME'] != ServiceName.SAGEMAKER_UNIFIED_STUDIO) {
+ return serveError(req, res, 403, 'Forbidden');
+ } else {
+ //If postStartupScriptFile doesn't exist, it will throw FileNotFoundError (404)
+ //If exists, it will start the execution and add the execution logs in logFile.
+ try {
+ if (fs.existsSync(postStartupScriptPath)) {
+ // Adding 0o755 to make script file executable
+ fs.chmodSync(postStartupScriptPath, 0o755);
+
+ const subprocess = spawn('bash', [`${postStartupScriptPath}`], { cwd: '/' });
+ subprocess.stdout.pipe(logStream);
+ subprocess.stderr.pipe(logStream);
+ const subprocess = spawn('bash', [`${postStartupScriptPath}`], { cwd: '/' });
+ subprocess.stdout.pipe(logStream);
+ subprocess.stderr.pipe(logStream);
+
+ res.statusCode = 200;
+ res.setHeader('Content-Type', 'application/json');
+ res.end(JSON.stringify({ 'success': 'true' }));
+ res.statusCode = 200;
+ res.setHeader('Content-Type', 'application/json');
+ res.end(JSON.stringify({ 'success': 'true' }));
+ } else {
+ serveError(req, res, 500, 'Poststartup script file not found at ' + postStartupScriptPath);
+ }
Expand All @@ -80,5 +80,3 @@ Index: third-party-src/src/vs/server/node/webClientServer.ts
+ }
+ }
}


28 changes: 14 additions & 14 deletions patches/sagemaker/terminal-crash-mitigation.diff
Original file line number Diff line number Diff line change
Expand Up @@ -240,27 +240,27 @@ Index: third-party-src/extensions/sagemaker-terminal-crash-mitigation/tsconfig.j
+ "../../src/vscode-dts/vscode.d.ts"
+ ]
+}
Index: third-party-src/build/npm/dirs.js
===================================================================
--- third-party-src.orig/build/npm/dirs.js
+++ third-party-src/build/npm/dirs.js
@@ -43,6 +43,7 @@ const dirs = [
'extensions/php-language-features',
'extensions/references-view',
'extensions/sagemaker-extension',
+ 'extensions/sagemaker-terminal-crash-mitigation',
'extensions/search-result',
'extensions/simple-browser',
'extensions/tunnel-forwarding',
Index: third-party-src/build/gulpfile.extensions.js
===================================================================
--- third-party-src.orig/build/gulpfile.extensions.js
+++ third-party-src/build/gulpfile.extensions.js
@@ -65,6 +65,7 @@ const compilations = [
'extensions/search-result/tsconfig.json',
@@ -62,6 +62,7 @@ const compilations = [
'extensions/simple-browser/tsconfig.json',
'extensions/sagemaker-extension/tsconfig.json',
'extensions/sagemaker-idle-extension/tsconfig.json',
+ 'extensions/sagemaker-terminal-crash-mitigation/tsconfig.json',
'extensions/tunnel-forwarding/tsconfig.json',
'extensions/typescript-language-features/test-workspace/tsconfig.json',
'extensions/typescript-language-features/web/tsconfig.json',
Index: third-party-src/build/npm/dirs.js
===================================================================
--- third-party-src.orig/build/npm/dirs.js
+++ third-party-src/build/npm/dirs.js
@@ -40,6 +40,7 @@ const dirs = [
'extensions/references-view',
'extensions/sagemaker-extension',
'extensions/sagemaker-idle-extension',
+ 'extensions/sagemaker-terminal-crash-mitigation',
'extensions/search-result',
'extensions/simple-browser',
'extensions/tunnel-forwarding',
2 changes: 1 addition & 1 deletion patches/sagemaker/update-csp.diff
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
Index: third-party-src/src/vs/server/node/webClientServer.ts
===================================================================
--- third-party-src.orig/src/vs/server/node/webClientServer.ts
+++ third-party-src/src/vs/server/node/webClientServer.ts
Expand Down