Skip to content

Commit d8852bd

Browse files
ilia-dbkartikgupta-dbgithub-actions[bot]web-floweng-dev-ecosystem-bot
authored
Bundle integ merge main (#1009)
Merge main into build-integ --------- Co-authored-by: Kartik Gupta <88345179+kartikgupta-db@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: releasebot <noreply@github.com> Co-authored-by: kartikgupta-db <kartik.gupta@databricks.com> Co-authored-by: eng-dev-ecosystem-bot <eng-dev-ecosystem-bot@users.noreply.github.com> Co-authored-by: eng-dev-ecosystem-bot <110475461+eng-dev-ecosystem-bot@users.noreply.github.com> Co-authored-by: Serge Smertin <259697+nfx@users.noreply.github.com>
1 parent 125a2ec commit d8852bd

File tree

9 files changed

+98
-98
lines changed

9 files changed

+98
-98
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@databricks/databricks-vscode",
3-
"version": "1.2.4",
3+
"version": "1.2.5",
44
"private": true,
55
"workspaces": [
66
"packages/*"

packages/databricks-vscode-types/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Release: v1.2.5
2+
3+
## packages/databricks-vscode-types
4+
5+
## <small>1.2.5 (2024-01-10)</small>
6+
7+
- Update the license (#981) ([66cf3c3](https://github.com/databricks/databricks-vscode/commit/66cf3c3)), closes [#981](https://github.com/databricks/databricks-vscode/issues/981)
8+
19
# Release: v1.2.4
210

311
## packages/databricks-vscode-types

packages/databricks-vscode-types/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@databricks/databricks-vscode-types",
3-
"version": "1.2.4",
3+
"version": "1.2.5",
44
"description": "Package with types and interfaces to develop extensions to the Databricks VSCode plugin",
55
"main": "index.js",
66
"types": "index.d.ts",

packages/databricks-vscode/CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Release: v1.2.5
2+
3+
## packages/databricks-vscode
4+
5+
## <small>1.2.5 (2024-01-10)</small>
6+
7+
- Explicitly clear terminal environment variables before injecting new ones.
8+
- Fix race conditions around setting environment variable for the metadata url.
9+
- Show warning when the extension doesn't have permissions to execute the CLI.
10+
- Store `lastInstalledExtensionVersion` in the global storage so we only show `what's new` once.
11+
- Update the license.
12+
- Update Databricks CLI to v0.211.0.
13+
- Fix the telemetry.
14+
115
# Release: v1.2.4
216

317
## packages/databricks-vscode

packages/databricks-vscode/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "IDE support for Databricks",
55
"publisher": "databricks",
66
"license": "LicenseRef-LICENSE",
7-
"version": "1.2.4",
7+
"version": "1.2.5",
88
"engines": {
99
"vscode": "^1.83.0"
1010
},
@@ -677,7 +677,7 @@
677677
"useYarn": false
678678
},
679679
"cli": {
680-
"version": "0.210.3"
680+
"version": "0.212.0"
681681
},
682682
"scripts": {
683683
"vscode:prepublish": "rm -rf out && yarn run package:compile && yarn run package:wrappers:write && yarn run package:jupyter-init-script:write && yarn run package:copy-webview-toolkit && yarn run generate-telemetry",

packages/databricks-vscode/src/configuration/ConnectionManager.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {ConfigModel} from "./models/ConfigModel";
1515
import {onError} from "../utils/onErrorDecorator";
1616
import {AuthProvider, ProfileAuthProvider} from "./auth/AuthProvider";
1717
import {Mutex} from "../locking";
18+
import {MetadataService} from "./auth/MetadataService";
1819

1920
// eslint-disable-next-line @typescript-eslint/naming-convention
2021
const {NamedLogger} = logging;
@@ -35,6 +36,7 @@ export class ConnectionManager implements Disposable {
3536
private _syncDestinationMapper?: SyncDestinationMapper;
3637
private _clusterManager?: ClusterManager;
3738
private _databricksWorkspace?: DatabricksWorkspace;
39+
private _metadataService: MetadataService;
3840

3941
private readonly onDidChangeStateEmitter: EventEmitter<ConnectionState> =
4042
new EventEmitter();
@@ -50,7 +52,17 @@ export class ConnectionManager implements Disposable {
5052
public readonly onDidChangeSyncDestination =
5153
this.onDidChangeSyncDestinationEmitter.event;
5254

53-
public metadataServiceUrl?: string;
55+
constructor(
56+
private cli: CliWrapper,
57+
private readonly configModel: ConfigModel,
58+
private readonly workspaceUri: Uri,
59+
private readonly customWhenContext: CustomWhenContext
60+
) {
61+
this._metadataService = new MetadataService(
62+
undefined,
63+
NamedLogger.getOrCreate("Extension")
64+
);
65+
}
5466

5567
@onError({
5668
popup: {prefix: "Error attaching sync destination: "},
@@ -104,12 +116,9 @@ export class ConnectionManager implements Disposable {
104116
this.onDidChangeClusterEmitter.fire(this.cluster);
105117
}
106118

107-
constructor(
108-
private cli: CliWrapper,
109-
private readonly configModel: ConfigModel,
110-
private readonly workspaceUri: Uri,
111-
private readonly customWhenContext: CustomWhenContext
112-
) {}
119+
get metadataServiceUrl() {
120+
return this._metadataService.url;
121+
}
113122

114123
public async init() {
115124
await this.configModel.init();
@@ -345,6 +354,11 @@ export class ConnectionManager implements Disposable {
345354
});
346355
}
347356

357+
async startMetadataService() {
358+
await this._metadataService.listen();
359+
return this._metadataService;
360+
}
361+
348362
async waitForConnect(): Promise<void> {
349363
if (this._state !== "CONNECTED") {
350364
return await new Promise((resolve) => {

packages/databricks-vscode/src/configuration/auth/MetadataServiceManager.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

packages/databricks-vscode/src/extension.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import {
3434
import {CustomWhenContext} from "./vscode-objs/CustomWhenContext";
3535
import {StateStorage} from "./vscode-objs/StateStorage";
3636
import path from "node:path";
37-
import {MetadataServiceManager} from "./configuration/auth/MetadataServiceManager";
3837
import {FeatureId, FeatureManager} from "./feature-manager/FeatureManager";
3938
import {DbConnectAccessVerifier} from "./language/DbConnectAccessVerifier";
4039
import {MsPythonExtensionWrapper} from "./language/MsPythonExtensionWrapper";
@@ -100,9 +99,10 @@ export async function activate(
10099

101100
// Add the databricks binary to the PATH environment variable in terminals
102101
context.environmentVariableCollection.clear();
103-
context.environmentVariableCollection.append(
102+
context.environmentVariableCollection.persistent = false;
103+
context.environmentVariableCollection.prepend(
104104
"PATH",
105-
`${path.delimiter}${context.asAbsolutePath("./bin")}`
105+
`${context.asAbsolutePath("./bin")}${path.delimiter}`
106106
);
107107

108108
const loggerManager = new LoggerManager(context);
@@ -222,10 +222,9 @@ export async function activate(
222222
}
223223
})
224224
);
225-
const metadataServiceManager = new MetadataServiceManager(
226-
connectionManager
227-
);
228-
await metadataServiceManager.listen();
225+
226+
const metadataService = await connectionManager.startMetadataService();
227+
context.subscriptions.push(metadataService);
229228

230229
const workspaceFsDataProvider = new WorkspaceFsDataProvider(
231230
connectionManager
@@ -237,7 +236,6 @@ export async function activate(
237236
);
238237

239238
context.subscriptions.push(
240-
metadataServiceManager,
241239
window.registerTreeDataProvider(
242240
"workspaceFsView",
243241
workspaceFsDataProvider

packages/databricks-vscode/src/file-managers/DatabricksEnvFileManager.ts

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {Context, context} from "@databricks/databricks-sdk/dist/context";
1818
import {DbConnectStatusBarButton} from "../language/DbConnectStatusBarButton";
1919
import {EnvVarGenerators, FileUtils} from "../utils";
2020
import {NotebookInitScriptManager} from "../language/notebooks/NotebookInitScriptManager";
21+
import {Mutex} from "../locking/Mutex";
2122

2223
function isValidUserEnvPath(
2324
path: string | undefined,
@@ -27,7 +28,7 @@ function isValidUserEnvPath(
2728
}
2829
export class DatabricksEnvFileManager implements Disposable {
2930
private disposables: Disposable[] = [];
30-
31+
private mutex = new Mutex();
3132
private readonly unresolvedDatabricksEnvFile: string;
3233
private readonly databricksEnvPath: Uri;
3334
private readonly unresolvedUserEnvFile: string;
@@ -97,38 +98,31 @@ export class DatabricksEnvFileManager implements Disposable {
9798
this.disposables.push(
9899
userEnvFileWatcher,
99100
userEnvFileWatcher.onDidChange(async () => {
100-
await this.emitToTerminal();
101101
await this.writeFile();
102102
}, this),
103103
userEnvFileWatcher.onDidDelete(async () => {
104-
await this.emitToTerminal();
105104
await this.writeFile();
106105
}, this),
107106
userEnvFileWatcher.onDidCreate(async () => {
108-
await this.emitToTerminal();
109107
await this.writeFile();
110108
}, this),
111109
this.featureManager.onDidChangeState(
112110
"notebooks.dbconnect",
113111
async () => {
114-
await this.emitToTerminal();
115112
await this.writeFile();
116113
}
117114
),
118115
this.featureManager.onDidChangeState(
119116
"debugging.dbconnect",
120117
() => {
121-
this.emitToTerminal();
122118
this.writeFile();
123119
},
124120
this
125121
),
126122
this.connectionManager.onDidChangeCluster(async () => {
127-
this.emitToTerminal();
128123
this.writeFile();
129124
}, this),
130125
this.connectionManager.onDidChangeState(async () => {
131-
this.emitToTerminal();
132126
this.writeFile();
133127
}, this)
134128
);
@@ -153,44 +147,51 @@ export class DatabricksEnvFileManager implements Disposable {
153147
async writeFile(@context ctx?: Context) {
154148
await this.connectionManager.waitForConnect();
155149

156-
const data = Object.entries({
157-
...(this.getDatabrickseEnvVars() || {}),
158-
...((await EnvVarGenerators.getDbConnectEnvVars(
159-
this.connectionManager,
160-
this.workspacePath
161-
)) || {}),
162-
...this.getIdeEnvVars(),
163-
...((await this.getUserEnvVars()) || {}),
164-
})
165-
.filter(([, value]) => value !== undefined)
166-
.map(([key, value]) => `${key}=${value}`);
167-
data.sort();
150+
await this.mutex.wait();
168151
try {
169-
const oldData = await readFile(
170-
this.databricksEnvPath.fsPath,
171-
"utf-8"
172-
);
173-
if (oldData !== data.join(os.EOL)) {
174-
this.onDidChangeEnvironmentVariablesEmitter.fire();
152+
const data = Object.entries({
153+
...(this.getDatabrickseEnvVars() || {}),
154+
...((await EnvVarGenerators.getDbConnectEnvVars(
155+
this.connectionManager,
156+
this.workspacePath
157+
)) || {}),
158+
...this.getIdeEnvVars(),
159+
...((await this.getUserEnvVars()) || {}),
160+
})
161+
.filter(([, value]) => value !== undefined)
162+
.map(([key, value]) => `${key}=${value}`);
163+
data.sort();
164+
try {
165+
const oldData = await readFile(
166+
this.databricksEnvPath.fsPath,
167+
"utf-8"
168+
);
169+
if (oldData === data.join(os.EOL)) {
170+
return;
171+
}
172+
} catch (e) {
173+
ctx?.logger?.info("Error reading old databricks.env file", e);
175174
}
176-
} catch (e) {
177-
ctx?.logger?.info("Error reading old databricks.env file", e);
178-
}
179-
try {
180-
await writeFile(
181-
this.databricksEnvPath.fsPath,
182-
data.join(os.EOL),
183-
"utf-8"
184-
);
185-
this.dbConnectStatusBarButton.update();
186-
} catch (e) {
187-
ctx?.logger?.info("Error writing databricks.env file", e);
175+
this.onDidChangeEnvironmentVariablesEmitter.fire();
176+
try {
177+
await writeFile(
178+
this.databricksEnvPath.fsPath,
179+
data.join(os.EOL),
180+
"utf-8"
181+
);
182+
this.dbConnectStatusBarButton.update();
183+
await this.emitToTerminal();
184+
} catch (e) {
185+
ctx?.logger?.info("Error writing databricks.env file", e);
186+
}
187+
} finally {
188+
this.mutex.signal();
188189
}
189190
}
190191

191192
async emitToTerminal() {
192-
await this.connectionManager.waitForConnect();
193-
193+
this.clearTerminalEnv();
194+
this.extensionContext.environmentVariableCollection.persistent = false;
194195
Object.entries({
195196
...(this.getDatabrickseEnvVars() || {}),
196197
...this.getIdeEnvVars(),
@@ -207,6 +208,10 @@ export class DatabricksEnvFileManager implements Disposable {
207208
value
208209
);
209210
});
211+
this.extensionContext.environmentVariableCollection.prepend(
212+
"PATH",
213+
`${this.extensionContext.asAbsolutePath("./bin")}${path.delimiter}`
214+
);
210215
}
211216

212217
async clearTerminalEnv() {

0 commit comments

Comments
 (0)