@@ -315,6 +315,13 @@ export const VPCSubnetsTable = (props: Props) => {
315315
316316 const getTableItems = ( ) : TableItem [ ] => {
317317 return subnets . data . map ( ( subnet ) => {
318+ // NodeBalancers can have same VPC subnet as its frontend and backend configuration.
319+ // and this can create duplicate entries in the resources count and also in the list of nodebalancers assigned to a subnet.
320+ // To avoid this, we are creating a unique list of nodebalancers based on their id.
321+ const uniqueNodebalancers = Array . from (
322+ new Map ( subnet . nodebalancers . map ( ( nb ) => [ nb . id , nb ] ) ) . values ( )
323+ ) ;
324+
318325 const OuterTableCells = (
319326 < >
320327 < Hidden smDown >
@@ -326,7 +333,7 @@ export const VPCSubnetsTable = (props: Props) => {
326333 ) }
327334 < Hidden smDown >
328335 < TableCell >
329- { `${ isNodebalancerVPCEnabled ? subnet . linodes . length + subnet . nodebalancers . length : subnet . linodes . length } ` }
336+ { `${ isNodebalancerVPCEnabled ? subnet . linodes . length + uniqueNodebalancers . length : subnet . linodes . length } ` }
330337 </ TableCell >
331338 </ Hidden >
332339 < TableCell actionCell >
@@ -336,7 +343,7 @@ export const VPCSubnetsTable = (props: Props) => {
336343 handleEdit = { handleSubnetEdit }
337344 handleUnassignLinodes = { handleSubnetUnassignLinodes }
338345 numLinodes = { subnet . linodes . length }
339- numNodebalancers = { subnet . nodebalancers . length }
346+ numNodebalancers = { uniqueNodebalancers . length }
340347 subnet = { subnet }
341348 vpcId = { vpcId }
342349 />
@@ -376,7 +383,7 @@ export const VPCSubnetsTable = (props: Props) => {
376383 ) }
377384 </ TableBody >
378385 </ Table >
379- { isNodebalancerVPCEnabled && subnet . nodebalancers ? .length > 0 && (
386+ { isNodebalancerVPCEnabled && uniqueNodebalancers . length > 0 && (
380387 < Table aria-label = "NodeBalancers" size = "small" striped = { false } >
381388 < TableHead
382389 style = { {
@@ -386,7 +393,7 @@ export const VPCSubnetsTable = (props: Props) => {
386393 { SubnetNodebalancerTableRowHead }
387394 </ TableHead >
388395 < TableBody >
389- { subnet . nodebalancers . map ( ( nb ) => (
396+ { uniqueNodebalancers . map ( ( nb ) => (
390397 < SubnetNodeBalancerRow
391398 key = { nb . id }
392399 nodeBalancerId = { nb . id }
0 commit comments