Skip to content

Commit daa750c

Browse files
change: [UIE-8685] - Advanced Config: custom validation for wal_sender_timeout (linode#12022)
* change: [UIE-8685] - add new field to Config item * Added changeset: DBaaS: `anyOf` field to the `ConfigurationItem` * Added changeset: validation for config items with an `anyOf` field that defines a range * add temporary custom validation (no backend support yet) * add temporary custom validation for max_failover_replication_time_lag * update changeset --------- Co-authored-by: cpathipa <[email protected]>
1 parent a0febfa commit daa750c

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

packages/api-v4/src/databases/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export interface DatabaseBackup {
5050
label: string;
5151
type: DatabaseBackupType;
5252
}
53+
5354
export interface ConfigurationItem {
5455
description?: string;
5556
enum?: string[];

packages/manager/src/factories/databases.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ export const databaseTypeFactory = Factory.Sync.makeFactory<DatabaseType>({
126126

127127
const adb10 = (i: number) => i % 2 === 0;
128128

129-
export const databaseInstanceFactory = Factory.Sync.makeFactory<DatabaseInstance>(
130-
{
129+
export const databaseInstanceFactory =
130+
Factory.Sync.makeFactory<DatabaseInstance>({
131131
allow_list: [],
132132
cluster_size: Factory.each((i) =>
133133
adb10(i)
@@ -187,8 +187,7 @@ export const databaseInstanceFactory = Factory.Sync.makeFactory<DatabaseInstance
187187
week_of_month: null,
188188
},
189189
version: Factory.each((i) => ['8.0.30', '15.7'][i % 2]),
190-
}
191-
);
190+
});
192191

193192
export const databaseFactory = Factory.Sync.makeFactory<Database>({
194193
allow_list: [...IPv4List],
@@ -273,8 +272,8 @@ export const databaseEngineFactory = Factory.Sync.makeFactory<DatabaseEngine>({
273272
version: Factory.each((i) => `${i}`),
274273
});
275274

276-
export const databaseEngineConfigFactory = Factory.Sync.makeFactory<DatabaseEngineConfig>(
277-
{
275+
export const databaseEngineConfigFactory =
276+
Factory.Sync.makeFactory<DatabaseEngineConfig>({
278277
binlog_retention_period: {
279278
description:
280279
'The minimum amount of time in seconds to keep binlog entries before deletion. This may be extended for services that require binlog entries for longer than the default for example if using the MySQL Debezium Kafka connector.',
@@ -284,6 +283,12 @@ export const databaseEngineConfigFactory = Factory.Sync.makeFactory<DatabaseEngi
284283
requires_restart: false,
285284
type: 'integer',
286285
},
286+
wal_sender_timeout: {
287+
description:
288+
'Terminate replication connections that are inactive for longer than this amount of time, in milliseconds. Setting this value to zero disables the timeout.',
289+
type: 'integer',
290+
example: 60000,
291+
},
287292
mysql: {
288293
connect_timeout: {
289294
description:
@@ -370,5 +375,4 @@ export const databaseEngineConfigFactory = Factory.Sync.makeFactory<DatabaseEngi
370375
requires_restart: false,
371376
type: ['boolean', 'null'],
372377
},
373-
}
374-
);
378+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/validation": Added
3+
---
4+
5+
custom validation for `wal_sender_timeout` and `max_failover_replication_time_lag` ([#12022](https://github.com/linode/manager/pull/12022))

packages/validation/src/databases.schema.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,28 @@ const applyConstraints = (validator: any, key: string, field: any) => {
103103
`Please ensure that ${key} follows the format ${field.example}`,
104104
);
105105
}
106+
// custom validation for wal_sender_timeout since it has a special case
107+
// where it can be 0 or between 5000 and 10800000
108+
if (key === 'wal_sender_timeout') {
109+
validator = validator.test(
110+
'is-zero-or-in-range',
111+
`${key} must be 0 or between 5000 and 10800000`,
112+
(value: boolean | number | string) => {
113+
if (typeof value !== 'number') return false;
114+
return value === 0 || (value >= 5000 && value <= 10800000);
115+
},
116+
);
117+
}
106118
if (key === 'timezone') {
107119
if (!field.value) {
108120
validator = validator.required('timezone cannot be empty');
109121
}
110122
}
123+
// temporary custom validation for max_failover_replication_time_lag
124+
// TODO: remove this when the API is updated
125+
if (key === 'max_failover_replication_time_lag') {
126+
validator = validator.max(999999, `${key} must be at most 999999`);
127+
}
111128

112129
return validator;
113130
};

0 commit comments

Comments
 (0)