Skip to content

Commit

Permalink
PMM-11673-fix-psmdb-configuration: add extra configuration, add defau…
Browse files Browse the repository at this point in the history
…lt configuration
  • Loading branch information
solovevayaroslavna committed Apr 27, 2023
1 parent a712e59 commit ebb95b8
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Databases } from 'app/percona/shared/core';
export const PXCDefailtConfiguration =
'Configuration: [mysqld]\n' +
'wsrep_provider_options="gcache.size=600M"\n' +
"wsrep_trx_fragment_unit='bytes'\n" +
'wsrep_trx_fragment_size=3670018';
export const PSMDBDefaultConfiguration = ' Configuration: \n' + ' operationProfiling:\n' + ' mode: slowOp';

export const DefaultDatabaseConfiguration: Partial<Record<Databases, string>> = {
[Databases.mysql]: PXCDefailtConfiguration,
[Databases.mongodb]: PSMDBDefaultConfiguration,
};
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const DBClusterBasicOptions: FC<DBClusterBasicOptionsProps> = ({ kubernet
const onChangeDatabase = useCallback((databaseType) => {
change(BasicOptionsFields.databaseType, databaseType);
form.mutators.setClusterName(databaseType.value);
form.mutators.changeConfiguration(databaseType.value);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { Form } from 'react-final-form';
import { Redirect, useHistory } from 'react-router-dom';

import { Spinner, useStyles2 } from '@grafana/ui/src';
import { DefaultDatabaseConfiguration } from 'app/percona/dbaas/components/DBCluster/EditDBClusterPage/DBClusterAdvancedOptions/Configurations/Configuration.constants';
import { useShowPMMAddressWarning } from 'app/percona/shared/components/hooks/showPMMAddressWarning';
import { Databases } from 'app/percona/shared/core';
import { useSelector, useDispatch } from 'app/types';

import { FeatureLoader } from '../../../../shared/components/Elements/FeatureLoader';
Expand Down Expand Up @@ -93,6 +95,11 @@ export const EditDBClusterPage: FC<EditDBClusterPageProps> = () => {
trimConfiguration: ([configuration]: string[], state, { changeValue }) => {
changeValue(state, ConfigurationFields.configuration, () => configuration.trim());
},
changeConfiguration: (databaseTypeValue: Databases, state, { changeValue }) => {
changeValue(state, ConfigurationFields.configuration, () =>
databaseTypeValue ? DefaultDatabaseConfiguration[databaseTypeValue] : ''
);
},
...arrayMutators,
}}
render={({ form, handleSubmit, valid, pristine, ...props }) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { logger } from '@percona/platform-core';

import { DefaultDatabaseConfiguration } from 'app/percona/dbaas/components/DBCluster/EditDBClusterPage/DBClusterAdvancedOptions/Configurations/Configuration.constants';
import { ConfigurationFields } from 'app/percona/dbaas/components/DBCluster/EditDBClusterPage/DBClusterAdvancedOptions/Configurations/Configurations.types';

import { DATABASE_LABELS } from '../../../../shared/core';
import { Kubernetes } from '../../Kubernetes/Kubernetes.types';
import { getActiveOperators, getDatabaseOptionFromOperator } from '../../Kubernetes/Kubernetes.utils';
Expand Down Expand Up @@ -37,8 +40,12 @@ export const getAddInitialValues = (
initialValues[BasicOptionsFields.kubernetesCluster] = initialCluster;
if (activeOperators.length > 0) {
const databaseDefaultOperator = getDatabaseOptionFromOperator(activeOperators[0]);
const defaultConfiguration = databaseDefaultOperator?.value
? DefaultDatabaseConfiguration[databaseDefaultOperator?.value]
: '';
initialValues[BasicOptionsFields.databaseType] = databaseDefaultOperator;
initialValues[BasicOptionsFields.name] = `${databaseDefaultOperator?.value}-${generateUID()}`;
initialValues[ConfigurationFields.configuration] = defaultConfiguration;
}
}
}
Expand Down Expand Up @@ -80,7 +87,10 @@ export const getEditInitialValues = (
cpu,
disk,
memory,
configuration: configuration?.params?.pxc?.configuration || configuration?.params?.replicaset?.configuration,
configuration:
selectedDBCluster?.configuration ||
configuration?.params?.pxc?.configuration ||
configuration?.params?.replicaset?.configuration,
expose: configuration?.exposed,
internetFacing: configuration?.internet_facing,
sourceRanges: sourceRangesArray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export class PSMDBService extends DBClusterService {
availableImage: dbCluster.available_image,
template: dbCluster.template,
sourceRanges: dbCluster.source_ranges,
configuration: dbCluster.params.replicaset?.configuration,
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export class XtraDBService extends DBClusterService {
availableImage: dbCluster.available_image,
template: dbCluster.template,
sourceRanges: dbCluster.source_ranges,
configuration: dbCluster.params.pxc?.configuration,
};
}
}
Expand Down

0 comments on commit ebb95b8

Please sign in to comment.