Skip to content

Commit 2f9e676

Browse files
authored
Collect lssh logs in connection window (#105)
1 parent 22e1e96 commit 2f9e676

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Gitpod",
44
"description": "Gitpod Support",
55
"publisher": "gitpod",
6-
"version": "0.0.167",
6+
"version": "0.0.168",
77
"license": "MIT",
88
"icon": "resources/gitpod.png",
99
"repository": {

src/commands/logs.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface IFile {
2323

2424
export class ExportLogsCommand implements Command {
2525
readonly id = 'gitpod.exportLogs';
26+
static latestLSSHHost: string | undefined;
2627

2728
constructor(
2829
private readonly context: vscode.ExtensionContext,
@@ -70,12 +71,14 @@ export class ExportLogsCommand implements Command {
7071
}
7172

7273
private getLSSHLog(): string | undefined {
74+
let lsshHostname: string | undefined;
7375
const sshDestStr = getGitpodRemoteWindowConnectionInfo(this.context)?.sshDestStr;
7476
if (sshDestStr) {
75-
const sshDest = SSHDestination.fromRemoteSSHString(sshDestStr);
76-
return path.join(os.tmpdir(), `lssh-${sshDest.hostname}.log`);
77+
lsshHostname = SSHDestination.fromRemoteSSHString(sshDestStr).hostname;
78+
} else if (ExportLogsCommand.latestLSSHHost) {
79+
lsshHostname = ExportLogsCommand.latestLSSHHost;
7780
}
78-
return undefined;
81+
return lsshHostname ? path.join(os.tmpdir(), `lssh-${lsshHostname}.log`) : undefined;
7982
}
8083

8184
async exportLogs() {

src/commands/workspaces.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { IRemoteService } from '../services/remoteService';
1818
import { WrapError } from '../common/utils';
1919
import { getOpenSSHVersion, testSSHConnection as testLocalSSHConnection } from '../ssh/nativeSSH';
2020
import { IExperimentsService } from '../experiments';
21+
import { ExportLogsCommand } from './logs';
2122

2223
function getCommandName(command: string) {
2324
return command.replace('gitpod.workspaces.', '').replace(/(?:_inline|_context)(?:@\d)?$/, '');
@@ -133,6 +134,8 @@ export class ConnectInNewWindowCommand implements Command {
133134
await testLocalSSHConnection(localSSHDestination.user!, localSSHDestination.hostname);
134135
localSSHTestSuccess = true;
135136
} catch (e) {
137+
ExportLogsCommand.latestLSSHHost = localSSHDestination?.hostname;
138+
136139
this.telemetryService.sendTelemetryException(
137140
new WrapError('Local SSH: failed to connect to workspace', e),
138141
{
@@ -305,6 +308,8 @@ export class ConnectInCurrentWindowCommand implements Command {
305308
await testLocalSSHConnection(localSSHDestination.user!, localSSHDestination.hostname);
306309
localSSHTestSuccess = true;
307310
} catch (e) {
311+
ExportLogsCommand.latestLSSHHost = localSSHDestination?.hostname;
312+
308313
this.telemetryService.sendTelemetryException(
309314
new WrapError('Local SSH: failed to connect to workspace', e),
310315
{

src/remoteConnector.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { ILogService } from './services/logService';
2626
import { IHostService } from './services/hostService';
2727
import { WrapError, getServiceURL } from './common/utils';
2828
import { IRemoteService } from './services/remoteService';
29+
import { ExportLogsCommand } from './commands/logs';
2930

3031
export class RemoteConnector extends Disposable {
3132

@@ -44,8 +45,8 @@ export class RemoteConnector extends Disposable {
4445
super();
4546

4647
this._register(this.hostService.onDidChangeHost(async () => {
47-
await this.updateSSHRemotePlatform()
48-
}))
48+
await this.updateSSHRemotePlatform();
49+
}));
4950
}
5051

5152
private async getWorkspaceSSHDestination({ workspaceId, gitpodHost, debugWorkspace }: SSHConnectionParams): Promise<{ destination: SSHDestination; password?: string }> {
@@ -278,6 +279,8 @@ export class RemoteConnector extends Disposable {
278279

279280
this.telemetryService.sendUserFlowStatus('connected', localSSHFlow);
280281
} catch (e) {
282+
ExportLogsCommand.latestLSSHHost = localSSHDestination?.hostname;
283+
281284
const reason = e?.code ?? (e?.name && e.name !== 'Error' ? e.name : 'Unknown');
282285
this.telemetryService.sendTelemetryException(new WrapError('Local SSH: failed to connect to workspace', e), { ...localSSHFlow });
283286
this.telemetryService.sendUserFlowStatus('failed', { ...localSSHFlow, reason });

0 commit comments

Comments
 (0)