Fixed SqlMiShowResult to be up to date (#19319)

* Fixed SqlMiShowResult to be up to date

* Bumped versions of azcli and arc up to 1.2.1 for bug bash

Co-authored-by: Candice Ye <canye@microsoft.com>
This commit is contained in:
Candice Ye
2022-05-09 18:38:44 -07:00
committed by GitHub
parent 75ab9b6812
commit 2312bed4ad
11 changed files with 217 additions and 60 deletions

View File

@@ -2,7 +2,7 @@
"name": "arc",
"displayName": "%arc.displayName%",
"description": "%arc.description%",
"version": "1.2.0",
"version": "1.2.1",
"publisher": "Microsoft",
"license": "https://raw.githubusercontent.com/Microsoft/azuredatastudio/main/LICENSE.txt",
"icon": "images/extension.png",

View File

@@ -121,7 +121,7 @@ export class MiaaModel extends ResourceModel {
}
this._config = result.stdout;
this.configLastUpdated = new Date();
this.rpSettings.retentionDays = this._config?.spec?.backup?.retentionPeriodInDays?.toString() ?? '';
this.rpSettings.retentionDays = this._config?.properties?.k8SRaw?.spec?.backup?.retentionPeriodInDays?.toString() ?? '';
this._onConfigUpdated.fire(this._config);
this._onDatabasesUpdated.fire(this._databases);
} catch (err) {
@@ -135,7 +135,7 @@ export class MiaaModel extends ResourceModel {
}
// If we have an external endpoint configured then fetch the databases now
if (this._config.status.primaryEndpoint) {
if (this._config.properties?.k8SRaw?.status.primaryEndpoint) {
this.getDatabases(false).catch(_err => {
// If an error occurs still fire the event so callers can know to
// update (e.g. so dashboards don't show the loading icon forever)
@@ -217,7 +217,7 @@ export class MiaaModel extends ResourceModel {
}
protected createConnectionProfile(): azdata.IConnectionProfile {
const ipAndPort = parseIpAndPort(this.config?.status.primaryEndpoint || '');
const ipAndPort = parseIpAndPort(this.config?.properties?.k8SRaw?.status.primaryEndpoint || '');
return {
serverName: `${ipAndPort.ip},${ipAndPort.port}`,
databaseName: '',

View File

@@ -288,7 +288,7 @@ export class MiaaBackupsPage extends DashboardPage {
} else {
// If we don't have an endpoint then there's no point in showing the connect button - but the logic
// to display text informing the user of this is already handled by the handleMiaaConfigUpdated
if (this._miaaModel?.config?.status.primaryEndpoint) {
if (this._miaaModel?.config?.properties?.k8SRaw?.status.primaryEndpoint) {
this._connectToServerLoading.loading = false;
this._connectToServerButton.enabled = true;
}
@@ -296,7 +296,7 @@ export class MiaaBackupsPage extends DashboardPage {
}
private refreshRD(): void {
this._saveArgs.retentionDays = this._miaaModel.config?.spec?.backup?.retentionPeriodInDays.toString() ?? '';
this._saveArgs.retentionDays = this._miaaModel.config?.properties?.k8SRaw?.spec?.backup?.retentionPeriodInDays.toString() ?? '';
}
// Create restore button for every database entry in the database table

View File

@@ -330,7 +330,7 @@ export class MiaaComputeAndStoragePage extends DashboardPage {
}
private editCores(): void {
let currentCPUSize = this._miaaModel.config?.spec?.scheduling?.default?.resources?.requests?.cpu;
let currentCPUSize = this._miaaModel.config?.properties?.k8SRaw?.spec?.scheduling?.default?.resources?.requests?.cpu;
if (!currentCPUSize) {
currentCPUSize = '';
@@ -340,7 +340,7 @@ export class MiaaComputeAndStoragePage extends DashboardPage {
this.coresRequestBox!.value = '';
this.saveArgs.coresRequest = undefined;
currentCPUSize = this._miaaModel.config?.spec?.scheduling?.default?.resources?.limits?.cpu;
currentCPUSize = this._miaaModel.config?.properties?.k8SRaw?.spec?.scheduling?.default?.resources?.limits?.cpu;
if (!currentCPUSize) {
currentCPUSize = '';
@@ -353,7 +353,7 @@ export class MiaaComputeAndStoragePage extends DashboardPage {
private editMemory(): void {
let currentMemSizeConversion: string;
let currentMemorySize = this._miaaModel.config?.spec?.scheduling?.default?.resources?.requests?.memory;
let currentMemorySize = this._miaaModel.config?.properties?.k8SRaw?.spec?.scheduling?.default?.resources?.requests?.memory;
if (!currentMemorySize) {
currentMemSizeConversion = '';
@@ -366,7 +366,7 @@ export class MiaaComputeAndStoragePage extends DashboardPage {
this.saveArgs.memoryRequest = undefined;
currentMemorySize = this._miaaModel.config?.spec?.scheduling?.default?.resources?.limits?.memory;
currentMemorySize = this._miaaModel.config?.properties?.k8SRaw?.spec?.scheduling?.default?.resources?.limits?.memory;
if (!currentMemorySize) {
currentMemSizeConversion = '';

View File

@@ -74,11 +74,11 @@ export class MiaaConnectionStringsPage extends DashboardPage {
private getConnectionStrings(): KeyValue[] {
const config = this._miaaModel.config;
if (!config?.status.primaryEndpoint) {
if (!config?.properties?.k8SRaw?.status.primaryEndpoint) {
return [];
}
const externalEndpoint = parseIpAndPort(config.status.primaryEndpoint);
const externalEndpoint = parseIpAndPort(config.properties?.k8SRaw?.status.primaryEndpoint);
const username = this._miaaModel.username ?? '{your_username_here}';
return [
@@ -97,7 +97,7 @@ $conn = sqlsrv_connect($serverName, $connectionInfo);`),
}
private updateConnectionStrings(): void {
this._connectionStringsMessage.value = !this._miaaModel.config?.status.primaryEndpoint ? loc.noExternalEndpoint : '';
this._connectionStringsMessage.value = !this._miaaModel.config?.properties?.k8SRaw?.status.primaryEndpoint ? loc.noExternalEndpoint : '';
this._keyValueContainer.refresh(this.getConnectionStrings());
}
}

View File

@@ -335,11 +335,11 @@ export class MiaaDashboardOverviewPage extends DashboardPage {
private handleMiaaConfigUpdated(): void {
if (this._miaaModel.config) {
this._instanceProperties.status = this._miaaModel.config.status.state || '-';
this._instanceProperties.externalEndpoint = this._miaaModel.config.status.primaryEndpoint || loc.notConfigured;
this._instanceProperties.vCores = this._miaaModel.config.spec.scheduling?.default?.resources?.limits?.cpu?.toString() || '';
this._databasesMessage.value = !this._miaaModel.config.status.primaryEndpoint ? loc.noExternalEndpoint : '';
if (!this._miaaModel.config.status.primaryEndpoint) {
this._instanceProperties.status = this._miaaModel.config.properties?.k8SRaw?.status.state || '-';
this._instanceProperties.externalEndpoint = this._miaaModel.config.properties?.k8SRaw?.status.primaryEndpoint || loc.notConfigured;
this._instanceProperties.vCores = this._miaaModel.config.properties?.k8SRaw?.spec?.scheduling?.default?.resources?.limits?.cpu?.toString() || '';
this._databasesMessage.value = !this._miaaModel.config.properties?.k8SRaw?.status.primaryEndpoint ? loc.noExternalEndpoint : '';
if (!this._miaaModel.config.properties?.k8SRaw?.status.primaryEndpoint) {
this._databasesContainer.removeItem(this._connectToServerLoading);
}
}
@@ -368,7 +368,7 @@ export class MiaaDashboardOverviewPage extends DashboardPage {
} else {
// If we don't have an endpoint then there's no point in showing the connect button - but the logic
// to display text informing the user of this is already handled by the handleMiaaConfigUpdated
if (this._miaaModel?.config?.status.primaryEndpoint) {
if (this._miaaModel?.config?.properties?.k8SRaw?.status.primaryEndpoint) {
this._connectToServerLoading.loading = false;
this._connectToServerButton.enabled = true;
}
@@ -419,12 +419,12 @@ export class MiaaDashboardOverviewPage extends DashboardPage {
private refreshDashboardLinks(): void {
if (this._miaaModel.config) {
const kibanaUrl = this._miaaModel.config.status.logSearchDashboard ?? '';
const kibanaUrl = this._miaaModel.config.properties?.k8SRaw?.status.logSearchDashboard ?? '';
this._kibanaLink.label = kibanaUrl;
this._kibanaLink.url = kibanaUrl;
this._kibanaLoading!.loading = false;
const grafanaUrl = this._miaaModel.config.status.metricsDashboard ?? '';
const grafanaUrl = this._miaaModel.config.properties?.k8SRaw?.status.metricsDashboard ?? '';
this._grafanaLink.label = grafanaUrl;
this._grafanaLink.url = grafanaUrl;
this._grafanaLoading!.loading = false;

View File

@@ -179,7 +179,7 @@ export class MiaaUpgradeManagementPage extends DashboardPage {
this._controllerModel.azAdditionalEnvVars
);
}
return miaaShowResult.stdout.status.runningVersion;
return miaaShowResult.stdout.properties.k8SRaw.status.runningVersion;
} catch (e) {
console.error(loc.showMiaaError, e);
return undefined;

View File

@@ -26,7 +26,7 @@ export class ConfigureRPOSqlDialog extends InitializingComponent {
public showDialog(dialogTitle: string, retentionDays: string | undefined): azdata.window.Dialog {
const dialog = azdata.window.createModelViewDialog(dialogTitle);
dialog.cancelButton.onClick(() => this.handleCancel());
retentionDays = (retentionDays === undefined ? this._model.config?.spec?.backup?.retentionPeriodInDays?.toString() : retentionDays);
retentionDays = (retentionDays === undefined ? this._model.config?.properties?.k8SRaw?.spec?.backup?.retentionPeriodInDays?.toString() : retentionDays);
dialog.registerContent(async view => {
this.modelBuilder = view.modelBuilder;
this.retentionDaysInputBox = this.modelBuilder.inputBox()

View File

@@ -303,7 +303,7 @@ export class RestoreSqlDialog extends InitializingComponent {
}
public refreshPitrSettings(): void {
this.pitrSettings.instanceName = this._miaaModel?.config?.metadata.name || this.pitrSettings.instanceName;
this.pitrSettings.instanceName = this._miaaModel?.config?.name || this.pitrSettings.instanceName;
this.pitrSettings.resourceGroupName = this._controllerModel?.controllerConfig?.spec.settings.azure.resourceGroup || this.pitrSettings.resourceGroupName;
this.pitrSettings.location = this._azurecoreApi.getRegionDisplayName(this._controllerModel?.controllerConfig?.spec.settings.azure.location) || this.pitrSettings.location;
this.pitrSettings.subscriptionId = this._controllerModel?.controllerConfig?.spec.settings.azure.subscription || this.pitrSettings.subscriptionId;

View File

@@ -2,7 +2,7 @@
"name": "azcli",
"displayName": "%azcli.arc.displayName%",
"description": "%azcli.arc.description%",
"version": "1.2.0",
"version": "1.2.1",
"publisher": "Microsoft",
"license": "https://raw.githubusercontent.com/Microsoft/azuredatastudio/main/LICENSE.txt",
"icon": "images/extension.png",

View File

@@ -137,51 +137,208 @@ declare module 'az-ext' {
port?: number // 5432
}
// export interface SqlMiShowResult {
// apiVersion: string, // "sql.arcdata.microsoft.com/v1alpha1"
// kind: string, // "sqlmanagedinstance"
// metadata: {
// creationTimestamp: string, // "2020-08-19T17:35:45Z"
// generation: number, // 1
// name: string, // "miaa-instance"
// namespace: string, // "arc"
// resourceVersion: string, // "202623"
// selfLink: string, // "/apis/sql.arcdata.microsoft.com/v1alpha1/namespaces/arc/sqlmanagedinstances/miaa-instance"
// uid: string // "cea737aa-3f82-4f6a-9bed-2b51c2c33dff"
// },
// spec: {
// backup?: {
// retentionPeriodInDays: number, // 1
// }
// scheduling?: {
// default?: {
// resources?: {
// limits?: SchedulingOptions,
// requests?: SchedulingOptions
// }
// }
// }
// services: {
// primary: ServiceSpec
// }
// storage: {
// data: {
// volumes: StorageVolume[]
// },
// logs: {
// volumes: StorageVolume[]
// }
// }
// },
// status: {
// readyReplicas: string, // "1/1"
// state: string, // "Ready",
// logSearchDashboard: string, // https://127.0.0.1:30777/kibana/app/kibana#/discover?_a=(query:(language:kuery,query:'custom_resource_name:miaa1'))
// metricsDashboard: string, // https://127.0.0.1:30777/grafana/d/40q72HnGk/sql-managed-instance-metrics?var-hostname=miaa1-0
// primaryEndpoint?: string // "10.91.86.39:32718"
// runningVersion: string // "v1.5.0_2022-04-05"
// }
// }
export interface SqlMiShowResult {
apiVersion: string, // "sql.arcdata.microsoft.com/v1alpha1"
kind: string, // "sqlmanagedinstance"
metadata: {
creationTimestamp: string, // "2020-08-19T17:35:45Z"
generation: number, // 1
name: string, // "miaa-instance"
namespace: string, // "arc"
resourceVersion: string, // "202623"
selfLink: string, // "/apis/sql.arcdata.microsoft.com/v1alpha1/namespaces/arc/sqlmanagedinstances/miaa-instance"
uid: string // "cea737aa-3f82-4f6a-9bed-2b51c2c33dff"
extendedLocation: {
name: string, // /subscriptions/a2382b66-3h2k-3h2k-2gdd-8ef45dgfdc33/resourcegroups/name-rg/providers/microsoft.extendedlocation/customlocations/custom-loc,
type: string, // CustomLocation
},
spec: {
backup?: {
retentionPeriodInDays: number, // 1
}
scheduling?: {
default?: {
resources?: {
limits?: SchedulingOptions,
requests?: SchedulingOptions
id: string, // /subscriptions/a2382b66-3h2k-3h2k-2gdd-8ef45dgfdc33/resourceGroups/name-rg/providers/Microsoft.AzureArcData/sqlManagedInstances/sql1,
location: string, // eastus2,
name: string, // sql2,
properties: {
activeDirectoryInformation: string, // null,
admin: string, // admin,
basicLoginInformation: string, // null,
clusterId: string, // null,
dataControllerId: string, // dc-name,
endTime: string, // null,
extensionId: string, // null,
k8SRaw: {
spec: {
backup: {
retentionPeriodInDays: number, // 7
},
dev: boolean, // true,
licenseType: string, // BasePrice,
metadata: {
annotations: string, // ,
labels: string, // ,
namespace: string, // namespace-name
},
replicas: number, // 1,
scheduling: {
additionalProperties: string, // null,
default: {
additionalProperties: string, // null,
resources: {
additionalProperties: string, // null,
limits: {
cpu: string, // 4,
memory: string, // 8Gi
},
requests: {
cpu: string, // 2,
memory: string, // 4Gi
}
}
}
}
services: {
primary: ServiceSpec
}
storage: {
},
security: {
adminLoginSecret: string, // sql-login-secret,
serviceCertificateSecret: string, //
},
services: {
primary: {
annotations: string, // ,
labels: string, // ,
type: string, // NodePort
}
},
settings: {
collation: string, // SQL_Latin1_General_CP1_CI_AS,
language: {
lcid: number, // 1234
},
sqlagent: {
enabled: boolean, // false
},
timezone: string, // UTC,
traceFlags: boolean, // false
},
storage: {
backups: {
volumes: [
{
annotations: string, // ,
className: string, // azurefile,
labels: string, // ,
size: string, // 5Gi
}
]
},
data: {
volumes: StorageVolume[]
volumes: [
{
annotations: string, // ,
className: string, // default,
labels: string, // ,
size: string, // 5Gi
}
]
},
datalogs: {
volumes: [
{
annotations: string, // ,
className: string, // default,
labels: string, // ,
size: string, // 5Gi
}
]
},
logs: {
volumes: StorageVolume[]
volumes: [
{
annotations: string, // ,
className: string, // default,
labels: string, // ,
size: string, // 5Gi
}
]
}
},
tier: string, // GeneralPurpose
},
status: {
endpoints: {
logSearchDashboard: string, // https://localhost:12345/app/kibana#/discover?_a=(query:(language:kuery,query:'custom_resource_name:sql1')),
metricsDashboard: string, // https://12.123.1.4:12345/d/sdfgwseg/sql-managed-instance-metrics?var-hostname=sql1-0,
mirroring: string, // 10.224.0.4:32040,
primary: string, // 10.224.0.4,32477
},
highAvailability: {
lastUpdateTime: string, // 2022-05-09T23:40:19.626856Z,
mirroringCertificate: string,
},
lastUpdateTime: string, // 2022-05-09T23:41:00.137919Z,
logSearchDashboard: string,
metricsDashboard: string,
observedGeneration: number, // 1,
primaryEndpoint: string, // 10.224.0.4,32477,
readyReplicas: string, // 1/1,
roles: {
sql: {
lastUpdateTime: string, // 2022-05-09T23:39:53.364002Z,
readyReplicas: number, // 1,
replicas: number, // 1
}
},
runningVersion: string, // v1.4.0_2022-02-25,
state: string, // Ready
}
},
lastUploadedDate: string, // null,
licenseType: string, // BasePrice,
provisioningState: string, // Succeeded,
startTime: string, // null
},
status: {
readyReplicas: string, // "1/1"
state: string, // "Ready",
logSearchDashboard: string, // https://127.0.0.1:30777/kibana/app/kibana#/discover?_a=(query:(language:kuery,query:'custom_resource_name:miaa1'))
metricsDashboard: string, // https://127.0.0.1:30777/grafana/d/40q72HnGk/sql-managed-instance-metrics?var-hostname=miaa1-0
primaryEndpoint?: string // "10.91.86.39:32718"
runningVersion: string // "v1.5.0_2022-04-05"
}
}
resourceGroup: string, // rg-name,
sku: {
capacity: string, // null,
dev: string, // null,
family: string, // null,
size: string, // null,
tier: string, // GeneralPurpose
},
tags: {},
type: string, // microsoft.azurearcdata/sqlmanagedinstances
}
export interface SqlMiDbRestoreResult {
destDatabase: string, //testDbToRestore