mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-12 19:18:32 -05:00
Arc Postgres: Fixes for May release (#10877)
This commit is contained in:
@@ -7,10 +7,10 @@ import * as vscode from 'vscode';
|
||||
import * as azdata from 'azdata';
|
||||
import * as loc from '../../../localizedConstants';
|
||||
import { IconPathHelper, cssStyles } from '../../../constants';
|
||||
import { DuskyObjectModelsDatabase, DuskyObjectModelsDatabaseServiceArcPayload } from '../../../controller/generated/dusky/api';
|
||||
import { DuskyObjectModelsDatabase, DuskyObjectModelsDatabaseServiceArcPayload, V1Pod } from '../../../controller/generated/dusky/api';
|
||||
import { DashboardPage } from '../../components/dashboardPage';
|
||||
import { ControllerModel } from '../../../models/controllerModel';
|
||||
import { PostgresModel } from '../../../models/postgresModel';
|
||||
import { PostgresModel, PodRole } from '../../../models/postgresModel';
|
||||
import { ResourceType } from '../../../common/utils';
|
||||
|
||||
export class PostgresOverviewPage extends DashboardPage {
|
||||
@@ -29,10 +29,16 @@ export class PostgresOverviewPage extends DashboardPage {
|
||||
this._controllerModel.onEndpointsUpdated(() => this.eventuallyRunOnInitialized(() => this.refreshEndpoints()));
|
||||
this._controllerModel.onRegistrationsUpdated(() => this.eventuallyRunOnInitialized(() => this.refreshProperties()));
|
||||
this._postgresModel.onPasswordUpdated(() => this.eventuallyRunOnInitialized(() => this.refreshProperties()));
|
||||
|
||||
this._postgresModel.onServiceUpdated(() => this.eventuallyRunOnInitialized(() => {
|
||||
this.refreshProperties();
|
||||
this.refreshNodes();
|
||||
}));
|
||||
|
||||
this._postgresModel.onPodsUpdated(() => this.eventuallyRunOnInitialized(() => {
|
||||
this.refreshProperties();
|
||||
this.refreshNodes();
|
||||
}));
|
||||
}
|
||||
|
||||
protected get title(): string {
|
||||
@@ -59,7 +65,11 @@ export class PostgresOverviewPage extends DashboardPage {
|
||||
|
||||
// Service endpoints
|
||||
const titleCSS = { ...cssStyles.title, 'margin-block-start': '2em', 'margin-block-end': '0' };
|
||||
content.addItem(this.modelView.modelBuilder.text().withProperties<azdata.TextComponentProperties>({ value: loc.serviceEndpoints, CSSStyles: titleCSS }).component());
|
||||
content.addItem(this.modelView.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
||||
value: loc.serviceEndpoints,
|
||||
CSSStyles: titleCSS
|
||||
}).component());
|
||||
|
||||
this.kibanaLink = this.modelView.modelBuilder.hyperlink().component();
|
||||
this.grafanaLink = this.modelView.modelBuilder.hyperlink().component();
|
||||
this.kibanaLoading = this.modelView.modelBuilder.loadingComponent().withItem(this.kibanaLink).component();
|
||||
@@ -106,7 +116,11 @@ export class PostgresOverviewPage extends DashboardPage {
|
||||
content.addItem(endpointsTable);
|
||||
|
||||
// Server group nodes
|
||||
content.addItem(this.modelView.modelBuilder.text().withProperties<azdata.TextComponentProperties>({ value: loc.serverGroupNodes, CSSStyles: titleCSS }).component());
|
||||
content.addItem(this.modelView.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
|
||||
value: loc.serverGroupNodes,
|
||||
CSSStyles: titleCSS
|
||||
}).component());
|
||||
|
||||
this.nodesTable = this.modelView.modelBuilder.declarativeTable().withProperties<azdata.DeclarativeTableProperties>({
|
||||
width: '100%',
|
||||
columns: [
|
||||
@@ -122,7 +136,15 @@ export class PostgresOverviewPage extends DashboardPage {
|
||||
displayName: loc.type,
|
||||
valueType: azdata.DeclarativeDataType.string,
|
||||
isReadOnly: true,
|
||||
width: '25%',
|
||||
width: '15%',
|
||||
headerCssStyles: cssStyles.tableHeader,
|
||||
rowCssStyles: cssStyles.tableRow
|
||||
},
|
||||
{
|
||||
displayName: loc.status,
|
||||
valueType: azdata.DeclarativeDataType.string,
|
||||
isReadOnly: true,
|
||||
width: '20%',
|
||||
headerCssStyles: cssStyles.tableHeader,
|
||||
rowCssStyles: cssStyles.tableRow
|
||||
},
|
||||
@@ -130,7 +152,7 @@ export class PostgresOverviewPage extends DashboardPage {
|
||||
displayName: loc.fullyQualifiedDomain,
|
||||
valueType: azdata.DeclarativeDataType.string,
|
||||
isReadOnly: true,
|
||||
width: '45%',
|
||||
width: '35%',
|
||||
headerCssStyles: cssStyles.tableHeader,
|
||||
rowCssStyles: cssStyles.tableRow
|
||||
}
|
||||
@@ -159,7 +181,7 @@ export class PostgresOverviewPage extends DashboardPage {
|
||||
if (name === undefined) { return; }
|
||||
const db: DuskyObjectModelsDatabase = { name: name }; // TODO support other options (sharded, owner)
|
||||
await this._postgresModel.createDatabase(db);
|
||||
vscode.window.showInformationMessage(loc.databaseCreated(db.name));
|
||||
vscode.window.showInformationMessage(loc.databaseCreated(db.name ?? ''));
|
||||
} catch (error) {
|
||||
vscode.window.showErrorMessage(loc.databaseCreationFailed(name ?? '', error));
|
||||
} finally {
|
||||
@@ -275,7 +297,7 @@ export class PostgresOverviewPage extends DashboardPage {
|
||||
{ displayName: loc.dataController, value: this._controllerModel?.namespace() ?? '' },
|
||||
{ displayName: loc.nodeConfiguration, value: this._postgresModel.configuration() },
|
||||
{ displayName: loc.subscriptionId, value: registration?.subscriptionId ?? '' },
|
||||
{ displayName: loc.postgresVersion, value: this._postgresModel.service()?.spec.engine.version?.toString() ?? '' }
|
||||
{ displayName: loc.postgresVersion, value: this._postgresModel.service()?.spec?.engine?.version?.toString() ?? '' }
|
||||
];
|
||||
|
||||
this.propertiesLoading!.loading = false;
|
||||
@@ -296,19 +318,22 @@ export class PostgresOverviewPage extends DashboardPage {
|
||||
}
|
||||
|
||||
private refreshNodes() {
|
||||
const nodes = this._postgresModel.numNodes();
|
||||
const endpoint: { ip?: string, port?: number } = this._postgresModel.endpoint();
|
||||
|
||||
const data: any[][] = [];
|
||||
for (let i = 0; i < nodes; i++) {
|
||||
data.push([
|
||||
`${this._postgresModel.name()}-${i}`,
|
||||
i === 0 ? loc.coordinatorEndpoint : loc.worker,
|
||||
i === 0 ? `${endpoint.ip}:${endpoint.port}` :
|
||||
`${this._postgresModel.name()}-${i}.${this._postgresModel.name()}-svc.${this._postgresModel.namespace()}.svc.cluster.local`]);
|
||||
}
|
||||
this.nodesTable!.data = this._postgresModel.pods()?.map((pod: V1Pod) => {
|
||||
const name = pod.metadata?.name;
|
||||
const role: PodRole | undefined = PostgresModel.getPodRole(pod);
|
||||
const service = pod.metadata?.annotations?.['arcdata.microsoft.com/serviceHost'];
|
||||
const internalDns = service ? `${name}.${service}` : '';
|
||||
|
||||
return [
|
||||
name,
|
||||
PostgresModel.getPodRoleName(role),
|
||||
PostgresModel.getPodStatus(pod),
|
||||
role === PodRole.Router ? `${endpoint.ip}:${endpoint.port}` : internalDns
|
||||
];
|
||||
}) ?? [];
|
||||
|
||||
this.nodesTable!.data = data;
|
||||
this.nodesTableLoading!.loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user