mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed an issue where the cloud deployment wizard creates the cluster with the
High Availability even if that option is not selected. Fixes #7608
This commit is contained in:
committed by
Akshay Joshi
parent
1e94c3bd81
commit
ae5254e8a9
@@ -27,6 +27,10 @@ from pgadmin.utils.constants import MIMETYPE_APP_JSON
|
||||
|
||||
MODULE_NAME = 'biganimal'
|
||||
|
||||
SINGLE_CLUSTER_ARCH = 'single'
|
||||
HA_CLUSTER_ARCH = 'ha' # High Availability
|
||||
EHA_CLUSTER_ARCH = 'eha' # Extreme High Availability
|
||||
|
||||
|
||||
class BigAnimalModule(PgAdminModule):
|
||||
"""Cloud module to deploy on EDB BigAnimal"""
|
||||
@@ -285,10 +289,12 @@ class BigAnimalProvider():
|
||||
if resp.status_code == 200 and resp.content:
|
||||
pg_types_resp = json.loads(resp.content)
|
||||
for value in pg_types_resp['pgTypesList']:
|
||||
pg_types.append({
|
||||
'label': value['name'],
|
||||
'value': value['id']
|
||||
})
|
||||
# Extreme HA is in Beta, so avoid it
|
||||
if len(value['supportedClusterArchitectureIds']) != 1:
|
||||
pg_types.append({
|
||||
'label': value['name'],
|
||||
'value': value['id']
|
||||
})
|
||||
return pg_types
|
||||
|
||||
def get_postgres_versions(self):
|
||||
@@ -366,10 +372,15 @@ def deploy_on_biganimal(data):
|
||||
_label = data['instance_details']['name']
|
||||
_private_network = '1' if str(data['instance_details']['cloud_type']
|
||||
) == 'private' else '0'
|
||||
_high_availability = '1' if data['db_details']['high_availability']\
|
||||
else '0'
|
||||
_instance_size = data['instance_details']['instance_size'].split('||')[1]
|
||||
|
||||
cluster_arch = SINGLE_CLUSTER_ARCH
|
||||
nodes = 1
|
||||
|
||||
if data['db_details']['high_availability']:
|
||||
cluster_arch = HA_CLUSTER_ARCH
|
||||
nodes = int(data['db_details']['replicas']) + nodes
|
||||
|
||||
args = [_cmd_script,
|
||||
data['cloud'],
|
||||
'create-instance',
|
||||
@@ -389,8 +400,10 @@ def deploy_on_biganimal(data):
|
||||
str(_instance_size),
|
||||
'--private-network',
|
||||
_private_network,
|
||||
'--high-availability',
|
||||
_high_availability
|
||||
'--cluster-arch',
|
||||
cluster_arch,
|
||||
'--nodes',
|
||||
str(nodes)
|
||||
]
|
||||
|
||||
if 'biganimal_public_ip' in data['instance_details']:
|
||||
|
||||
@@ -188,6 +188,7 @@ export function getBigAnimalSummary(cloud, bigAnimalInstanceData, bigAnimalDatab
|
||||
createData('Database Type', bigAnimalDatabaseData.database_type),
|
||||
createData('Database Version', bigAnimalDatabaseData.postgres_version),
|
||||
createData('High Availability', bigAnimalDatabaseData.high_availability),
|
||||
createData('No of Standby Replicas', bigAnimalDatabaseData.replicas),
|
||||
];
|
||||
|
||||
return [rows1, rows2, rows3, rows4];
|
||||
@@ -211,6 +212,10 @@ export function validateBigAnimalStep3(cloudDBDetails, nodeInfo) {
|
||||
isEmptyString(cloudDBDetails.database_type) || isEmptyString(cloudDBDetails.postgres_version)) {
|
||||
isError = true;
|
||||
}
|
||||
|
||||
if(cloudDBDetails.high_availability == true && (isEmptyString(cloudDBDetails.replicas) || cloudDBDetails.replicas <= 0)) {
|
||||
isError = true;
|
||||
}
|
||||
if (isEmptyString(cloudDBDetails.gid)) cloudDBDetails.gid = nodeInfo['server_group']._id;
|
||||
return isError;
|
||||
}
|
||||
|
||||
@@ -467,6 +467,7 @@ class BigAnimalDatabaseSchema extends BaseUISchema {
|
||||
database_type: '',
|
||||
postgres_version: '',
|
||||
high_availability: false,
|
||||
replicas: 0,
|
||||
...initValues
|
||||
});
|
||||
|
||||
@@ -487,7 +488,10 @@ class BigAnimalDatabaseSchema extends BaseUISchema {
|
||||
setErrMsg('confirm_password', gettext('Password must be 12 characters or more.'));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (data.high_availability == true && (isEmptyString(data.replicas) || data.replicas <= 0)) {
|
||||
setErrMsg('replicas', gettext('Please select no. of stand by replicas.'));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -592,6 +596,7 @@ class BigAnimalHighAvailSchema extends BaseUISchema {
|
||||
super({
|
||||
oid: undefined,
|
||||
high_availability: false,
|
||||
replicas: 0,
|
||||
...initValues
|
||||
});
|
||||
|
||||
@@ -610,13 +615,25 @@ class BigAnimalHighAvailSchema extends BaseUISchema {
|
||||
{
|
||||
id: 'high_availability_note', type: 'note',
|
||||
mode: ['create'],
|
||||
text: gettext('High availability clusters are configured with one primary and two '
|
||||
+ 'replicas with synchronous streaming replication. Clusters are configured across availability zones in regions with availability zones.'),
|
||||
text: gettext('High availability clusters are configured with one primary and up to two '
|
||||
+ 'stand by replicas. Clusters are configured across availability zones in regions with availability zones.'),
|
||||
},{
|
||||
id: 'high_availability', label: gettext('High Availability'), type: 'switch',
|
||||
mode: ['create'],
|
||||
helpMessage: gettext('Turning on high availability means your number of CPUs will triple, as will your cost.'),
|
||||
}
|
||||
id: 'high_availability', label: gettext('High availability'), type: 'switch',
|
||||
mode: ['create']
|
||||
},{
|
||||
id: 'replicas', label: gettext('Number of standby replicas'), type: 'select',
|
||||
mode: ['create'], deps: ['high_availability'],
|
||||
controlProps: { allowClear: false },
|
||||
helpMessage: gettext('Adding standby replicas will increase your number of CPUs, as well as your cost.'),
|
||||
options: [
|
||||
{'label': gettext('1'), 'value': 1},
|
||||
{'label': gettext('2'), 'value': 2},
|
||||
], noEmpty: true,
|
||||
disabled: (state) => {
|
||||
if (state.high_availability == true) return false;
|
||||
return true;
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user