mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Converting all SQL MIAA commands to use K8s API commands (#20203)
* refresh does not differentiate direct vs indirect * For direct mode MIAA commands, always use --use-k8s * Changed comment language to use ARM instead of direct and K8S API instead of indirect Co-authored-by: Candice Ye <canye@microsoft.com>
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
import { ControllerInfo, ResourceType } from 'arc';
|
||||
import * as azExt from 'az-ext';
|
||||
import * as vscode from 'vscode';
|
||||
import { ConnectionMode } from '../constants';
|
||||
import * as loc from '../localizedConstants';
|
||||
import { AzureArcTreeDataProvider } from '../ui/tree/azureArcTreeDataProvider';
|
||||
|
||||
@@ -69,15 +68,6 @@ export class ControllerModel {
|
||||
}
|
||||
|
||||
public async refresh(showErrors: boolean = true, namespace: string): Promise<void> {
|
||||
await this.refreshController(showErrors, namespace);
|
||||
if (this._controllerConfig?.spec.settings.azure.connectionMode.toLowerCase() === ConnectionMode.direct) {
|
||||
await this.refreshDirectMode(this._controllerConfig?.spec.settings.azure.resourceGroup, namespace);
|
||||
} else {
|
||||
await this.refreshIndirectMode(namespace);
|
||||
}
|
||||
}
|
||||
|
||||
public async refreshController(showErrors: boolean = true, namespace: string): Promise<void> {
|
||||
await Promise.all([
|
||||
this._azApi.az.arcdata.dc.config.show(namespace, this.azAdditionalEnvVars).then(result => {
|
||||
this._controllerConfig = result.stdout;
|
||||
@@ -108,38 +98,6 @@ export class ControllerModel {
|
||||
throw err;
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
||||
public async refreshDirectMode(resourceGroup: string, namespace: string): Promise<void> {
|
||||
const newRegistrations: Registration[] = [];
|
||||
await Promise.all([
|
||||
this._azApi.az.postgres.arcserver.list(namespace, this.azAdditionalEnvVars).then(result => {
|
||||
newRegistrations.push(...result.stdout.map(r => {
|
||||
return {
|
||||
instanceName: r.name,
|
||||
state: r.state,
|
||||
instanceType: ResourceType.postgresInstances
|
||||
};
|
||||
}));
|
||||
}),
|
||||
this._azApi.az.sql.miarc.list({ resourceGroup: resourceGroup, namespace: undefined }, this.azAdditionalEnvVars).then(result => {
|
||||
newRegistrations.push(...result.stdout.map(r => {
|
||||
return {
|
||||
instanceName: r.name,
|
||||
state: r.state,
|
||||
instanceType: ResourceType.sqlManagedInstances
|
||||
};
|
||||
}));
|
||||
|
||||
})
|
||||
]).then(() => {
|
||||
this._registrations = newRegistrations;
|
||||
this.registrationsLastUpdated = new Date();
|
||||
this._onRegistrationsUpdated.fire(this._registrations);
|
||||
});
|
||||
}
|
||||
|
||||
public async refreshIndirectMode(namespace: string): Promise<void> {
|
||||
const newRegistrations: Registration[] = [];
|
||||
await Promise.all([
|
||||
this._azApi.az.postgres.arcserver.list(namespace, this.azAdditionalEnvVars).then(result => {
|
||||
|
||||
@@ -15,7 +15,6 @@ import { ConnectToMiaaSqlDialog } from '../ui/dialogs/connectMiaaDialog';
|
||||
import { AzureArcTreeDataProvider } from '../ui/tree/azureArcTreeDataProvider';
|
||||
import { ControllerModel, Registration } from './controllerModel';
|
||||
import { ResourceModel } from './resourceModel';
|
||||
import { ConnectionMode } from '../constants';
|
||||
|
||||
export type DatabaseModel = { name: string, status: string, earliestBackup: string, lastBackup: string };
|
||||
export type RPModel = { recoveryPointObjective: string, retentionDays: string };
|
||||
@@ -100,16 +99,6 @@ export class MiaaModel extends ResourceModel {
|
||||
try {
|
||||
try {
|
||||
let result;
|
||||
if (this.controllerModel.info.connectionMode.toLowerCase() === ConnectionMode.direct) {
|
||||
result = await this._azApi.az.sql.miarc.show(
|
||||
this.info.name,
|
||||
{
|
||||
resourceGroup: this.controllerModel.info.resourceGroup,
|
||||
namespace: undefined
|
||||
},
|
||||
this.controllerModel.azAdditionalEnvVars
|
||||
);
|
||||
} else {
|
||||
result = await this._azApi.az.sql.miarc.show(
|
||||
this.info.name,
|
||||
{
|
||||
@@ -118,7 +107,6 @@ export class MiaaModel extends ResourceModel {
|
||||
},
|
||||
this.controllerModel.azAdditionalEnvVars
|
||||
);
|
||||
}
|
||||
this._config = result.stdout;
|
||||
this.configLastUpdated = new Date();
|
||||
this.rpSettings.retentionDays = this._config?.spec?.backup?.retentionPeriodInDays?.toString() ?? '';
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as vscode from 'vscode';
|
||||
import * as azdata from 'azdata';
|
||||
import * as azExt from 'az-ext';
|
||||
import * as loc from '../../../localizedConstants';
|
||||
import { IconPathHelper, cssStyles, ConnectionMode } from '../../../constants';
|
||||
import { IconPathHelper, cssStyles } from '../../../constants';
|
||||
import { DashboardPage } from '../../components/dashboardPage';
|
||||
import { MiaaModel, RPModel, DatabaseModel, systemDbs } from '../../../models/miaaModel';
|
||||
import { ControllerModel } from '../../../models/controllerModel';
|
||||
@@ -220,15 +220,6 @@ export class MiaaBackupsPage extends DashboardPage {
|
||||
cancellable: false
|
||||
},
|
||||
async (_progress, _token): Promise<void> => {
|
||||
if (this._miaaModel.controllerModel.info.connectionMode.toLowerCase() === ConnectionMode.direct) {
|
||||
await this._azApi.az.sql.miarc.update(
|
||||
this._miaaModel.info.name,
|
||||
this._saveArgs,
|
||||
this._miaaModel.controllerModel.info.resourceGroup,
|
||||
undefined, // Indirect mode argument - namespace
|
||||
undefined, // Indirect mode argument - usek8s
|
||||
this._miaaModel.controllerModel.azAdditionalEnvVars);
|
||||
} else {
|
||||
await this._azApi.az.sql.miarc.update(
|
||||
this._miaaModel.info.name,
|
||||
this._saveArgs,
|
||||
@@ -236,7 +227,6 @@ export class MiaaBackupsPage extends DashboardPage {
|
||||
this._miaaModel.controllerModel.info.namespace,
|
||||
true,
|
||||
this._miaaModel.controllerModel.azAdditionalEnvVars);
|
||||
}
|
||||
try {
|
||||
await this._miaaModel.refresh();
|
||||
} catch (error) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as vscode from 'vscode';
|
||||
import * as azdata from 'azdata';
|
||||
import * as azExt from 'az-ext';
|
||||
import * as loc from '../../../localizedConstants';
|
||||
import { IconPathHelper, cssStyles, ConnectionMode } from '../../../constants';
|
||||
import { IconPathHelper, cssStyles } from '../../../constants';
|
||||
import { DashboardPage } from '../../components/dashboardPage';
|
||||
import { convertToGibibyteString } from '../../../common/utils';
|
||||
import { MiaaModel } from '../../../models/miaaModel';
|
||||
@@ -132,15 +132,6 @@ export class MiaaComputeAndStoragePage extends DashboardPage {
|
||||
},
|
||||
async (_progress, _token): Promise<void> => {
|
||||
try {
|
||||
if (this._miaaModel.controllerModel.info.connectionMode.toLowerCase() === ConnectionMode.direct) {
|
||||
await this._azApi.az.sql.miarc.update(
|
||||
this._miaaModel.info.name,
|
||||
this.saveArgs,
|
||||
this._miaaModel.controllerModel.info.resourceGroup,
|
||||
undefined, // Indirect mode argument - namespace
|
||||
undefined, // Indirect mode argument - usek8s
|
||||
this._miaaModel.controllerModel.azAdditionalEnvVars);
|
||||
} else {
|
||||
await this._azApi.az.sql.miarc.update(
|
||||
this._miaaModel.info.name,
|
||||
this.saveArgs,
|
||||
@@ -148,7 +139,6 @@ export class MiaaComputeAndStoragePage extends DashboardPage {
|
||||
this._miaaModel.controllerModel.info.namespace,
|
||||
true,
|
||||
this._miaaModel.controllerModel.azAdditionalEnvVars);
|
||||
}
|
||||
} catch (err) {
|
||||
this.saveButton!.enabled = true;
|
||||
throw err;
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as azExt from 'az-ext';
|
||||
import * as azurecore from 'azurecore';
|
||||
import * as vscode from 'vscode';
|
||||
import { getDatabaseStateDisplayText, promptForInstanceDeletion } from '../../../common/utils';
|
||||
import { ConnectionMode, cssStyles, IconPathHelper, miaaTroubleshootDocsUrl } from '../../../constants';
|
||||
import { cssStyles, IconPathHelper, miaaTroubleshootDocsUrl } from '../../../constants';
|
||||
import * as loc from '../../../localizedConstants';
|
||||
import { ControllerModel } from '../../../models/controllerModel';
|
||||
import { MiaaModel } from '../../../models/miaaModel';
|
||||
@@ -243,16 +243,6 @@ export class MiaaDashboardOverviewPage extends DashboardPage {
|
||||
cancellable: false
|
||||
},
|
||||
async (_progress, _token) => {
|
||||
if (this._controllerModel.info.connectionMode.toLowerCase() === ConnectionMode.direct) {
|
||||
return await this._azApi.az.sql.miarc.delete(
|
||||
this._miaaModel.info.name,
|
||||
{
|
||||
resourceGroup: this._controllerModel.info.resourceGroup,
|
||||
namespace: undefined,
|
||||
},
|
||||
this._controllerModel.azAdditionalEnvVars
|
||||
);
|
||||
} else {
|
||||
return await this._azApi.az.sql.miarc.delete(
|
||||
this._miaaModel.info.name,
|
||||
{
|
||||
@@ -262,7 +252,6 @@ export class MiaaDashboardOverviewPage extends DashboardPage {
|
||||
this._controllerModel.azAdditionalEnvVars
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
await this._controllerModel.refreshTreeNode();
|
||||
vscode.window.showInformationMessage(loc.instanceDeleted(this._miaaModel.info.name));
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as vscode from 'vscode';
|
||||
import * as azdata from 'azdata';
|
||||
import * as azExt from 'az-ext';
|
||||
import * as loc from '../../../localizedConstants';
|
||||
import { IconPathHelper, cssStyles, ConnectionMode } from '../../../constants';
|
||||
import { IconPathHelper, cssStyles } from '../../../constants';
|
||||
import { DashboardPage } from '../../components/dashboardPage';
|
||||
import { ControllerModel } from '../../../models/controllerModel';
|
||||
import { UpgradeSqlMiaa } from '../../dialogs/upgradeSqlMiaa';
|
||||
@@ -160,16 +160,6 @@ export class MiaaUpgradeManagementPage extends DashboardPage {
|
||||
private async getMiaaVersion(): Promise<string | undefined> {
|
||||
try {
|
||||
let miaaShowResult;
|
||||
if (this._controllerModel.info.connectionMode.toLowerCase() === ConnectionMode.direct || this._controllerModel.controllerConfig?.spec.settings.azure.connectionMode.toLowerCase() === ConnectionMode.direct) {
|
||||
miaaShowResult = await this._azApi.az.sql.miarc.show(
|
||||
this._miaaModel.info.name,
|
||||
{
|
||||
resourceGroup: this._controllerModel.info.resourceGroup,
|
||||
namespace: undefined
|
||||
},
|
||||
this._controllerModel.azAdditionalEnvVars
|
||||
);
|
||||
} else {
|
||||
miaaShowResult = await this._azApi.az.sql.miarc.show(
|
||||
this._miaaModel.info.name,
|
||||
{
|
||||
@@ -178,7 +168,6 @@ export class MiaaUpgradeManagementPage extends DashboardPage {
|
||||
},
|
||||
this._controllerModel.azAdditionalEnvVars
|
||||
);
|
||||
}
|
||||
return miaaShowResult.stdout.status.runningVersion;
|
||||
} catch (e) {
|
||||
console.error(loc.showMiaaError, e);
|
||||
@@ -263,29 +252,6 @@ export class MiaaUpgradeManagementPage extends DashboardPage {
|
||||
try {
|
||||
upgradeButton.enabled = false;
|
||||
vscode.window.showInformationMessage(loc.upgradingMiaa('kubectl get sqlmi -A\' should not be localized.'));
|
||||
if (this._controllerModel.info.connectionMode.toLowerCase() === ConnectionMode.direct) {
|
||||
await vscode.window.withProgress(
|
||||
{
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: loc.upgradingDirectMiaa(this._miaaModel.info.name, this._controllerModel.info.resourceGroup),
|
||||
cancellable: true
|
||||
},
|
||||
async (_progress, _token): Promise<void> => {
|
||||
await this._azApi.az.sql.miarc.upgrade(
|
||||
this._miaaModel.info.name,
|
||||
{
|
||||
resourceGroup: this._controllerModel.info.resourceGroup,
|
||||
namespace: undefined
|
||||
}
|
||||
);
|
||||
try {
|
||||
await this._controllerModel.refresh(false, this._controllerModel.info.namespace);
|
||||
} catch (error) {
|
||||
vscode.window.showErrorMessage(loc.refreshFailed(error));
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
await vscode.window.withProgress(
|
||||
{
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
@@ -307,7 +273,6 @@ export class MiaaUpgradeManagementPage extends DashboardPage {
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
@@ -117,9 +117,9 @@ export function getAzApi(localAzDiscovered: Promise<IAzTool | undefined>, azTool
|
||||
delete: async (
|
||||
name: string,
|
||||
args: {
|
||||
// Direct mode arguments
|
||||
// ARM API arguments
|
||||
resourceGroup?: string;
|
||||
// Indirect mode arguments
|
||||
// K8s API arguments
|
||||
namespace?: string;
|
||||
},
|
||||
additionalEnvVars?: azExt.AdditionalEnvVars
|
||||
@@ -130,9 +130,9 @@ export function getAzApi(localAzDiscovered: Promise<IAzTool | undefined>, azTool
|
||||
},
|
||||
list: async (
|
||||
args: {
|
||||
// Direct mode arguments
|
||||
// ARM API arguments
|
||||
resourceGroup?: string;
|
||||
// Indirect mode arguments
|
||||
// K8s API arguments
|
||||
namespace?: string;
|
||||
},
|
||||
additionalEnvVars?: azExt.AdditionalEnvVars
|
||||
@@ -144,9 +144,9 @@ export function getAzApi(localAzDiscovered: Promise<IAzTool | undefined>, azTool
|
||||
show: async (
|
||||
name: string,
|
||||
args: {
|
||||
// Direct mode arguments
|
||||
// ARM API arguments
|
||||
resourceGroup?: string;
|
||||
// Indirect mode arguments
|
||||
// K8s API arguments
|
||||
namespace?: string;
|
||||
},
|
||||
// Additional arguments
|
||||
@@ -166,9 +166,9 @@ export function getAzApi(localAzDiscovered: Promise<IAzTool | undefined>, azTool
|
||||
noWait?: boolean;
|
||||
syncSecondaryToCommit?: string;
|
||||
},
|
||||
// Direct mode arguments
|
||||
// ARM API arguments
|
||||
resourceGroup?: string,
|
||||
// Indirect mode arguments
|
||||
// K8s API arguments
|
||||
namespace?: string,
|
||||
usek8s?: boolean,
|
||||
// Additional arguments
|
||||
@@ -181,9 +181,9 @@ export function getAzApi(localAzDiscovered: Promise<IAzTool | undefined>, azTool
|
||||
upgrade: async (
|
||||
name: string,
|
||||
args: {
|
||||
// Direct mode arguments
|
||||
// ARM API arguments
|
||||
resourceGroup?: string;
|
||||
// Indirect mode arguments
|
||||
// K8s API arguments
|
||||
namespace?: string;
|
||||
},
|
||||
// Additional arguments
|
||||
|
||||
@@ -116,7 +116,7 @@ export class AzTool implements azExt.IAzApi {
|
||||
const argsArray = ['arcdata', 'dc', 'upgrade', '--desired-version', desiredVersion, '--name', name];
|
||||
// Direct mode argument
|
||||
if (resourceGroup) { argsArray.push('--resource-group', resourceGroup); }
|
||||
// Indirect mode arguments
|
||||
// K8s API arguments
|
||||
if (namespace) {
|
||||
argsArray.push('--k8s-namespace', namespace);
|
||||
argsArray.push('--use-k8s');
|
||||
@@ -180,9 +180,9 @@ export class AzTool implements azExt.IAzApi {
|
||||
delete: (
|
||||
name: string,
|
||||
args: {
|
||||
// Direct mode arguments
|
||||
// ARM API arguments
|
||||
resourceGroup?: string,
|
||||
// Indirect mode arguments
|
||||
// K8s API arguments
|
||||
namespace?: string
|
||||
// Additional arguments
|
||||
},
|
||||
@@ -200,9 +200,9 @@ export class AzTool implements azExt.IAzApi {
|
||||
},
|
||||
list: (
|
||||
args: {
|
||||
// Direct mode arguments
|
||||
// ARM API arguments
|
||||
resourceGroup?: string,
|
||||
// Indirect mode arguments
|
||||
// K8s API arguments
|
||||
namespace?: string
|
||||
// Additional arguments
|
||||
},
|
||||
@@ -221,9 +221,9 @@ export class AzTool implements azExt.IAzApi {
|
||||
show: (
|
||||
name: string,
|
||||
args: {
|
||||
// Direct mode arguments
|
||||
// ARM API arguments
|
||||
resourceGroup?: string,
|
||||
// Indirect mode arguments
|
||||
// K8s API arguments
|
||||
namespace?: string
|
||||
// Additional arguments
|
||||
},
|
||||
@@ -250,9 +250,9 @@ export class AzTool implements azExt.IAzApi {
|
||||
retentionDays?: string,
|
||||
syncSecondaryToCommit?: string
|
||||
},
|
||||
// Direct mode arguments
|
||||
// ARM API arguments
|
||||
resourceGroup?: string,
|
||||
// Indirect mode arguments
|
||||
// K8s API arguments
|
||||
namespace?: string,
|
||||
usek8s?: boolean,
|
||||
// Additional arguments
|
||||
@@ -273,9 +273,9 @@ export class AzTool implements azExt.IAzApi {
|
||||
upgrade: (
|
||||
name: string,
|
||||
args: {
|
||||
// Direct mode arguments
|
||||
// ARM API arguments
|
||||
resourceGroup?: string,
|
||||
// Indirect mode arguments
|
||||
// K8s API arguments
|
||||
namespace?: string
|
||||
// Additional arguments
|
||||
},
|
||||
|
||||
20
extensions/azcli/src/typings/az-ext.d.ts
vendored
20
extensions/azcli/src/typings/az-ext.d.ts
vendored
@@ -575,9 +575,9 @@ declare module 'az-ext' {
|
||||
delete(
|
||||
name: string,
|
||||
args: {
|
||||
// Direct mode arguments
|
||||
// ARM API arguments
|
||||
resourceGroup?: string,
|
||||
// Indirect mode arguments
|
||||
// K8s API arguments
|
||||
namespace?: string
|
||||
},
|
||||
// Additional arguments
|
||||
@@ -585,9 +585,9 @@ declare module 'az-ext' {
|
||||
): Promise<AzOutput<void>>,
|
||||
list(
|
||||
args: {
|
||||
// Direct mode arguments
|
||||
// ARM API arguments
|
||||
resourceGroup?: string,
|
||||
// Indirect mode arguments
|
||||
// K8s API arguments
|
||||
namespace?: string
|
||||
},
|
||||
// Additional arguments
|
||||
@@ -596,9 +596,9 @@ declare module 'az-ext' {
|
||||
show(
|
||||
name: string,
|
||||
args: {
|
||||
// Direct mode arguments
|
||||
// ARM API arguments
|
||||
resourceGroup?: string,
|
||||
// Indirect mode arguments
|
||||
// K8s API arguments
|
||||
namespace?: string
|
||||
},
|
||||
// Additional arguments
|
||||
@@ -615,9 +615,9 @@ declare module 'az-ext' {
|
||||
retentionDays?: string, //5
|
||||
syncSecondaryToCommit?: string //2
|
||||
},
|
||||
// Direct mode arguments
|
||||
// ARM API arguments
|
||||
resourceGroup?: string,
|
||||
// Indirect mode arguments
|
||||
// K8s API arguments
|
||||
namespace?: string,
|
||||
usek8s?: boolean,
|
||||
// Additional arguments
|
||||
@@ -626,9 +626,9 @@ declare module 'az-ext' {
|
||||
upgrade(
|
||||
name: string,
|
||||
args: {
|
||||
// Direct mode arguments
|
||||
// ARM API arguments
|
||||
resourceGroup?: string,
|
||||
// Indirect mode arguments
|
||||
// K8s API arguments
|
||||
namespace?: string
|
||||
},
|
||||
// Additional arguments
|
||||
|
||||
Reference in New Issue
Block a user