mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-08 01:28:26 -05:00
Fixed PG update (#20484)
Co-authored-by: Candice Ye <canye@microsoft.com>
This commit is contained in:
@@ -50,11 +50,6 @@ export class PostgresModel extends ResourceModel {
|
||||
return this._config;
|
||||
}
|
||||
|
||||
/** Returns the major version of Postgres */
|
||||
public get engineVersion(): string | undefined {
|
||||
return this._config?.spec.engine.version;
|
||||
}
|
||||
|
||||
/** Returns the IP address and port of Postgres */
|
||||
public get endpoint(): { ip: string, port: string } | undefined {
|
||||
return this._config?.status.primaryEndpoint
|
||||
@@ -76,12 +71,7 @@ export class PostgresModel extends ResourceModel {
|
||||
const logStorage = this._config.spec.storage?.logs?.volumes?.[0]?.size;
|
||||
const backupsStorage = this._config.spec.storage?.backups?.volumes?.[0]?.size;
|
||||
|
||||
// scale.shards was renamed to scale.workers. Check both for backwards compatibility.
|
||||
const scale = this._config.spec.scale;
|
||||
const nodes = (scale?.workers ?? scale?.shards ?? 0) + 1; // An extra node for the coordinator
|
||||
|
||||
let configuration: string[] = [];
|
||||
configuration.push(`${nodes} ${nodes > 1 ? loc.nodes : loc.node}`);
|
||||
|
||||
// Prefer limits if they're provided, otherwise use requests if they're provided
|
||||
if (cpuLimit || cpuRequest) {
|
||||
@@ -162,12 +152,6 @@ export class PostgresModel extends ResourceModel {
|
||||
|
||||
await this.createCoordinatorEngineSettings(provider, ownerUri, skippedEngineSettings);
|
||||
|
||||
const scale = this._config?.spec.scale;
|
||||
const nodes = (scale?.workers ?? scale?.shards ?? 0);
|
||||
if (nodes !== 0) {
|
||||
await this.createWorkerEngineSettings(provider, ownerUri, skippedEngineSettings);
|
||||
}
|
||||
|
||||
this.engineSettingsLastUpdated = new Date();
|
||||
this._engineSettingsPromise.resolve();
|
||||
} catch (err) {
|
||||
@@ -202,39 +186,6 @@ export class PostgresModel extends ResourceModel {
|
||||
|
||||
}
|
||||
|
||||
private async createWorkerEngineSettings(provider: azdata.QueryProvider, ownerUri: string, skip: String[]): Promise<void> {
|
||||
|
||||
const engineSettingsWorker = await provider.runQueryAndReturn(ownerUri,
|
||||
`with settings as (select nodename, success, result from run_command_on_workers('select json_agg(pg_settings) from pg_settings') order by success desc, nodename asc)
|
||||
select * from settings limit case when exists(select 1 from settings where success) then 1 end`);
|
||||
|
||||
if (engineSettingsWorker.rows[0][1].displayValue === 'False') {
|
||||
let errorString = engineSettingsWorker.rows.map(row => row[2].displayValue);
|
||||
throw new Error(errorString.join('\n'));
|
||||
}
|
||||
|
||||
let engineSettingsWorkerJSON = JSON.parse(engineSettingsWorker.rows[0][2].displayValue);
|
||||
this.workerNodesEngineSettings = [];
|
||||
|
||||
for (let i = 0; i < engineSettingsWorkerJSON.length; i++) {
|
||||
let rowValues = engineSettingsWorkerJSON[i];
|
||||
let name = rowValues.name;
|
||||
if (!skip.includes(name!)) {
|
||||
let result: EngineSettingsModel = {
|
||||
parameterName: name,
|
||||
value: rowValues.setting,
|
||||
description: rowValues.short_desc,
|
||||
min: rowValues.min_val,
|
||||
max: rowValues.max_val,
|
||||
options: rowValues.enumvals,
|
||||
type: rowValues.vartype
|
||||
};
|
||||
|
||||
this.workerNodesEngineSettings.push(result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected createConnectionProfile(): azdata.IConnectionProfile {
|
||||
const ipAndPort = parseIpAndPort(this.config?.status.primaryEndpoint || '');
|
||||
|
||||
Reference in New Issue
Block a user