Fixes for Arc Postgres (#11012)

This commit is contained in:
Brian Bergeron
2020-06-21 16:02:55 -07:00
committed by GitHub
parent 87a7c659f2
commit 06058d8925
9 changed files with 120 additions and 68 deletions

View File

@@ -17,7 +17,6 @@ export class PostgresConnectionStringsPage extends DashboardPage {
constructor(protected modelView: azdata.ModelView, private _postgresModel: PostgresModel) {
super(modelView);
this._postgresModel.onServiceUpdated(() => this.eventuallyRunOnInitialized(() => this.refresh()));
this._postgresModel.onPasswordUpdated(() => this.eventuallyRunOnInitialized(() => this.refresh()));
}
protected get title(): string {
@@ -43,18 +42,19 @@ export class PostgresConnectionStringsPage extends DashboardPage {
}).component());
const info = this.modelView.modelBuilder.text().withProperties<azdata.TextComponentProperties>({
value: `${loc.selectConnectionString}.&nbsp;`,
value: loc.selectConnectionString,
CSSStyles: { ...cssStyles.text, 'margin-block-start': '0px', 'margin-block-end': '0px' }
}).component();
const link = this.modelView.modelBuilder.hyperlink().withProperties<azdata.HyperlinkComponentProperties>({
label: loc.learnAboutPostgresClients,
url: 'http://example.com', // TODO link to documentation
url: 'https://docs.microsoft.com/azure/postgresql/concepts-connection-libraries',
}).component();
content.addItem(
this.modelView.modelBuilder.flexContainer().withItems([info, link]).withLayout({ flexWrap: 'wrap' }).component(),
{ CSSStyles: { display: 'inline-flex', 'margin-bottom': '25px' } });
const infoAndLink = this.modelView.modelBuilder.flexContainer().withLayout({ flexWrap: 'wrap' }).component();
infoAndLink.addItem(info, { CSSStyles: { 'margin-right': '5px' } });
infoAndLink.addItem(link);
content.addItem(infoAndLink, { CSSStyles: { 'margin-bottom': '25px' } });
this.keyValueContainer = new KeyValueContainer(this.modelView.modelBuilder, []);
content.addItem(this.keyValueContainer.container);

View File

@@ -9,11 +9,8 @@ import * as loc from '../../../localizedConstants';
import { ControllerModel } from '../../../models/controllerModel';
import { PostgresModel } from '../../../models/postgresModel';
import { PostgresOverviewPage } from './postgresOverviewPage';
import { PostgresComputeStoragePage } from './postgresComputeStoragePage';
import { PostgresConnectionStringsPage } from './postgresConnectionStringsPage';
import { PostgresBackupPage } from './postgresBackupPage';
import { PostgresPropertiesPage } from './postgresPropertiesPage';
import { PostgresNetworkingPage } from './postgresNetworkingPage';
import { Dashboard } from '../../components/dashboard';
import { PostgresDiagnoseAndSolveProblemsPage } from './postgresDiagnoseAndSolveProblemsPage';
import { PostgresSupportRequestPage } from './postgresSupportRequestPage';
@@ -25,11 +22,8 @@ export class PostgresDashboard extends Dashboard {
protected async registerTabs(modelView: azdata.ModelView): Promise<(azdata.DashboardTab | azdata.DashboardTabGroup)[]> {
const overviewPage = new PostgresOverviewPage(modelView, this._controllerModel, this._postgresModel);
const computeStoragePage = new PostgresComputeStoragePage(modelView);
const connectionStringsPage = new PostgresConnectionStringsPage(modelView, this._postgresModel);
const backupPage = new PostgresBackupPage(modelView);
const propertiesPage = new PostgresPropertiesPage(modelView, this._controllerModel, this._postgresModel);
const networkingPage = new PostgresNetworkingPage(modelView);
const diagnoseAndSolveProblemsPage = new PostgresDiagnoseAndSolveProblemsPage(modelView, this._context, this._postgresModel);
const supportRequestPage = new PostgresSupportRequestPage(modelView, this._controllerModel, this._postgresModel);
@@ -38,16 +32,9 @@ export class PostgresDashboard extends Dashboard {
{
title: loc.settings,
tabs: [
computeStoragePage.tab,
connectionStringsPage.tab,
backupPage.tab,
propertiesPage.tab
]
}, {
title: loc.security,
tabs: [
networkingPage.tab
]
},
{
title: loc.supportAndTroubleshooting,

View File

@@ -51,7 +51,7 @@ export class PostgresDiagnoseAndSolveProblemsPage extends DashboardPage {
troubleshootButton.onDidClick(() => {
process.env['POSTGRES_SERVER_NAMESPACE'] = this._postgresModel.namespace;
process.env['POSTGRES_SERVER_NAME'] = this._postgresModel.name;
vscode.commands.executeCommand('bookTreeView.openBook', this._context.asAbsolutePath('notebooks/arc'), true, 'postgres/tsg100-troubleshoot-postgres');
vscode.commands.executeCommand('bookTreeView.openBook', this._context.asAbsolutePath('notebooks/arcDataServices'), true, 'postgres/tsg100-troubleshoot-postgres');
});
content.addItem(troubleshootButton);

View File

@@ -7,11 +7,11 @@ import * as vscode from 'vscode';
import * as azdata from 'azdata';
import * as loc from '../../../localizedConstants';
import { IconPathHelper, cssStyles, ResourceType } from '../../../constants';
import { DuskyObjectModelsDatabase, DuskyObjectModelsDatabaseServiceArcPayload, V1Pod } from '../../../controller/generated/dusky/api';
import { DuskyObjectModelsDatabase, V1Pod, DuskyObjectModelsDatabaseServiceArcPayload } from '../../../controller/generated/dusky/api';
import { DashboardPage } from '../../components/dashboardPage';
import { ControllerModel } from '../../../models/controllerModel';
import { PostgresModel, PodRole } from '../../../models/postgresModel';
import { promptForResourceDeletion } from '../../../common/utils';
import { promptForResourceDeletion, promptAndConfirmPassword } from '../../../common/utils';
export class PostgresOverviewPage extends DashboardPage {
private propertiesLoading?: azdata.LoadingComponent;
@@ -28,7 +28,6 @@ export class PostgresOverviewPage extends DashboardPage {
super(modelView);
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();
@@ -178,10 +177,11 @@ export class PostgresOverviewPage extends DashboardPage {
let name;
try {
name = await vscode.window.showInputBox({ prompt: loc.databaseName });
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 ?? ''));
if (name) {
const db: DuskyObjectModelsDatabase = { name: name }; // TODO support other options (sharded, owner)
await this._postgresModel.createDatabase(db);
vscode.window.showInformationMessage(loc.databaseCreated(db.name ?? ''));
}
} catch (error) {
vscode.window.showErrorMessage(loc.databaseCreationFailed(name ?? '', error));
} finally {
@@ -198,15 +198,16 @@ export class PostgresOverviewPage extends DashboardPage {
resetPasswordButton.onDidClick(async () => {
resetPasswordButton.enabled = false;
try {
const password = await vscode.window.showInputBox({ prompt: loc.newPassword, password: true });
if (password === undefined) { return; }
await this._postgresModel.update(s => {
s.arc = s.arc ?? new DuskyObjectModelsDatabaseServiceArcPayload();
s.arc.servicePassword = password;
});
vscode.window.showInformationMessage(loc.passwordReset(this._postgresModel.fullName));
const password = await promptAndConfirmPassword(input => !input ? loc.enterANonEmptyPassword : '');
if (password) {
await this._postgresModel.update(s => {
s.arc = s.arc ?? new DuskyObjectModelsDatabaseServiceArcPayload();
s.arc.servicePassword = password;
});
vscode.window.showInformationMessage(loc.passwordReset);
}
} catch (error) {
vscode.window.showErrorMessage(loc.passwordResetFailed(this._postgresModel.fullName, error));
vscode.window.showErrorMessage(loc.passwordResetFailed);
} finally {
resetPasswordButton.enabled = true;
}
@@ -289,7 +290,7 @@ export class PostgresOverviewPage extends DashboardPage {
this.properties!.propertyItems = [
{ displayName: loc.name, value: this._postgresModel.name },
{ displayName: loc.coordinatorEndpoint, value: `postgresql://postgres:${this._postgresModel.password}@${endpoint.ip}:${endpoint.port}` },
{ displayName: loc.coordinatorEndpoint, value: `postgresql://postgres@${endpoint.ip}:${endpoint.port}` },
{ displayName: loc.status, value: this._postgresModel.service?.status?.state ?? '' },
{ displayName: loc.postgresAdminUsername, value: 'postgres' },
{ displayName: loc.dataController, value: this._controllerModel?.namespace ?? '' },

View File

@@ -18,7 +18,6 @@ export class PostgresPropertiesPage extends DashboardPage {
constructor(protected modelView: azdata.ModelView, private _controllerModel: ControllerModel, private _postgresModel: PostgresModel) {
super(modelView);
this._postgresModel.onServiceUpdated(() => this.eventuallyRunOnInitialized(() => this.refresh()));
this._postgresModel.onPasswordUpdated(() => this.eventuallyRunOnInitialized(() => this.refresh()));
this._controllerModel.onRegistrationsUpdated(() => this.eventuallyRunOnInitialized(() => this.refresh()));
}
@@ -78,7 +77,7 @@ export class PostgresPropertiesPage extends DashboardPage {
private refresh() {
const endpoint: { ip?: string, port?: number } = this._postgresModel.endpoint;
const connectionString = `postgresql://postgres:${this._postgresModel.password}@${endpoint.ip}:${endpoint.port}`;
const connectionString = `postgresql://postgres@${endpoint.ip}:${endpoint.port}`;
const registration = this._controllerModel.getRegistration(ResourceType.postgresInstances, this._postgresModel.namespace, this._postgresModel.name);
this.keyValueContainer?.refresh([
@@ -86,7 +85,7 @@ export class PostgresPropertiesPage extends DashboardPage {
new InputKeyValue(loc.postgresAdminUsername, 'postgres'),
new TextKeyValue(loc.status, this._postgresModel.service?.status?.state ?? 'Unknown'),
new LinkKeyValue(loc.dataController, this._controllerModel.namespace ?? '', _ => vscode.window.showInformationMessage('TODO: Go to data controller')),
new LinkKeyValue(loc.nodeConfiguration, this._postgresModel.configuration, _ => vscode.window.showInformationMessage('TODO: Go to configuration')),
new TextKeyValue(loc.nodeConfiguration, this._postgresModel.configuration),
new TextKeyValue(loc.postgresVersion, this._postgresModel.service?.spec?.engine?.version?.toString() ?? ''),
new TextKeyValue(loc.resourceGroup, registration?.resourceGroupName ?? ''),
new TextKeyValue(loc.subscriptionId, registration?.subscriptionId ?? '')