Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Upcoming Features
---

Deprecate connection_pool_port, add endpoints property to DatabaseHosts ([#13386](https://github.com/linode/manager/pull/13386))
15 changes: 15 additions & 0 deletions packages/api-v4/src/databases/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,21 @@ export interface DatabaseCredentials {
username: string;
}

export type HostEndpointRole =
| 'primary'
| 'primary-connection-pool'
| 'standby'
| 'standby-connection-pool';

interface HostEndpoint {
address: string;
port: number;
private_access: boolean;
role: HostEndpointRole;
}

interface DatabaseHosts {
endpoints: HostEndpoint[];
primary: string;
secondary?: string;
standby?: string;
Expand All @@ -106,6 +120,7 @@ type MemberType = 'failover' | 'primary';
export interface DatabaseInstance {
allow_list: string[];
cluster_size: ClusterSize;
/** @Deprecated replaced by `endpoints` property */
connection_pool_port: null | number;
connection_strings: ConnectionStrings[];
created: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Deprecate connection_pool_port, add endpoints mock data for Databases ([#13386](https://github.com/linode/manager/pull/13386))
38 changes: 36 additions & 2 deletions packages/manager/src/factories/databases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@
? ([1, 3][i % 2] as ClusterSize)
: ([1, 2, 3][i % 3] as ClusterSize)
),
connection_pool_port: null,
connection_pool_port:
null /** @Deprecated replaced by `endpoints` property */,
connection_strings: [],
created: '2021-12-09T17:15:12',
encrypted: false,
Expand All @@ -174,10 +175,26 @@
? {
primary: 'db-mysql-primary-0.b.linodeb.net',
secondary: 'db-mysql-secondary-0.b.linodeb.net',
endpoints: [
{
address: 'public-db-mysql-primary-0.b.linodeb.net',

Check warning on line 180 in packages/manager/src/factories/databases.ts

View workflow job for this annotation

GitHub Actions / ESLint Review (manager)

[eslint] reported by reviewdog ๐Ÿถ Define a constant instead of duplicating this literal 4 times. Raw Output: {"ruleId":"sonarjs/no-duplicate-string","severity":1,"message":"Define a constant instead of duplicating this literal 4 times.","line":180,"column":26,"nodeType":"Literal","endLine":180,"endColumn":67}
role: 'primary',
private_access: false,
port: 3306,
},
],
}
: {
primary: 'db-mysql-primary-0.b.linodeb.net',
standby: 'db-mysql-secondary-0.b.linodeb.net',
endpoints: [
{
address: 'public-db-mysql-primary-0.b.linodeb.net',
role: 'primary',
private_access: false,
port: 3306,
},
],
}
),
id: Factory.each((i) => i),
Expand Down Expand Up @@ -213,7 +230,8 @@
export const databaseFactory = Factory.Sync.makeFactory<Database>({
allow_list: [...IPv4List],
cluster_size: Factory.each(() => pickRandom([1, 3])),
connection_pool_port: null,
connection_pool_port:
null /** @Deprecated replaced by `endpoints` property */,
connection_strings: [
{
driver: 'python',
Expand All @@ -231,10 +249,26 @@
? {
primary: 'db-mysql-primary-0.b.linodeb.net',
secondary: 'db-mysql-secondary-0.b.linodeb.net',
endpoints: [
{
address: 'public-db-mysql-primary-0.b.linodeb.net',
role: 'primary',
private_access: false,
port: 3306,
},
],
}
: {
primary: 'db-mysql-primary-0.b.linodeb.net',
standby: 'db-mysql-secondary-0.b.linodeb.net',
endpoints: [
{
address: 'public-db-mysql-primary-0.b.linodeb.net',
role: 'primary',
private_access: false,
port: 3306,
},
],
}
),
id: Factory.each((i) => i),
Expand Down
17 changes: 17 additions & 0 deletions packages/manager/src/features/Databases/utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import type {
AccountCapability,
Database,
Engine,
HostEndpointRole,
PendingUpdates,
} from '@linode/api-v4';

Expand Down Expand Up @@ -540,6 +541,14 @@ describe('getReadOnlyHost', () => {
primary: 'primary.example.com',
standby: 'standby.example.com',
secondary: 'secondary.example.com',
endpoints: [
{
address: 'public-primary.example.com',
role: 'primary' as HostEndpointRole,
private_access: false,
port: 12345,
},
],
};
db.hosts = mockHosts;
const result = getReadOnlyHost(db);
Expand All @@ -552,6 +561,14 @@ describe('getReadOnlyHost', () => {
const mockHosts = {
primary: 'primary.example.com',
secondary: 'secondary.example.com',
endpoints: [
{
address: 'public-primary.example.com',
role: 'primary' as HostEndpointRole,
private_access: false,
port: 12345,
},
],
};
db.hosts = mockHosts;
const result = getReadOnlyHost(db);
Expand Down
10 changes: 9 additions & 1 deletion packages/manager/src/mocks/serverHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ const makeMockDatabase = (params: PathParams): Database => {
}

if (db.engine === 'postgresql') {
db.connection_pool_port = 100;
db.connection_pool_port = 100; /** @Deprecated replaced by `endpoints` property */
}

const database = databaseFactory.build(db);
Expand All @@ -232,6 +232,14 @@ const makeMockDatabase = (params: PathParams): Database => {
database.hosts = {
primary: 'private-db-mysql-primary-0.b.linodeb.net',
standby: 'private-db-mysql-standby-0.b.linodeb.net',
endpoints: [
{
address: 'private-db-mysql-primary-0.b.linodeb.net',
role: 'primary',
private_access: true,
port: 12345,
},
],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, but as a future change, I'd suggest making the 'endpoints' array content dynamic based on the VPC configuration. We could have it render different endpoints based on the settings, similar to how it behaves in the backend.

That way, it'd be easier to test the display behavior for the fields that appear in the UI and we could even add a comment to give insight into the backend behavior.

But since we're still confirming the behavior, we could consider it one of the upcoming tickets for this instead.

};
}

Expand Down