Skip to content

Commit 6840f1a

Browse files
iQQBotjeanp413
andauthored
Remove deprecated failureReason field and add error report (#53)
* remove deprecated failureReason field * ensure errorstack has value * 💄 * 💄 --------- Co-authored-by: Jean Pierre <[email protected]>
1 parent b5afea8 commit 6840f1a

File tree

6 files changed

+22
-37
lines changed

6 files changed

+22
-37
lines changed

src/local-ssh/ipc/extension.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ export class ExtensionServiceImpl implements ExtensionServiceImplementation {
123123
extensionVersion: request.extensionVersion,
124124
};
125125
if (request.status !== SendLocalSSHUserFlowStatusRequest_Status.STATUS_SUCCESS && request.failureCode !== SendLocalSSHUserFlowStatusRequest_Code.CODE_UNSPECIFIED) {
126-
flow.reason = request.failureReason; // TODO remove, should go to error reporting only
127126
flow.reasonCode = SendLocalSSHUserFlowStatusRequest_Code[request.failureCode];
128127
}
129128
const status = request.status === SendLocalSSHUserFlowStatusRequest_Status.STATUS_SUCCESS ? 'local-ssh-success' : 'local-ssh-failure';
@@ -135,7 +134,7 @@ export class ExtensionServiceImpl implements ExtensionServiceImplementation {
135134
// local ssh daemon should be own component in reporting?
136135
async sendErrorReport(request: SendErrorReportRequest, _context: CallContext): Promise<{}> {
137136
const err = new Error(request.errorMessage);
138-
err.name = 'local-ssh:' + request.errorName;
137+
err.name = `${request.errorName}[local-ssh]`;
139138
err.stack = request.errorStack;
140139
const properties: Record<string, any> = {
141140
workspaceId: request.workspaceId,

src/local-ssh/ipc/localssh.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ export class LocalSSHServiceImpl implements LocalSSHServiceImplementation {
130130
request.errorMessage = message + ': ' + err.message;
131131
request.errorStack = err.stack ?? '';
132132
} else {
133-
request.errorName = err.toString();
133+
request.errorName = '';
134134
request.errorMessage = message + ': ' + err.toString();
135+
request.errorStack = '';
135136
}
136137
for (const ext of this.extensionServices) {
137138
try {

src/local-ssh/server.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class LocalSSHGatewayServer {
4040
workspaceId: clientUsername,
4141
instanceId: '',
4242
failureCode: SendLocalSSHUserFlowStatusRequest_Code.CODE_NO_WORKSPACE_AUTO_INFO,
43-
failureReason: e?.toString(), // TODO remove, and report to error reporting
43+
// TODO remove, and report to error reporting
4444
daemonVersion: getDaemonVersion(),
4545
extensionVersion: getRunningExtensionVersion(),
4646
connType: SendLocalSSHUserFlowStatusRequest_ConnType.CONN_TYPE_UNSPECIFIED,
@@ -72,16 +72,16 @@ export class LocalSSHGatewayServer {
7272
this.clientCount += 1;
7373
session.onAuthenticating((e) => {
7474
e.authenticationPromise = this.authenticateClient(e.username!).then(s => {
75-
this.logger.info('authenticate with ' + e.username);
76-
pipeSession = s;
77-
return {};
78-
}).catch(e => {
79-
this.logger.error(e, 'failed to authenticate client');
80-
// TODO not sure how to get gitpod host here
81-
// this.localsshService.sendErrorReport(e.username, undefined, e, 'failed to authenticate client');
82-
session.close(SshDisconnectReason.hostNotAllowedToConnect, 'auth failed or workspace is not running');
83-
return null;
84-
});
75+
this.logger.info('authenticate with ' + e.username);
76+
pipeSession = s;
77+
return {};
78+
}).catch(e => {
79+
this.logger.error(e, 'failed to authenticate client');
80+
// TODO not sure how to get gitpod host here
81+
// this.localsshService.sendErrorReport(e.username, undefined, e, 'failed to authenticate client');
82+
session.close(SshDisconnectReason.hostNotAllowedToConnect, 'auth failed or workspace is not running');
83+
return null;
84+
});
8585
});
8686
session.onClientAuthenticated(async () => {
8787
try {
@@ -144,7 +144,6 @@ export class LocalSSHGatewayServer {
144144
workspaceId: workspaceInfo.workspaceId,
145145
instanceId: workspaceInfo.instanceId,
146146
failureCode: SendLocalSSHUserFlowStatusRequest_Code.CODE_SSH_CANNOT_CONNECT,
147-
failureReason: e?.toString(), // TODO remove, and report to error reporting
148147
daemonVersion: getDaemonVersion(),
149148
extensionVersion: getRunningExtensionVersion(),
150149
connType: SendLocalSSHUserFlowStatusRequest_ConnType.CONN_TYPE_SSH,
@@ -154,12 +153,12 @@ export class LocalSSHGatewayServer {
154153
}
155154

156155
private async getTunnelSSHConfig(workspaceInfo: GetWorkspaceAuthInfoResponse): Promise<SshClientSession> {
157-
const ssh = new SupervisorSSHTunnel(this.logger, workspaceInfo, this.localsshService);
158-
const connConfig = await ssh.establishTunnel();
159-
const config = new SshSessionConfiguration();
160-
const session = new SshClientSession(config);
161-
session.onAuthenticating((e) => e.authenticationPromise = Promise.resolve({}));
162156
try {
157+
const ssh = new SupervisorSSHTunnel(this.logger, workspaceInfo, this.localsshService);
158+
const connConfig = await ssh.establishTunnel();
159+
const config = new SshSessionConfiguration();
160+
const session = new SshClientSession(config);
161+
session.onAuthenticating((e) => e.authenticationPromise = Promise.resolve({}));
163162
await session.connect(new NodeStream(connConfig.sock!));
164163
// we need to convert openssh to pkcs8 since dev-tunnels-ssh not support openssh
165164
const credentials: SshClientCredentials = { username: connConfig.username, publicKeys: [await importKeyBytes(parsePrivateKey(connConfig.privateKey, 'openssh').toBuffer('pkcs8'))] };
@@ -169,14 +168,14 @@ export class LocalSSHGatewayServer {
169168
}
170169
return session;
171170
} catch (e) {
171+
this.localsshService.sendErrorReport(workspaceInfo.gitpodHost, workspaceInfo.userId, workspaceInfo.workspaceId, workspaceInfo.instanceId, e, 'failed to connect with tunnel ssh');
172172
this.localsshService.sendTelemetry({
173173
gitpodHost: workspaceInfo.gitpodHost,
174174
userId: workspaceInfo.userId,
175175
status: SendLocalSSHUserFlowStatusRequest_Status.STATUS_FAILURE,
176176
workspaceId: workspaceInfo.workspaceId,
177177
instanceId: workspaceInfo.instanceId,
178178
failureCode: SendLocalSSHUserFlowStatusRequest_Code.CODE_TUNNEL_NO_ESTABLISHED_CONNECTION,
179-
failureReason: e?.toString(), // TODO remove, and report to error reporting
180179
daemonVersion: getDaemonVersion(),
181180
extensionVersion: getRunningExtensionVersion(),
182181
connType: SendLocalSSHUserFlowStatusRequest_ConnType.CONN_TYPE_TUNNEL,

src/local-ssh/sshTunnel.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ export class SupervisorSSHTunnel {
8585
workspaceId: this.workspaceInfo.workspaceId,
8686
instanceId: this.workspaceInfo.instanceId,
8787
failureCode: SendLocalSSHUserFlowStatusRequest_Code.CODE_TUNNEL_NO_PRIVATEKEY,
88-
failureReason: e?.toString(), // TODO remove, and report to error reporting
8988
daemonVersion: getDaemonVersion(),
9089
extensionVersion: getRunningExtensionVersion(),
9190
connType: SendLocalSSHUserFlowStatusRequest_ConnType.CONN_TYPE_TUNNEL,
@@ -113,7 +112,6 @@ export class SupervisorSSHTunnel {
113112
workspaceId: this.workspaceInfo.workspaceId,
114113
instanceId: this.workspaceInfo.instanceId,
115114
failureCode: SendLocalSSHUserFlowStatusRequest_Code.CODE_TUNNEL_CANNOT_CREATE_WEBSOCKET,
116-
failureReason: e?.toString(), // TODO remove, and report to error reporting
117115
daemonVersion: getDaemonVersion(),
118116
extensionVersion: getRunningExtensionVersion(),
119117
connType: SendLocalSSHUserFlowStatusRequest_ConnType.CONN_TYPE_TUNNEL,
@@ -142,7 +140,6 @@ export class SupervisorSSHTunnel {
142140
workspaceId: this.workspaceInfo.workspaceId,
143141
instanceId: this.workspaceInfo.instanceId,
144142
failureCode: SendLocalSSHUserFlowStatusRequest_Code.CODE_TUNNEL_FAILED_FORWARD_SSH_PORT,
145-
failureReason: e?.toString(), // TODO remove, and report to error reporting
146143
daemonVersion: getDaemonVersion(),
147144
extensionVersion: getRunningExtensionVersion(),
148145
connType: SendLocalSSHUserFlowStatusRequest_ConnType.CONN_TYPE_TUNNEL,

src/proto/ipc/v1/ipc.proto

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ message SendLocalSSHUserFlowStatusRequest {
8888
string workspace_id = 2;
8989
string instance_id = 3;
9090
Code failure_code = 5;
91-
string failure_reason = 6 [deprecated = true];
91+
// DEPRECATED string failure_reason = 6
92+
reserved 6;
9293
string daemon_version = 7;
9394
string extension_version = 8;
9495
ConnType conn_type = 9;

src/proto/typescript/ipc/v1/ipc.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ export interface SendLocalSSHUserFlowStatusRequest {
4040
workspaceId: string;
4141
instanceId: string;
4242
failureCode: SendLocalSSHUserFlowStatusRequest_Code;
43-
/** @deprecated */
44-
failureReason: string;
4543
daemonVersion: string;
4644
extensionVersion: string;
4745
connType: SendLocalSSHUserFlowStatusRequest_ConnType;
@@ -651,7 +649,6 @@ function createBaseSendLocalSSHUserFlowStatusRequest(): SendLocalSSHUserFlowStat
651649
workspaceId: "",
652650
instanceId: "",
653651
failureCode: 0,
654-
failureReason: "",
655652
daemonVersion: "",
656653
extensionVersion: "",
657654
connType: 0,
@@ -674,9 +671,6 @@ export const SendLocalSSHUserFlowStatusRequest = {
674671
if (message.failureCode !== 0) {
675672
writer.uint32(40).int32(message.failureCode);
676673
}
677-
if (message.failureReason !== "") {
678-
writer.uint32(50).string(message.failureReason);
679-
}
680674
if (message.daemonVersion !== "") {
681675
writer.uint32(58).string(message.daemonVersion);
682676
}
@@ -714,9 +708,6 @@ export const SendLocalSSHUserFlowStatusRequest = {
714708
case 5:
715709
message.failureCode = reader.int32() as any;
716710
break;
717-
case 6:
718-
message.failureReason = reader.string();
719-
break;
720711
case 7:
721712
message.daemonVersion = reader.string();
722713
break;
@@ -746,7 +737,6 @@ export const SendLocalSSHUserFlowStatusRequest = {
746737
workspaceId: isSet(object.workspaceId) ? String(object.workspaceId) : "",
747738
instanceId: isSet(object.instanceId) ? String(object.instanceId) : "",
748739
failureCode: isSet(object.failureCode) ? sendLocalSSHUserFlowStatusRequest_CodeFromJSON(object.failureCode) : 0,
749-
failureReason: isSet(object.failureReason) ? String(object.failureReason) : "",
750740
daemonVersion: isSet(object.daemonVersion) ? String(object.daemonVersion) : "",
751741
extensionVersion: isSet(object.extensionVersion) ? String(object.extensionVersion) : "",
752742
connType: isSet(object.connType) ? sendLocalSSHUserFlowStatusRequest_ConnTypeFromJSON(object.connType) : 0,
@@ -762,7 +752,6 @@ export const SendLocalSSHUserFlowStatusRequest = {
762752
message.instanceId !== undefined && (obj.instanceId = message.instanceId);
763753
message.failureCode !== undefined &&
764754
(obj.failureCode = sendLocalSSHUserFlowStatusRequest_CodeToJSON(message.failureCode));
765-
message.failureReason !== undefined && (obj.failureReason = message.failureReason);
766755
message.daemonVersion !== undefined && (obj.daemonVersion = message.daemonVersion);
767756
message.extensionVersion !== undefined && (obj.extensionVersion = message.extensionVersion);
768757
message.connType !== undefined &&
@@ -782,7 +771,6 @@ export const SendLocalSSHUserFlowStatusRequest = {
782771
message.workspaceId = object.workspaceId ?? "";
783772
message.instanceId = object.instanceId ?? "";
784773
message.failureCode = object.failureCode ?? 0;
785-
message.failureReason = object.failureReason ?? "";
786774
message.daemonVersion = object.daemonVersion ?? "";
787775
message.extensionVersion = object.extensionVersion ?? "";
788776
message.connType = object.connType ?? 0;

0 commit comments

Comments
 (0)