Skip to content

Commit 2ab689f

Browse files
Increase cluster refresh timeout to 10 minutes. (#130)
- The default refresh time for cluster list is 10 minutes now. - Clicking on the refresh button or opening the quickpick will refresh the list as well.
1 parent 7ad6552 commit 2ab689f

File tree

4 files changed

+31
-14
lines changed

4 files changed

+31
-14
lines changed

packages/databricks-vscode/.vscode/launch.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@
99
"name": "Run Extension",
1010
"type": "extensionHost",
1111
"request": "launch",
12-
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
13-
"outFiles": ["${workspaceFolder}/out/**/*.js"],
12+
"args": [
13+
"--extensionDevelopmentPath=${workspaceFolder}"
14+
],
15+
"outFiles": [
16+
"${workspaceFolder}/out/**/*.js"
17+
],
1418
"preLaunchTask": "${defaultBuildTask}",
1519
"env": {
16-
"DATABRICKS_DEBUG_HEADERS": "true"
20+
"DATABRICKS_DEBUG_HEADERS": "false"
1721
}
1822
},
1923
{
@@ -24,10 +28,12 @@
2428
"--extensionDevelopmentPath=${workspaceFolder}",
2529
"--extensionTestsPath=${workspaceFolder}/out/test/suite"
2630
],
27-
"outFiles": ["${workspaceFolder}/out/**/*.js"],
31+
"outFiles": [
32+
"${workspaceFolder}/out/**/*.js"
33+
],
2834
"preLaunchTask": "${defaultBuildTask}",
2935
"env": {
30-
"DATABRICKS_DEBUG_HEADERS": "true"
36+
"DATABRICKS_DEBUG_HEADERS": "false"
3137
}
3238
}
3339
]

packages/databricks-vscode/src/cluster/ClusterLoader.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,17 @@ export class ClusterLoader implements Disposable {
4444
private _onDidStop: EventEmitter<void> = new EventEmitter<void>();
4545
private readonly onDidStop: Event<void> = this._onDidStop.event;
4646

47+
private _onStopRequested: EventEmitter<void> = new EventEmitter<void>();
48+
private readonly onStopRequested: Event<void> = this._onStopRequested.event;
49+
4750
private _onDidChange: EventEmitter<void> = new EventEmitter<void>();
4851
readonly onDidChange: Event<void> = this._onDidChange.event;
4952

5053
private disposables: Disposable[] = [];
5154

5255
constructor(
5356
private connectionManager: ConnectionManager,
54-
refreshTime: Time = new Time(5, TimeUnits.seconds)
57+
refreshTime: Time = new Time(10, TimeUnits.minutes)
5558
) {
5659
this.refreshTime = refreshTime;
5760
this.disposables.push(this.onDidStop(() => (this.stopped = true)));
@@ -102,9 +105,13 @@ export class ClusterLoader implements Disposable {
102105
return;
103106
}
104107
let allClusters = sortClusters(
105-
(await Cluster.list(apiClient)).filter((c) =>
106-
["UI", "API"].includes(c.source)
107-
)
108+
(await Cluster.list(apiClient))
109+
.filter((c) => ["UI", "API"].includes(c.source))
110+
.filter(
111+
(c) =>
112+
c.details.data_security_mode !== "SINGLE_USER" ||
113+
this.isValidSingleUser(c)
114+
)
108115
);
109116

110117
const permissionApi = new PermissionsService(apiClient);
@@ -123,15 +130,16 @@ export class ClusterLoader implements Disposable {
123130
}
124131

125132
const task = new Promise<void>((resolve) => {
133+
const hasUcPerm =
134+
c.details.data_security_mode !== "SINGLE_USER" ||
135+
this.isValidSingleUser(c);
136+
126137
this.hasPerm(c, permissionApi)
127138
.then((hasPerm) => {
128139
if (!this.running) {
129140
return resolve();
130141
}
131-
const keepCluster =
132-
(c.details.data_security_mode !== "SINGLE_USER" ||
133-
this.isValidSingleUser(c)) &&
134-
hasPerm;
142+
const keepCluster = hasUcPerm && hasPerm;
135143

136144
if (this._clusters.has(c.id) && !keepCluster) {
137145
this._clusters.delete(c.id);
@@ -192,6 +200,7 @@ export class ClusterLoader implements Disposable {
192200
break;
193201
}
194202
await new Promise((resolve) => {
203+
this.disposables.push(this.onStopRequested(resolve));
195204
setTimeout(resolve, this.refreshTime.toMillSeconds().value);
196205
});
197206
}
@@ -205,6 +214,7 @@ export class ClusterLoader implements Disposable {
205214
}
206215

207216
this.running = false;
217+
this._onStopRequested.fire();
208218
await new Promise((resolve) => {
209219
this.disposables.push(this.onDidStop(resolve));
210220
});

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export class ConnectionCommands implements Disposable {
110110
quickPick.keepScrollPosition = true;
111111
quickPick.busy = true;
112112

113+
this.clusterModel.refresh();
113114
const refreshQuickPickItems = () => {
114115
let clusters = this.clusterModel.roots ?? [];
115116
quickPick.items = clusters.map((c) => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export async function selectProfile(
5656
const option = await window.showErrorMessage(
5757
`Can't parse config file`,
5858
{
59-
detail: e.message,
59+
detail: (e as ConfigFileError).message,
6060
},
6161
"Open Config File",
6262
"Backup and Overwrite Config File"

0 commit comments

Comments
 (0)