Skip to content

Commit ce6937d

Browse files
Merge master into feature/LSP-gamma
2 parents 45eb30e + 6081f89 commit ce6937d

File tree

8 files changed

+32
-36
lines changed

8 files changed

+32
-36
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Support chat in AL2 aarch64"
4+
}

packages/amazonq/src/extension.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
maybeShowMinVscodeWarning,
3434
Experiments,
3535
isSageMaker,
36-
isAmazonInternalOs,
36+
isAmazonLinux2,
3737
} from 'aws-core-vscode/shared'
3838
import { ExtStartUpSources } from 'aws-core-vscode/telemetry'
3939
import { VSCODE_EXTENSION_ID } from 'aws-core-vscode/utils'
@@ -123,7 +123,7 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
123123
await activateCodeWhisperer(extContext as ExtContext)
124124
if (
125125
(Experiments.instance.get('amazonqLSP', true) || Auth.instance.isInternalAmazonUser()) &&
126-
(!isAmazonInternalOs() || (await hasGlibcPatch()))
126+
(!isAmazonLinux2() || hasGlibcPatch())
127127
) {
128128
// start the Amazon Q LSP for internal users first
129129
// for AL2, start LSP if glibc patch is found

packages/amazonq/src/lsp/client.ts

+8-11
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ import {
3131
getLogger,
3232
undefinedIfEmpty,
3333
getOptOutPreference,
34-
isAmazonInternalOs,
35-
fs,
34+
isAmazonLinux2,
3635
getClientId,
3736
extensionVersion,
3837
} from 'aws-core-vscode/shared'
@@ -45,8 +44,11 @@ import { telemetry } from 'aws-core-vscode/telemetry'
4544
const localize = nls.loadMessageBundle()
4645
const logger = getLogger('amazonqLsp.lspClient')
4746

48-
export async function hasGlibcPatch(): Promise<boolean> {
49-
return await fs.exists('/opt/vsc-sysroot/lib64/ld-linux-x86-64.so.2')
47+
export const glibcLinker: string = process.env.VSCODE_SERVER_CUSTOM_GLIBC_LINKER || ''
48+
export const glibcPath: string = process.env.VSCODE_SERVER_CUSTOM_GLIBC_PATH || ''
49+
50+
export function hasGlibcPatch(): boolean {
51+
return glibcLinker.length > 0 && glibcPath.length > 0
5052
}
5153

5254
export async function startLanguageServer(
@@ -71,13 +73,8 @@ export async function startLanguageServer(
7173
const traceServerEnabled = Settings.instance.isSet(`${clientId}.trace.server`)
7274
let executable: string[] = []
7375
// apply the GLIBC 2.28 path to node js runtime binary
74-
if (isAmazonInternalOs() && (await hasGlibcPatch())) {
75-
executable = [
76-
'/opt/vsc-sysroot/lib64/ld-linux-x86-64.so.2',
77-
'--library-path',
78-
'/opt/vsc-sysroot/lib64',
79-
resourcePaths.node,
80-
]
76+
if (isAmazonLinux2() && hasGlibcPatch()) {
77+
executable = [glibcLinker, '--library-path', glibcPath, resourcePaths.node]
8178
getLogger('amazonqLsp').info(`Patched node runtime with GLIBC to ${executable}`)
8279
} else {
8380
executable = [resourcePaths.node]

packages/core/src/amazonq/lsp/lspController.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { activate as activateLsp, LspClient } from './lspClient'
1111
import { telemetry } from '../../shared/telemetry/telemetry'
1212
import { isCloud9 } from '../../shared/extensionUtilities'
1313
import globals, { isWeb } from '../../shared/extensionGlobals'
14-
import { isAmazonInternalOs } from '../../shared/vscode/env'
14+
import { isAmazonLinux2 } from '../../shared/vscode/env'
1515
import { WorkspaceLspInstaller } from './workspaceInstaller'
1616
import { lspSetupStage } from '../../shared/lsp/utils/setupStage'
1717
import { RelevantTextDocumentAddition } from '../../codewhispererChat/controllers/chat/model'
@@ -165,7 +165,7 @@ export class LspController {
165165
}
166166

167167
async trySetupLsp(context: vscode.ExtensionContext, buildIndexConfig: BuildIndexConfig) {
168-
if (isCloud9() || isWeb() || isAmazonInternalOs()) {
168+
if (isCloud9() || isWeb() || isAmazonLinux2()) {
169169
this.logger.warn('Skipping LSP setup. LSP is not compatible with the current environment. ')
170170
// do not do anything if in Cloud9 or Web mode or in AL2 (AL2 does not support node v18+)
171171
return

packages/core/src/shared/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export * from './extensionUtilities'
1818
export * from './extensionStartup'
1919
export { RegionProvider } from './regions/regionProvider'
2020
export { Commands } from './vscode/commands2'
21-
export { getMachineId, getServiceEnvVarConfig, isAmazonInternalOs } from './vscode/env'
21+
export { getMachineId, getServiceEnvVarConfig, isAmazonLinux2 } from './vscode/env'
2222
export { getLogger } from './logger/logger'
2323
export { activateExtension, openUrl } from './utilities/vsCodeUtils'
2424
export { waitUntil, sleep, Timeout } from './utilities/timeoutUtils'

packages/core/src/shared/telemetry/util.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
isAutomation,
1616
isRemoteWorkspace,
1717
isCloudDesktop,
18-
isAmazonInternalOs,
18+
isAmazonLinux2,
1919
} from '../vscode/env'
2020
import { addTypeName } from '../utilities/typeConstructors'
2121
import globals, { isWeb } from '../extensionGlobals'
@@ -290,7 +290,7 @@ export async function getComputeEnvType(): Promise<EnvType> {
290290
} else if (isSageMaker()) {
291291
return web ? 'sagemaker-web' : 'sagemaker'
292292
} else if (isRemoteWorkspace()) {
293-
if (isAmazonInternalOs()) {
293+
if (isAmazonLinux2()) {
294294
if (await isCloudDesktop()) {
295295
return 'cloudDesktop-amzn'
296296
}

packages/core/src/shared/vscode/env.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,21 @@ export function isRemoteWorkspace(): boolean {
125125
}
126126

127127
/**
128-
* There is Amazon Linux 2, but additionally an Amazon Linux 2 Internal.
129-
* The internal version is for Amazon employees only. And this version can
130-
* be used by either EC2 OR CloudDesktop. It is not exclusive to either.
128+
* There is Amazon Linux 2.
131129
*
132-
* Use {@link isCloudDesktop()} to know if we are specifically using it.
130+
* Use {@link isCloudDesktop()} to know if we are specifically using internal Amazon Linux 2.
133131
*
134-
* Example: `5.10.220-188.869.amzn2int.x86_64`
132+
* Example: `5.10.220-188.869.amzn2int.x86_64` or `5.10.236-227.928.amzn2.x86_64` (Cloud Dev Machine)
135133
*/
136-
export function isAmazonInternalOs() {
137-
return os.release().includes('amzn2int') && process.platform === 'linux'
134+
export function isAmazonLinux2() {
135+
return (os.release().includes('.amzn2int.') || os.release().includes('.amzn2.')) && process.platform === 'linux'
138136
}
139137

140138
/**
141139
* Returns true if we are in an internal Amazon Cloud Desktop
142140
*/
143141
export async function isCloudDesktop() {
144-
if (!isAmazonInternalOs()) {
142+
if (!isAmazonLinux2()) {
145143
return false
146144
}
147145

packages/core/src/test/shared/vscode/env.test.ts

+7-10
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@
55

66
import assert from 'assert'
77
import path from 'path'
8-
import {
9-
isCloudDesktop,
10-
getEnvVars,
11-
getServiceEnvVarConfig,
12-
isAmazonInternalOs as isAmazonInternalOS,
13-
isBeta,
14-
} from '../../../shared/vscode/env'
8+
import { isCloudDesktop, getEnvVars, getServiceEnvVarConfig, isAmazonLinux2, isBeta } from '../../../shared/vscode/env'
159
import { ChildProcess } from '../../../shared/utilities/processUtils'
1610
import * as sinon from 'sinon'
1711
import os from 'os'
@@ -103,13 +97,16 @@ describe('env', function () {
10397
assert.strictEqual(isBeta(), expected)
10498
})
10599

106-
it('isAmazonInternalOS', function () {
100+
it('isAmazonLinux2', function () {
107101
sandbox.stub(process, 'platform').value('linux')
108102
const versionStub = stubOsVersion('5.10.220-188.869.amzn2int.x86_64')
109-
assert.strictEqual(isAmazonInternalOS(), true)
103+
assert.strictEqual(isAmazonLinux2(), true)
104+
105+
versionStub.returns('5.10.236-227.928.amzn2.x86_64')
106+
assert.strictEqual(isAmazonLinux2(), true)
110107

111108
versionStub.returns('5.10.220-188.869.NOT_INTERNAL.x86_64')
112-
assert.strictEqual(isAmazonInternalOS(), false)
109+
assert.strictEqual(isAmazonLinux2(), false)
113110
})
114111

115112
it('isCloudDesktop', async function () {

0 commit comments

Comments
 (0)