mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-16 17:22:29 -05:00
Dev/brih/bugs/merge rtm hotfix changes (#16792)
* improves migration context loading error handling * remove secrets and encode uris
This commit is contained in:
@@ -23,14 +23,11 @@ export class MigrationLocalStorage {
|
||||
const migrationMementos: MigrationContext[] = this.context.globalState.get(this.mementoToken) || [];
|
||||
for (let i = 0; i < migrationMementos.length; i++) {
|
||||
const migration = migrationMementos[i];
|
||||
migration.migrationContext = this.removeMigrationSecrets(migration.migrationContext);
|
||||
migration.sessionId = migration.sessionId ?? undefinedSessionId;
|
||||
if (migration.sourceConnectionProfile.serverName === connectionProfile.serverName) {
|
||||
if (refreshStatus) {
|
||||
try {
|
||||
const autoCutoverConfiguration = migration.migrationContext.properties.autoCutoverConfiguration;
|
||||
const backupConfiguration = migration.migrationContext.properties.backupConfiguration;
|
||||
const sourceDatabase = migration.migrationContext.properties.sourceDatabaseName;
|
||||
|
||||
await this.refreshMigrationAzureAccount(migration);
|
||||
|
||||
if (migration.asyncUrl) {
|
||||
@@ -38,28 +35,23 @@ export class MigrationLocalStorage {
|
||||
migration.azureAccount,
|
||||
migration.subscription,
|
||||
migration.asyncUrl,
|
||||
migration.sessionId!
|
||||
);
|
||||
|
||||
migration.migrationContext = await getMigrationStatus(
|
||||
migration.azureAccount,
|
||||
migration.subscription,
|
||||
migration.migrationContext,
|
||||
migration.sessionId!,
|
||||
migration.asyncUrl
|
||||
);
|
||||
|
||||
migration.migrationContext.properties.sourceDatabaseName = sourceDatabase;
|
||||
migration.migrationContext.properties.backupConfiguration = backupConfiguration;
|
||||
migration.migrationContext.properties.autoCutoverConfiguration = autoCutoverConfiguration;
|
||||
migration.sessionId!);
|
||||
}
|
||||
|
||||
migration.migrationContext = await getMigrationStatus(
|
||||
migration.azureAccount,
|
||||
migration.subscription,
|
||||
migration.migrationContext,
|
||||
migration.sessionId!);
|
||||
}
|
||||
catch (e) {
|
||||
// Keeping only valid migrations in cache. Clearing all the migrations which return ResourceDoesNotExit error.
|
||||
if (e.message === 'ResourceDoesNotExist') {
|
||||
continue;
|
||||
} else {
|
||||
console.log(e);
|
||||
switch (e.message) {
|
||||
case 'ResourceDoesNotExist':
|
||||
case 'NullMigrationId':
|
||||
continue;
|
||||
default:
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,7 +91,7 @@ export class MigrationLocalStorage {
|
||||
migrationMementos = migrationMementos.filter(m => m.migrationContext.id !== migrationContext.id);
|
||||
migrationMementos.push({
|
||||
sourceConnectionProfile: connectionProfile,
|
||||
migrationContext: migrationContext,
|
||||
migrationContext: this.removeMigrationSecrets(migrationContext),
|
||||
targetManagedInstance: targetMI,
|
||||
subscription: subscription,
|
||||
azureAccount: azureAccount,
|
||||
@@ -116,6 +108,23 @@ export class MigrationLocalStorage {
|
||||
public static clearMigrations() {
|
||||
this.context.globalState.update(this.mementoToken, ([] as MigrationContext[]));
|
||||
}
|
||||
|
||||
public static removeMigrationSecrets(migration: DatabaseMigration): DatabaseMigration {
|
||||
// remove secrets from migration context
|
||||
if (migration.properties.sourceSqlConnection?.password) {
|
||||
migration.properties.sourceSqlConnection.password = '';
|
||||
}
|
||||
if (migration.properties.backupConfiguration?.sourceLocation?.fileShare?.password) {
|
||||
migration.properties.backupConfiguration.sourceLocation.fileShare.password = '';
|
||||
}
|
||||
if (migration.properties.backupConfiguration?.sourceLocation?.azureBlob?.accountKey) {
|
||||
migration.properties.backupConfiguration.sourceLocation.azureBlob.accountKey = '';
|
||||
}
|
||||
if (migration.properties.backupConfiguration?.targetLocation?.accountKey) {
|
||||
migration.properties.backupConfiguration.targetLocation.accountKey = '';
|
||||
}
|
||||
return migration;
|
||||
}
|
||||
}
|
||||
|
||||
export interface MigrationContext {
|
||||
|
||||
Reference in New Issue
Block a user