Skip to content

Commit

Permalink
MGMT-18439: Handle undefined majority_groups gracefully (#2643)
Browse files Browse the repository at this point in the history
  • Loading branch information
rawagner authored Jul 23, 2024
1 parent b61e1f9 commit f391ce7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions libs/ui-lib/lib/cim/components/helpers/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AgentClusterInstallK8sResource } from '../../types/k8s/agent-cluster-in

type ConnectivityMajorityGroups = {
l3_connected_addresses: object;
majority_groups: { [key: string]: string[] };
majority_groups?: { [key: string]: string[] };
};

export const getHostNetworks = (
Expand All @@ -18,12 +18,14 @@ export const getHostNetworks = (
agentClusterInstall.status.connectivityMajorityGroups,
) as ConnectivityMajorityGroups;

return Object.keys(connectivityMajorityGroups.majority_groups)
const majorityGroups = connectivityMajorityGroups.majority_groups || {};

return Object.keys(majorityGroups)
.filter((k) => !['IPv4', 'IPv6'].includes(k))
.map((cidr) => {
const hostIds: string[] = [];

connectivityMajorityGroups.majority_groups[cidr].forEach((hostName: string) => {
majorityGroups[cidr].forEach((hostName: string) => {
const agent: AgentK8sResource | undefined = agents.find(
(agent) => agent.metadata?.name === hostName,
);
Expand Down

0 comments on commit f391ce7

Please sign in to comment.