From ffbb1b3917578ad23431b25ae04c022b77989a0f Mon Sep 17 00:00:00 2001 From: Brian Bergeron Date: Fri, 18 Sep 2020 19:34:56 -0700 Subject: [PATCH] Arc Postgres - Add Azure params to overview page, update notebook (#12482) * add azure params to pg overview page, update troubelshooting notebook, string changes * no default pg version for notebook Co-authored-by: Brian Bergeron --- .../notebooks/arcDataServices/_data/toc.yml | 2 +- .../content/postgres/readme.md | 2 +- .../arcDataServices/content/postgres/toc.yml | 2 +- .../tsg100-troubleshoot-postgres.ipynb | 30 ++++++++-------- extensions/arc/package.nls.json | 6 ++-- extensions/arc/src/localizedConstants.ts | 1 + .../postgres/postgresConnectionStringsPage.ts | 34 ++----------------- .../dashboards/postgres/postgresDashboard.ts | 7 ++-- .../postgres/postgresOverviewPage.ts | 19 ++++++----- .../postgres/postgresPropertiesPage.ts | 3 +- 10 files changed, 41 insertions(+), 65 deletions(-) diff --git a/extensions/arc/notebooks/arcDataServices/_data/toc.yml b/extensions/arc/notebooks/arcDataServices/_data/toc.yml index 08aa620181..8648d839fb 100644 --- a/extensions/arc/notebooks/arcDataServices/_data/toc.yml +++ b/extensions/arc/notebooks/arcDataServices/_data/toc.yml @@ -8,5 +8,5 @@ not_numbered: true expand_sections: true sections: - - title: TSG100 - The Azure Arc Postgres troubleshooter + - title: TSG100 - The Azure Arc enabled PostgreSQL Hyperscale troubleshooter url: postgres/tsg100-troubleshoot-postgres diff --git a/extensions/arc/notebooks/arcDataServices/content/postgres/readme.md b/extensions/arc/notebooks/arcDataServices/content/postgres/readme.md index a3fe0eee38..f374526c4b 100644 --- a/extensions/arc/notebooks/arcDataServices/content/postgres/readme.md +++ b/extensions/arc/notebooks/arcDataServices/content/postgres/readme.md @@ -3,5 +3,5 @@ - This chapter contains notebooks for troubleshooting Postgres on Azure Arc ## Notebooks in this Chapter -- [TSG100 - The Azure Arc Postgres troubleshooter](tsg100-troubleshoot-postgres.ipynb) +- [TSG100 - The Azure Arc enabled PostgreSQL Hyperscale troubleshooter](tsg100-troubleshoot-postgres.ipynb) diff --git a/extensions/arc/notebooks/arcDataServices/content/postgres/toc.yml b/extensions/arc/notebooks/arcDataServices/content/postgres/toc.yml index cf63274703..71298e6fc7 100644 --- a/extensions/arc/notebooks/arcDataServices/content/postgres/toc.yml +++ b/extensions/arc/notebooks/arcDataServices/content/postgres/toc.yml @@ -3,5 +3,5 @@ not_numbered: true expand_sections: true sections: - - title: TSG100 - The Azure Arc Postgres troubleshooter + - title: TSG100 - The Azure Arc enabled PostgreSQL Hyperscale troubleshooter url: postgres/tsg100-troubleshoot-postgres diff --git a/extensions/arc/notebooks/arcDataServices/content/postgres/tsg100-troubleshoot-postgres.ipynb b/extensions/arc/notebooks/arcDataServices/content/postgres/tsg100-troubleshoot-postgres.ipynb index a0ac270ea8..8a7c7af4fb 100644 --- a/extensions/arc/notebooks/arcDataServices/content/postgres/tsg100-troubleshoot-postgres.ipynb +++ b/extensions/arc/notebooks/arcDataServices/content/postgres/tsg100-troubleshoot-postgres.ipynb @@ -4,13 +4,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "TSG100 - The Azure Arc Postgres troubleshooter\n", - "==============================================\n", + "TSG100 - The Azure Arc enabled PostgreSQL Hyperscale troubleshooter\n", + "===================================================================\n", "\n", "Description\n", "-----------\n", "\n", - "Follow these steps to troubleshoot an Azure Arc Postgres Server.\n", + "Follow these steps to troubleshoot an Azure Arc enabled PostgreSQL\n", + "Hyperscale Server.\n", "\n", "Steps\n", "-----\n", @@ -34,6 +35,7 @@ "# the user will be prompted to select a server.\n", "namespace = os.environ.get('POSTGRES_SERVER_NAMESPACE')\n", "name = os.environ.get('POSTGRES_SERVER_NAME')\n", + "version = os.environ.get('POSTGRES_SERVER_VERSION')\n", "\n", "tail_lines = 50" ] @@ -143,7 +145,7 @@ " if cmd.startswith(\"kubectl \") and \"AZDATA_OPENSHIFT\" in os.environ:\n", " cmd_actual[0] = cmd_actual[0].replace(\"kubectl\", \"oc\")\n", "\n", - " # To aid supportabilty, determine which binary file will actually be executed on the machine\n", + " # To aid supportability, determine which binary file will actually be executed on the machine\n", " #\n", " which_binary = None\n", "\n", @@ -400,11 +402,11 @@ "import math\n", "\n", "# If a server was provided, get it\n", - "if namespace and name:\n", - " server = json.loads(run(f'kubectl get dbs -n {namespace} {name} -o json', return_output=True))\n", + "if namespace and name and version:\n", + " server = json.loads(run(f'kubectl get postgresql-{version} -n {namespace} {name} -o json', return_output=True))\n", "else:\n", " # Otherwise prompt the user to select a server\n", - " servers = json.loads(run(f'kubectl get dbs --all-namespaces -o json', return_output=True))['items']\n", + " servers = json.loads(run(f'kubectl get postgresqls --all-namespaces -o json', return_output=True))['items']\n", " if not servers:\n", " raise Exception('No Postgres servers found')\n", "\n", @@ -425,6 +427,7 @@ " server = servers[i-1]\n", " namespace = server['metadata']['namespace']\n", " name = server['metadata']['name']\n", + " version = server['kind'][len('postgresql-'):]\n", " break\n", "\n", "display(Markdown(f'#### Got server {namespace}.{name}'))" @@ -446,10 +449,10 @@ "uid = server['metadata']['uid']\n", "\n", "display(Markdown(f'#### Server summary'))\n", - "run(f'kubectl get dbs -n {namespace} {name}')\n", + "run(f'kubectl get postgresql-{version} -n {namespace} {name}')\n", "\n", "display(Markdown(f'#### Resource summary'))\n", - "run(f'kubectl get pods,pvc,svc,ep -n {namespace} -l dusky.microsoft.com/serviceId={uid}')" + "run(f'kubectl get sts,pods,pvc,svc,ep -n {namespace} -l postgresqls.arcdata.microsoft.com/cluster-id={uid}')" ] }, { @@ -466,7 +469,7 @@ "outputs": [], "source": [ "display(Markdown(f'#### Troubleshooting server {namespace}.{name}'))\n", - "run(f'kubectl describe dbs -n {namespace} {name}')" + "run(f'kubectl describe postgresql-{version} -n {namespace} {name}')" ] }, { @@ -482,7 +485,7 @@ "metadata": {}, "outputs": [], "source": [ - "pods = json.loads(run(f'kubectl get pods -n {namespace} -l dusky.microsoft.com/serviceId={uid} -o json', return_output=True))['items']\n", + "pods = json.loads(run(f'kubectl get pods -n {namespace} -l postgresqls.arcdata.microsoft.com/cluster-id={uid} -o json', return_output=True))['items']\n", "\n", "# Summarize and describe each pod\n", "for pod in pods:\n", @@ -529,8 +532,7 @@ " con_restarts = con_status.get('restartCount', 0)\n", "\n", " display(Markdown(f'#### Troubleshooting container {namespace}.{pod_name}/{con_name} ({i+1}/{len(cons)})\\n'\n", - " f'#### {\"S\" if con_started else \"Not s\"}tarted and '\n", - " f'{\"\" if con_ready else \"not \"}ready with {con_restarts} restarts'))\n", + " f'#### {\"R\" if con_ready else \"Not r\"}eady with {con_restarts} restarts'))\n", "\n", " run(f'kubectl logs -n {namespace} {pod_name} {con_name} --tail {tail_lines}')\n", "\n", @@ -554,7 +556,7 @@ "outputs": [], "source": [ "display(Markdown(f'#### Troubleshooting PersistentVolumeClaims'))\n", - "run(f'kubectl describe pvc -n {namespace} -l dusky.microsoft.com/serviceId={uid}')" + "run(f'kubectl describe pvc -n {namespace} -l postgresqls.arcdata.microsoft.com/cluster-id={uid}')" ] }, { diff --git a/extensions/arc/package.nls.json b/extensions/arc/package.nls.json index 0bbf383807..e151babf13 100644 --- a/extensions/arc/package.nls.json +++ b/extensions/arc/package.nls.json @@ -103,9 +103,9 @@ "arc.azure.resource.group": "Azure resource group", "arc.azure.location": "Azure location", "arc.postgres.new.dialog.title": "Deploy an Azure Arc enabled PostgreSQL Hyperscale server group (Preview)", - "arc.postgres.settings.section.title": "PostgreSQL server group settings", - "arc.postgres.settings.resource.title": "PostgreSQL server group resource settings", - "arc.postgres.settings.storage.title": "PostgreSQL server group storage settings", + "arc.postgres.settings.section.title": "General settings", + "arc.postgres.settings.resource.title": "Resource settings", + "arc.postgres.settings.storage.title": "Storage settings", "arc.postgres.server.group.name": "Server group name", "arc.postgres.server.group.name.validation.description": "Server group name must consist of lower case alphanumeric characters or '-', start with a letter, end with an alphanumeric character, and be 12 characters or fewer in length.", "arc.postgres.server.group.workers": "Number of workers", diff --git a/extensions/arc/src/localizedConstants.ts b/extensions/arc/src/localizedConstants.ts index adb9c9f85c..08c5a80437 100644 --- a/extensions/arc/src/localizedConstants.ts +++ b/extensions/arc/src/localizedConstants.ts @@ -126,6 +126,7 @@ export const condition = localize('arc.condition', "Condition"); export const details = localize('arc.details', "Details"); export const lastUpdated = localize('arc.lastUpdated', "Last updated"); export const noExternalEndpoint = localize('arc.noExternalEndpoint', "No External Endpoint has been configured so this information isn't available."); +export const podsReady = localize('arc.podsReady', "pods ready"); export function databaseCreated(name: string): string { return localize('arc.databaseCreated', "Database {0} created", name); } export function instanceDeleted(name: string): string { return localize('arc.instanceDeleted', "Instance '{0}' deleted", name); } diff --git a/extensions/arc/src/ui/dashboards/postgres/postgresConnectionStringsPage.ts b/extensions/arc/src/ui/dashboards/postgres/postgresConnectionStringsPage.ts index 82760431da..183fe123bb 100644 --- a/extensions/arc/src/ui/dashboards/postgres/postgresConnectionStringsPage.ts +++ b/extensions/arc/src/ui/dashboards/postgres/postgresConnectionStringsPage.ts @@ -3,7 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as vscode from 'vscode'; import * as azdata from 'azdata'; import * as loc from '../../../localizedConstants'; import { IconPathHelper, cssStyles } from '../../../constants'; @@ -12,7 +11,6 @@ import { DashboardPage } from '../../components/dashboardPage'; import { PostgresModel } from '../../../models/postgresModel'; export class PostgresConnectionStringsPage extends DashboardPage { - private loading?: azdata.LoadingComponent; private keyValueContainer?: KeyValueContainer; constructor(protected modelView: azdata.ModelView, private _postgresModel: PostgresModel) { @@ -61,40 +59,13 @@ export class PostgresConnectionStringsPage extends DashboardPage { this.keyValueContainer = new KeyValueContainer(this.modelView.modelBuilder, this.getConnectionStrings()); this.disposables.push(this.keyValueContainer); - - this.loading = this.modelView.modelBuilder.loadingComponent() - .withItem(this.keyValueContainer.container) - .withProperties({ - loading: !this._postgresModel.configLastUpdated - }).component(); - - content.addItem(this.loading); + content.addItem(this.keyValueContainer.container); this.initialized = true; return root; } protected get toolbarContainer(): azdata.ToolbarContainer { - const refreshButton = this.modelView.modelBuilder.button().withProperties({ - label: loc.refresh, - iconPath: IconPathHelper.refresh - }).component(); - - this.disposables.push( - refreshButton.onDidClick(async () => { - refreshButton.enabled = false; - try { - this.loading!.loading = true; - await this._postgresModel.refresh(); - } catch (error) { - vscode.window.showErrorMessage(loc.refreshFailed(error)); - } finally { - refreshButton.enabled = true; - } - })); - - return this.modelView.modelBuilder.toolbarContainer().withToolbarItems([ - { component: refreshButton } - ]).component(); + return this.modelView.modelBuilder.toolbarContainer().component(); } private getConnectionStrings(): KeyValue[] { @@ -118,6 +89,5 @@ export class PostgresConnectionStringsPage extends DashboardPage { private handleServiceUpdated() { this.keyValueContainer?.refresh(this.getConnectionStrings()); - this.loading!.loading = false; } } diff --git a/extensions/arc/src/ui/dashboards/postgres/postgresDashboard.ts b/extensions/arc/src/ui/dashboards/postgres/postgresDashboard.ts index 6bb47cb5d8..2c23aceb06 100644 --- a/extensions/arc/src/ui/dashboards/postgres/postgresDashboard.ts +++ b/extensions/arc/src/ui/dashboards/postgres/postgresDashboard.ts @@ -10,7 +10,6 @@ import { ControllerModel } from '../../../models/controllerModel'; import { PostgresModel } from '../../../models/postgresModel'; import { PostgresOverviewPage } from './postgresOverviewPage'; import { PostgresConnectionStringsPage } from './postgresConnectionStringsPage'; -import { PostgresPropertiesPage } from './postgresPropertiesPage'; import { Dashboard } from '../../components/dashboard'; import { PostgresDiagnoseAndSolveProblemsPage } from './postgresDiagnoseAndSolveProblemsPage'; import { PostgresSupportRequestPage } from './postgresSupportRequestPage'; @@ -31,7 +30,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 connectionStringsPage = new PostgresConnectionStringsPage(modelView, this._postgresModel); - const propertiesPage = new PostgresPropertiesPage(modelView, this._controllerModel, this._postgresModel); + // TODO: Removed properties page while investigating bug where refreshed values don't appear in UI + // const propertiesPage = new PostgresPropertiesPage(modelView, this._controllerModel, this._postgresModel); const diagnoseAndSolveProblemsPage = new PostgresDiagnoseAndSolveProblemsPage(modelView, this._context, this._postgresModel); const supportRequestPage = new PostgresSupportRequestPage(modelView); @@ -40,8 +40,7 @@ export class PostgresDashboard extends Dashboard { { title: loc.settings, tabs: [ - connectionStringsPage.tab, - propertiesPage.tab + connectionStringsPage.tab ] }, { diff --git a/extensions/arc/src/ui/dashboards/postgres/postgresOverviewPage.ts b/extensions/arc/src/ui/dashboards/postgres/postgresOverviewPage.ts index 64d00a62fa..9d90aaf423 100644 --- a/extensions/arc/src/ui/dashboards/postgres/postgresOverviewPage.ts +++ b/extensions/arc/src/ui/dashboards/postgres/postgresOverviewPage.ts @@ -245,17 +245,20 @@ export class PostgresOverviewPage extends DashboardPage { } private getProperties(): azdata.PropertiesContainerItem[] { - const endpoint = this._postgresModel.endpoint; + const status = this._postgresModel.config?.status; + const azure = this._controllerModel.controllerConfig?.spec.settings.azure; return [ - { displayName: loc.name, value: this._postgresModel.info.name }, - { displayName: loc.coordinatorEndpoint, value: endpoint ? `postgresql://postgres@${endpoint.ip}:${endpoint.port}` : '-' }, - { displayName: loc.status, value: this._postgresModel.config?.status.state || '-' }, + { displayName: loc.resourceGroup, value: azure?.resourceGroup || '-' }, + { displayName: loc.dataController, value: this._controllerModel.controllerConfig?.metadata.name || '-' }, + { displayName: loc.region, value: azure?.location || '-' }, + { displayName: loc.namespace, value: this._postgresModel.config?.metadata.namespace || '-' }, + { displayName: loc.subscriptionId, value: azure?.subscription || '-' }, + { displayName: loc.externalEndpoint, value: this._postgresModel.config?.status.externalEndpoint || '-' }, + { displayName: loc.status, value: status ? `${status.state} (${status.readyPods} ${loc.podsReady})` : '-' }, { displayName: loc.postgresAdminUsername, value: 'postgres' }, - { displayName: loc.dataController, value: this._controllerModel?.controllerConfig?.metadata.namespace || '-' }, - { displayName: loc.nodeConfiguration, value: this._postgresModel.scaleConfiguration || '-' }, - { displayName: loc.subscriptionId, value: this._controllerModel.controllerConfig?.spec.settings.azure.subscription ?? '' }, - { displayName: loc.postgresVersion, value: this._postgresModel.engineVersion ?? '-' } + { displayName: loc.postgresVersion, value: this._postgresModel.engineVersion ?? '-' }, + { displayName: loc.nodeConfiguration, value: this._postgresModel.scaleConfiguration || '-' } ]; } diff --git a/extensions/arc/src/ui/dashboards/postgres/postgresPropertiesPage.ts b/extensions/arc/src/ui/dashboards/postgres/postgresPropertiesPage.ts index f2ebd8c423..03fb1e7858 100644 --- a/extensions/arc/src/ui/dashboards/postgres/postgresPropertiesPage.ts +++ b/extensions/arc/src/ui/dashboards/postgres/postgresPropertiesPage.ts @@ -92,11 +92,12 @@ export class PostgresPropertiesPage extends DashboardPage { private getProperties(): KeyValue[] { const endpoint = this._postgresModel.endpoint; + const status = this._postgresModel.config?.status; return [ new InputKeyValue(this.modelView.modelBuilder, loc.coordinatorEndpoint, endpoint ? `postgresql://postgres@${endpoint.ip}:${endpoint.port}` : ''), new InputKeyValue(this.modelView.modelBuilder, loc.postgresAdminUsername, 'postgres'), - new TextKeyValue(this.modelView.modelBuilder, loc.status, this._postgresModel.config?.status.state ?? loc.unknown), + new TextKeyValue(this.modelView.modelBuilder, loc.status, status ? `${status.state} (${status.readyPods} ${loc.podsReady})` : loc.unknown), // TODO: Make this a LinkKeyValue that opens the controller dashboard new TextKeyValue(this.modelView.modelBuilder, loc.dataController, this._controllerModel.controllerConfig?.metadata.namespace ?? ''), new TextKeyValue(this.modelView.modelBuilder, loc.nodeConfiguration, this._postgresModel.scaleConfiguration ?? ''),