mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
add error handler for validateIR gateway timeout (#22091)
* add error handler for validateIR gateway timeout * log api errors
This commit is contained in:
@@ -796,6 +796,8 @@ export function VALIDATE_IR_VALIDATION_STATUS(state: string | undefined, errors?
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const VALIDATE_IR_ERROR_GATEWAY_TIMEOUT = localize('sql.migration.validate.error.gatewaytimeout', "A time-out was encountered while validating a resource connection. Learn more: https://aka.ms/dms-migrations-troubleshooting.");
|
||||||
|
|
||||||
export function VALIDATE_IR_VALIDATION_STATUS_ERROR_COUNT(state: string | undefined, errorCount: number): string {
|
export function VALIDATE_IR_VALIDATION_STATUS_ERROR_COUNT(state: string | undefined, errorCount: number): string {
|
||||||
const status = state ?? '';
|
const status = state ?? '';
|
||||||
return errorCount > 1
|
return errorCount > 1
|
||||||
|
|||||||
@@ -11,9 +11,18 @@ import { MigrationStateModel, MigrationTargetType, NetworkShare, ValidateIrState
|
|||||||
import { EOL } from 'os';
|
import { EOL } from 'os';
|
||||||
import { IconPathHelper } from '../../constants/iconPathHelper';
|
import { IconPathHelper } from '../../constants/iconPathHelper';
|
||||||
import { getEncryptConnectionValue, getSourceConnectionProfile, getTrustServerCertificateValue } from '../../api/sqlUtils';
|
import { getEncryptConnectionValue, getSourceConnectionProfile, getTrustServerCertificateValue } from '../../api/sqlUtils';
|
||||||
|
import { logError, TelemetryViews } from '../../telemetry';
|
||||||
|
|
||||||
const DialogName = 'ValidateIrDialog';
|
const DialogName = 'ValidateIrDialog';
|
||||||
|
|
||||||
|
enum HttpStatusCodes {
|
||||||
|
GatewayTimeout = "504\r\n",
|
||||||
|
}
|
||||||
|
|
||||||
|
enum HttpStatusExceptionCodes {
|
||||||
|
ConnectionTimeoutError = "ConnectionTimeoutError",
|
||||||
|
}
|
||||||
|
|
||||||
enum ValidationResultIndex {
|
enum ValidationResultIndex {
|
||||||
message = 0,
|
message = 0,
|
||||||
icon = 1,
|
icon = 1,
|
||||||
@@ -405,10 +414,12 @@ export class ValidateIrDialog {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
const err = this._formatError(error);
|
||||||
|
logError(TelemetryViews.ValidIrDialog, err.message, error);
|
||||||
await this._updateValidateIrResults(
|
await this._updateValidateIrResults(
|
||||||
testNumber,
|
testNumber,
|
||||||
ValidateIrState.Failed,
|
ValidateIrState.Failed,
|
||||||
[constants.VALIDATE_IR_VALIDATION_RESULT_API_ERROR(sourceDatabase, error)]);
|
[constants.VALIDATE_IR_VALIDATION_RESULT_API_ERROR(sourceDatabase, err)]);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@@ -447,6 +458,16 @@ export class ValidateIrDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _formatError(error: Error): Error {
|
||||||
|
if (error?.message?.startsWith(HttpStatusCodes.GatewayTimeout)) {
|
||||||
|
return {
|
||||||
|
name: HttpStatusExceptionCodes.ConnectionTimeoutError,
|
||||||
|
message: constants.VALIDATE_IR_ERROR_GATEWAY_TIMEOUT,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
private async _validateSqlDbMigration(): Promise<void> {
|
private async _validateSqlDbMigration(): Promise<void> {
|
||||||
const currentConnection = await getSourceConnectionProfile();
|
const currentConnection = await getSourceConnectionProfile();
|
||||||
const sourceServerName = currentConnection?.serverName!;
|
const sourceServerName = currentConnection?.serverName!;
|
||||||
@@ -464,8 +485,8 @@ export class ValidateIrDialog {
|
|||||||
testSourceConnectivity: boolean,
|
testSourceConnectivity: boolean,
|
||||||
testTargetConnectivity: boolean): Promise<boolean> => {
|
testTargetConnectivity: boolean): Promise<boolean> => {
|
||||||
|
|
||||||
await this._updateValidateIrResults(testNumber, ValidateIrState.Running);
|
|
||||||
try {
|
try {
|
||||||
|
await this._updateValidateIrResults(testNumber, ValidateIrState.Running);
|
||||||
const response = await validateIrSqlDatabaseMigrationSettings(
|
const response = await validateIrSqlDatabaseMigrationSettings(
|
||||||
this._model,
|
this._model,
|
||||||
sourceServerName,
|
sourceServerName,
|
||||||
@@ -488,10 +509,12 @@ export class ValidateIrDialog {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
const err = this._formatError(error);
|
||||||
|
logError(TelemetryViews.ValidIrDialog, err.message, error);
|
||||||
await this._updateValidateIrResults(
|
await this._updateValidateIrResults(
|
||||||
testNumber,
|
testNumber,
|
||||||
ValidateIrState.Failed,
|
ValidateIrState.Failed,
|
||||||
[constants.VALIDATE_IR_VALIDATION_RESULT_API_ERROR(sourceDatabase, error)]);
|
[constants.VALIDATE_IR_VALIDATION_RESULT_API_ERROR(sourceDatabase, err)]);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export enum TelemetryViews {
|
|||||||
LoginMigrationSelectorPage = 'LoginMigrationSelectorPage',
|
LoginMigrationSelectorPage = 'LoginMigrationSelectorPage',
|
||||||
LoginMigrationStatusPage = 'LoginMigrationStatusPage',
|
LoginMigrationStatusPage = 'LoginMigrationStatusPage',
|
||||||
TdeConfigurationDialog = 'TdeConfigurationDialog',
|
TdeConfigurationDialog = 'TdeConfigurationDialog',
|
||||||
|
ValidIrDialog = 'validIrDialog',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum TelemetryAction {
|
export enum TelemetryAction {
|
||||||
|
|||||||
Reference in New Issue
Block a user