fix: [UIE-9487] VPC UI not displaying DBaaS resources#13504
fix: [UIE-9487] VPC UI not displaying DBaaS resources#13504smans-akamai wants to merge 5 commits intolinode:developfrom
Conversation
5eb6f67 to
80d3e4c
Compare
| borderTop: `1px solid ${theme.tokens.component.Table.Row.Border}`, | ||
| }} | ||
| /> | ||
| </> |
There was a problem hiding this comment.
Added pagination since the databases table will be using the database list GET request which is paginated. The other tables (Linodes and Nodebalancers) loop through the IDs from the subnets response and make their instance calls, so they don't have to be paginated.
There was a problem hiding this comment.
This is using the default page size options (25, 50, 75, 100) and is set to default to 25 as that's the minimum size for the Get database list request.
| const theme = useTheme(); | ||
|
|
||
| const [pageSize, setPageSize] = React.useState(25); | ||
| const [page, setPage] = React.useState(1); |
There was a problem hiding this comment.
I chose to store the page and pageSize property in state instead of using the usePaginationV2 hook that's used in the DatabaseLanding since there can be many of these and it might not make sense to store this information in preferences as the VPCs and Subnets can also be deleted.
Does this approach make sense for this unique case?
| const numResources = isNodebalancerVPCEnabled | ||
| ? getUniqueResourcesFromSubnets( | ||
| vpc.subnets, | ||
| flags.vpcDbaasResources ?? false |
There was a problem hiding this comment.
For the new vpcDbaasResources feature flag, in addition to hiding the databases table, the resource count fix is also behind this flag. I assumed we want the table to appear along with the updated count, so I've chosen to keep both changes behind the new feature flag for this reason.
| id: 5, | ||
| label: 'database-instance-5', | ||
| }); | ||
| const ids = Array.from({ length: 5 }, (_, i) => i + 1); // Update length to change the number of databases |
There was a problem hiding this comment.
Added this to make it a bit easier to control the length of the mock data. You can see something similar in the */v4beta/vpcs/:vpcId/subnets listener below that was also updated in this pull request.
| databasesFilter, | ||
| isDefaultEnabled // TODO (UIE-8634): Determine if check if still necessary | ||
| isDefaultEnabled, // TODO (UIE-8634): Determine if check if still necessary | ||
| 20000 |
There was a problem hiding this comment.
For more info, refer to my previous comment on the databases query.
| } | ||
|
|
||
| return [primaryIPv4, ...failoverIPv4s].join(', '); | ||
| }; |
There was a problem hiding this comment.
This logic uses the members property to get the content for the IPv4 field that can be seen in the wireframes.
packages/manager/src/features/VPCs/VPCDetail/SubnetDatabaseRow.tsx
Outdated
Show resolved
Hide resolved
| // Retrieve failover IPv4 addresses as there can be multiple | ||
| const failoverIPv4s = memberKeys.filter( | ||
| (key) => database.members[key] === 'failover' | ||
| ); | ||
|
|
||
| if (failoverIPv4s.length === 0) { | ||
| return primaryIPv4; | ||
| } |
There was a problem hiding this comment.
Can we move this early return above primaryIPv4?
There was a problem hiding this comment.
The behavior for this is, if there aren't any failover IPV4s in the members property, it should display just the primaryIPv4 as IPv4AddressesContent. Otherwise it will display the primary IPv4 followed by the failoverIPv4s. I don't think we can return this early as it would need primaryIPv4 defined before it can be returned.
There was a problem hiding this comment.
I'm going to update this to include an early return for when there's only 1 item in the members object. It should be safe to assume that it's the primary IP and return it as the content in the row.
if (memberKeys.length === 1) {
return memberKeys[0];
}This way we'll only perform the additional logic to find the primary and failover IPV4s if there's more than 1 key in the members object.
| const theme = useTheme(); | ||
|
|
||
| const [pageSize, setPageSize] = React.useState(25); | ||
| const [page, setPage] = React.useState(1); |
| const assignedDatabasesMap = React.useMemo(() => { | ||
| const databaseMap: Record<number, SubnetAssignedDatabaseData> = {}; | ||
| databasesData.forEach((assignedDatabase) => { | ||
| databaseMap[assignedDatabase.id] = assignedDatabase; | ||
| }); | ||
| return databaseMap; | ||
| }, [databasesData]); | ||
|
|
||
| // Create filter using unique database IDs from the assigned databases | ||
| const makeDatabaseIDsFilter = React.useMemo(() => { | ||
| const uniqueIds = Object.values(assignedDatabasesMap).map((db) => { | ||
| return { id: db.id }; | ||
| }); | ||
|
|
||
| return { | ||
| '+or': uniqueIds, | ||
| }; | ||
| }, [assignedDatabasesMap]); |
There was a problem hiding this comment.
We can simplify this to something like
| const assignedDatabasesMap = React.useMemo(() => { | |
| const databaseMap: Record<number, SubnetAssignedDatabaseData> = {}; | |
| databasesData.forEach((assignedDatabase) => { | |
| databaseMap[assignedDatabase.id] = assignedDatabase; | |
| }); | |
| return databaseMap; | |
| }, [databasesData]); | |
| // Create filter using unique database IDs from the assigned databases | |
| const makeDatabaseIDsFilter = React.useMemo(() => { | |
| const uniqueIds = Object.values(assignedDatabasesMap).map((db) => { | |
| return { id: db.id }; | |
| }); | |
| return { | |
| '+or': uniqueIds, | |
| }; | |
| }, [assignedDatabasesMap]); | |
| const databaseIDsToFilter = databasesData.map((database) => ({ | |
| id: database.id, | |
| })); |
There was a problem hiding this comment.
@hana-akamai We could use this instead of the makeDatabaseIDsFilter function, but this wouldn't work for the assignedDatabasesMap since that is meant to store the assigned databases data that we get back from the /subnets response. The map gets used in the SubnetDatabaseRow below that displays data from those assigned databases
There was a problem hiding this comment.
What about simplifying it to something like this so we still have access to the assigned database data for the rows?
const assignedDatabasesMap: Record<number, SubnetAssignedDatabaseData> = {};
const databaseIDsToFilter = databasesData.map((database) => {
// Store database data in map for easy lookup for rendering subnet database rows
assignedDatabasesMap[database.id] = database;
return {
id: database.id,
};
});Then access it in the SubnetDatabaseRow like this:
<SubnetDatabaseRow
assignedDatabase={assignedDatabasesMap[database.id]}
...
/>
packages/manager/src/features/VPCs/VPCDetail/SubnetDatabasesTable.tsx
Outdated
Show resolved
Hide resolved
packages/manager/src/features/VPCs/VPCDetail/SubnetDatabasesTable.tsx
Outdated
Show resolved
Hide resolved
packages/manager/src/features/VPCs/VPCDetail/SubnetDatabasesTable.tsx
Outdated
Show resolved
Hide resolved
80d3e4c to
b308124
Compare
Cloud Manager UI test results🔺 1 failing test on test run #5 ↗︎
Details
TroubleshootingUse this command to re-run the failing tests: pnpm cy:run -s "cypress/e2e/core/objectStorage/object-storage.e2e.spec.ts" |
|||||||||||||||||

Description 📝
This pull request fixes an issue in the VPC UI where DBaaS resources aren't being counted or displayed.
This issue consists of the following:
Changes 🔄
List any change(s) relevant to the reviewer.
vpcDbaasResourcesfeature flagScope 🚢
Upon production release, changes in this PR will be visible to:
Target release date 🗓️
TBD
Preview 📷
Note: The screenshots below are using mock data, so the data shown may not be accurate. The resource counts behavior will need to be checked using the verification steps that follow.
Databases Resource Tables Not displaying under expanded Subnet in VPC Details View
Resource Count Locations in VPC:

VPC Landing Table
VPC Detail Summary and Subnets Table

*Note: The count in the summary is inaccurate. Use the verification steps to test this behavior.
How to test 🧪
Prerequisites
(How to setup test environment)
VPC DBaaS ResourcesReproduction steps
Test the VPC workflow
stagingenvironment, access the VPC tab, select theCreate VPCand create a new VPC and Subnet in a region. Preferably one that doesn't currently have one. For example,US, Chicago, IL. Keep track of the region for this new VPC/Subnet.Networkingtab and keep it opensubnetscall (*/vpcs/{vpcID}/subnets) and inspect the response to see thatdatabasesproperty is currently an empty arraySummaryand Subnets table below show a resource count of 0, which is accuratelinodestable is displayed in an empty state.Create a new database and assign the VPC/Subnet you created and retest the steps above
Create Database ClusterTest the VPC workflowsteps above.subnetscall returns the databases property with a single database in the array, but the resource counts on all pages are still 0.databasestable is shown.Verification steps
(How to verify changes)
Testing the Resource Counts
Testing the database resources table under the expanded Subnet
*/v4beta/vpcs/:vpcId/subnetslistener.subnetscall (*/vpcs/{vpcID}/subnets) and inspect the response to see thatdatabasesproperty has 5 items listed.Author Checklists
As an Author, to speed up the review process, I considered 🤔
👀 Doing a self review
❔ Our contribution guidelines
🤏 Splitting feature into small PRs
➕ Adding a changeset
🧪 Providing/improving test coverage
🔐 Removing all sensitive information from the code and PR description
🚩 Using a feature flag to protect the release
👣 Providing comprehensive reproduction steps
📑 Providing or updating our documentation
🕛 Scheduling a pair reviewing session
📱 Providing mobile support
♿ Providing accessibility support
As an Author, before moving this PR from Draft to Open, I confirmed ✅