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:
Candice Ye
2022-08-02 11:12:25 -07:00
committed by GitHub
parent 8f5b3ef81d
commit 5d23627165
9 changed files with 92 additions and 212 deletions

View File

@@ -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 => {

View File

@@ -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,25 +99,14 @@ 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,
{
resourceGroup: undefined,
namespace: this.controllerModel.info.namespace
},
this.controllerModel.azAdditionalEnvVars
);
}
result = await this._azApi.az.sql.miarc.show(
this.info.name,
{
resourceGroup: undefined,
namespace: this.controllerModel.info.namespace
},
this.controllerModel.azAdditionalEnvVars
);
this._config = result.stdout;
this.configLastUpdated = new Date();
this.rpSettings.retentionDays = this._config?.spec?.backup?.retentionPeriodInDays?.toString() ?? '';