Skip to content

Commit

Permalink
MGMT-18439: Handle undefined majority_groups gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
rawagner authored and jgyselov committed Jul 23, 2024
1 parent 6ff32fa commit 54d7c9e
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 54d7c9e

Please sign in to comment.