Skip to content
Open
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
4 changes: 2 additions & 2 deletions locales/en/plugin__nmstate-console-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
"Number of nodes matched": "Number of nodes matched",
"One active, others standby, simple": "One active, others standby, simple",
"Open vSwitch bridge mapping": "Open vSwitch bridge mapping",
"Open vSwitch LSB - source load balancing": "Open vSwitch LSB - source load balancing",
"Open vSwitch SLB - source load balancing": "Open vSwitch SLB - source load balancing",
"Other network type": "Other network type",
"Overlapping nodes": "Overlapping nodes",
"OVN localnet name": "OVN localnet name",
Expand Down Expand Up @@ -239,7 +239,7 @@
"The largest size of a data packet, in bytes, that can be transmitted across this network. It is critical that the entire underlying physical network infrastructure also supports the same or larger MTU size to avoid packet fragmentation and connectivity issues.": "The largest size of a data packet, in bytes, that can be transmitted across this network. It is critical that the entire underlying physical network infrastructure also supports the same or larger MTU size to avoid packet fragmentation and connectivity issues.",
"The Open vSwitch bridge mapping is a list of Open vSwitch bridges and the physical interfaces that are connected to them.": "The Open vSwitch bridge mapping is a list of Open vSwitch bridges and the physical interfaces that are connected to them.",
"The selected secondary interface is configured with an IP address on some of the nodes.": "The selected secondary interface is configured with an IP address on some of the nodes.",
"These network interfaces will be bonded together. The list contains unused network interfaces available on all of the selected nodes.<1></1>Unused network interfaces available on all of the selected nodes.": "These network interfaces will be bonded together. The list contains unused network interfaces available on all of the selected nodes.<1></1>Unused network interfaces available on all of the selected nodes.",
"These network interfaces will be bonded together. The list contains unused network interfaces available on all of the selected nodes.": "These network interfaces will be bonded together. The list contains unused network interfaces available on all of the selected nodes.",
"This allows you to specify how the ethernet interface obtains an IPv4 address—either dynamically (DHCP) or by assigning a static IP and subnet.": "This allows you to specify how the ethernet interface obtains an IPv4 address—either dynamically (DHCP) or by assigning a static IP and subnet.",
"This is the list of ports to copy MAC address from. Select one of the matched ports this policy will apply to": "This is the list of ports to copy MAC address from. Select one of the matched ports this policy will apply to",
"This name is already in use. Use a different name to continue.": "This name is already in use. Use a different name to continue.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import NodeSelectorModal from '@utils/components/NodeSelectorModal/NodeSelectorM
import { isEmpty } from '@utils/helpers';
import { useNMStateTranslation } from '@utils/hooks/useNMStateTranslation';
import { getNodeSelector } from '@utils/resources/policies/getters';

import { WORKER_NODE_LABEL } from '../../../utils/constants';

type NodeSelectionRadioGroupProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const UplinkConnectionStep: FC<UplinkConnectionStepProps> = ({ setPolicy, policy
const bondName = `bond-${getRandomChars(10)}`;
const bridgePorts = getBridgePorts(draftPolicy);
draftPolicy.spec.desiredState.interfaces = [
getInitialBridgeInterface([...bridgePorts, { name: bondName }]),
getInitialBridgeInterface([...bridgePorts]),
getInitialLinuxBondInterface(bondName),
bridgeManagementInterface,
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ import FormGroupHelperText from '@utils/components/FormGroupHelperText/FormGroup
import TextWithHelpIcon from '@utils/components/HelpTextIcon/TextWithHelpIcon';
import AggregationModeSelect from '@utils/components/PolicyForm/PolicyWizard/steps/UplinkConnectionStep/components/BondingInterfaceContent/components/AggregationModeSelect';
import useBridgeNameValidation from '@utils/components/PolicyForm/PolicyWizard/utils/hooks/useBridgeNameValidation';
import {
getBondInterface,
getBondName,
getInterfaceName,
getPolicyInterface,
} from '@utils/components/PolicyForm/PolicyWizard/utils/selectors';
import { getBond, getBondName } from '@utils/components/PolicyForm/PolicyWizard/utils/selectors';
import { useNMStateTranslation } from '@utils/hooks/useNMStateTranslation';

import NetworkInterfacesSelect from './components/NetworkInterfacesSelect';
Expand All @@ -39,7 +34,7 @@ const BondingInterfaceContent: FC<BondingInterfaceContentProps> = ({

const handleNameChange = (newName: string) => {
setPolicy((draftPolicy) => {
getBondInterface(draftPolicy).name = newName;
getBond(draftPolicy).name = newName;
});
setNameValidationMessage(validateName(newName));
};
Expand Down Expand Up @@ -68,14 +63,9 @@ const BondingInterfaceContent: FC<BondingInterfaceContentProps> = ({
<FormGroup
label={
<TextWithHelpIcon
helpBodyContent={
<Trans t={t} ns="plugin__nmstate-console-plugin">
These network interfaces will be bonded together. The list contains unused network
interfaces available on all of the selected nodes.
<br />
Unused network interfaces available on all of the selected nodes.
</Trans>
}
helpBodyContent={t(
'These network interfaces will be bonded together. The list contains unused network interfaces available on all of the selected nodes.',
)}
helpHeaderContent={t('Network interfaces')}
text={t('Network interfaces')}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ const AggregationModeSelect: FC<AggregationModeSelectProps> = ({ policy, setPoli
const handleAggregationModeChange = (_, selectedMode: string) => {
setPolicy((draftPolicy) => {
updateBondType(draftPolicy, selectedMode);
// getLinkAggregationSettings(draftPolicy).mode =
// selectedMode as NodeNetworkConfigurationInterfaceBondMode;
});
setIsOpen(false);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { NodeNetworkConfigurationInterfaceBondMode as AggregationMode } from '..
export const aggregationModes = {
[AggregationMode.BALANCE_SLB]: {
description: t('Load balancing, no switch config'),
label: t('Open vSwitch LSB - source load balancing'),
label: t('Open vSwitch SLB - source load balancing'),
helperText: t('Failover results in loss of guest network connectivity.'),
},
[AggregationMode.ACTIVE_BACKUP]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
import {
DEFAULT_OVN_BRIDGE_NAME,
DEFAULT_OVS_BRIDGE_NAME,
WORKER_NODE_LABEL,
} from '@utils/components/PolicyForm/PolicyWizard/utils/constants';
import { NETWORK_STATES } from '@utils/components/PolicyForm/utils/constants';
import { getRandomChars } from '@utils/helpers';
Expand Down Expand Up @@ -40,12 +39,16 @@ export const bridgeManagementInterface = {
ipv6: { enabled: false },
} as NodeNetworkConfigurationInterface;

export const getInitialLinuxBondInterface = (bondName: string, ports?: string[]) => ({
export const getInitialLinuxBondInterface = (
bondName: string,
ports?: string[],
aggregationMode?: string,
) => ({
name: bondName,
type: InterfaceType.BOND,
state: NETWORK_STATES.Up,
'link-aggregation': {
mode: '',
mode: aggregationMode || '',
port: ports || [],
},
});
Expand Down
13 changes: 7 additions & 6 deletions src/utils/components/PolicyForm/PolicyWizard/utils/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,22 @@ export const getBondInterface = (policy: V1NodeNetworkConfigurationPolicy) =>
getPolicyBondingInterfaces(policy)?.[0];

export const getPolicyInterface = (policy: V1NodeNetworkConfigurationPolicy) =>
policy?.spec?.desiredState?.interfaces?.[0];
getPolicyInterfaces(policy)?.[0];

export const getMTU = (policy: V1NodeNetworkConfigurationPolicy) =>
getBridgeManagementInterface(policy)?.mtu;

export const getInterfaceName = (policy: V1NodeNetworkConfigurationPolicy) =>
getPolicyInterface(policy)?.name;

export const getBond = (policy: V1NodeNetworkConfigurationPolicy) =>
getBondInterface(policy) || getOVSBridgeBondPort(policy);

export const getLinkAggregationSettings = (policy: V1NodeNetworkConfigurationPolicy) =>
getBondInterface(policy)?.[LINK_AGGREGATION] || getOVSBridgeBondPort(policy)?.[LINK_AGGREGATION];
getBond(policy)?.[LINK_AGGREGATION];

export const getAggregationMode = (policy: V1NodeNetworkConfigurationPolicy) =>
getLinkAggregationSettings(policy)?.mode ||
getOVSBridgeBondPort(policy)?.[LINK_AGGREGATION]?.mode;
getLinkAggregationSettings(policy)?.mode;

export const getBondInterfacePorts = (policy: V1NodeNetworkConfigurationPolicy): string[] =>
getBondInterface(policy)?.[LINK_AGGREGATION]?.port;
Expand Down Expand Up @@ -78,8 +80,7 @@ export const getOVNLocalnet = (policy: V1NodeNetworkConfigurationPolicy) =>
export const getOVNBridgeName = (policy: V1NodeNetworkConfigurationPolicy) =>
getOVNBridgeMapping(policy)?.bridge;

export const getBondName = (policy: V1NodeNetworkConfigurationPolicy) =>
getBondInterface(policy)?.name;
export const getBondName = (policy: V1NodeNetworkConfigurationPolicy) => getBond(policy)?.name;

export const getBridgeName = (policy: V1NodeNetworkConfigurationPolicy) =>
getBridgeInterface(policy)?.name;
83 changes: 50 additions & 33 deletions src/utils/components/PolicyForm/PolicyWizard/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import {
MIN_NUM_INTERFACES_FOR_BOND,
NUM_INTERFACES_FOR_SINGLE_INTERFACE_UPLINK,
} from '@utils/components/PolicyForm/PolicyWizard/utils/constants';
import {
getInitialBridgeInterface,
getInitialLinuxBondInterface,
} from '@utils/components/PolicyForm/PolicyWizard/utils/initialState';
import { getInitialLinuxBondInterface } from '@utils/components/PolicyForm/PolicyWizard/utils/initialState';
import {
getAggregationMode,
getBondInterface,
Expand Down Expand Up @@ -112,45 +109,65 @@ export const updateBondInterfaces = (
getLinkAggregationSettings(policy).port = getBondPorts(policy);
};

export const updateBondType = (
const updateLinuxBonding = (
policy: V1NodeNetworkConfigurationPolicy,
bondPortNames: string[],
selectedAggregationMode: string,
) => {
const bondPortNames = getBondPortNames(policy);

if (selectedAggregationMode === AggregationMode.BALANCE_RR) {
const bondInterface = getBondInterface(policy);

if (!bondInterface) {
const interfaces = policy?.spec?.desiredState?.interfaces;
policy.spec.desiredState.interfaces = [
...interfaces,
getInitialLinuxBondInterface(generateBondName(), bondPortNames),
];
getBridgeInterface(policy).bridge.port = getBridgePorts(policy).filter(
(port) => !port?.[LINK_AGGREGATION],
);
}
const bondInterface = getBondInterface(policy);

if (!bondInterface) {
const interfaces = getPolicyInterfaces(policy);
policy.spec.desiredState.interfaces = [
...interfaces,
getInitialLinuxBondInterface(getBondName(policy), bondPortNames, selectedAggregationMode),
];
getBridgeInterface(policy).bridge.port = getBridgePorts(policy).filter(
(port) => !port?.[LINK_AGGREGATION],
);
} else {
const bridgeBondPort = getOVSBridgeBondPort(policy);
getLinkAggregationSettings(policy).mode = selectedAggregationMode;
}
};

const updateOVSBonding = (
policy: V1NodeNetworkConfigurationPolicy,
bondPortNames: string[],
selectedAggregationMode: string,
) => {
const bridgeBondPort = getOVSBridgeBondPort(policy);

if (!bridgeBondPort) {
const bridgePorts = getBridgePorts(policy)?.filter(
(port) => port?.name !== getBondName(policy),
);

if (!bridgeBondPort) {
getBridgeInterface(policy).bridge.port = [
...bridgePorts,
{
name: getBondName(policy) || generateBondName(),
[LINK_AGGREGATION]: {
mode: selectedAggregationMode,
port: getPortNamesAsPorts(bondPortNames),
},
getBridgeInterface(policy).bridge.port = [
...bridgePorts,
{
name: getBondName(policy),
[LINK_AGGREGATION]: {
mode: selectedAggregationMode,
port: getPortNamesAsPorts(bondPortNames),
},
];
}
},
];
policy.spec.desiredState.interfaces = getPolicyInterfaces(policy)?.filter(
(iface) => iface?.type !== InterfaceType.BOND,
);
} else {
getLinkAggregationSettings(policy).mode = selectedAggregationMode;
}
};

export const updateBondType = (
policy: V1NodeNetworkConfigurationPolicy,
selectedAggregationMode: string,
) => {
const bondPortNames = getBondPortNames(policy);

if (selectedAggregationMode === AggregationMode.BALANCE_SLB) {
updateOVSBonding(policy, bondPortNames, selectedAggregationMode);
} else {
updateLinuxBonding(policy, bondPortNames, selectedAggregationMode);
}
};
2 changes: 1 addition & 1 deletion src/views/policies/list/PoliciesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
useListPageFilter,
VirtualizedTable,
} from '@openshift-console/dynamic-plugin-sdk';
import { isEmpty } from '@utils/helpers';
import { getPolicyEnactments } from '@utils/resources/policies/utils';

import { EnactmentStatuses } from '../constants';
Expand All @@ -29,7 +30,6 @@ import PolicyListEmptyState from './components/PolicyListEmptyState/PolicyListEm
import PolicyRow from './components/PolicyRow';
import usePolicyColumns from './hooks/usePolicyColumns';
import usePolicyFilters from './hooks/usePolicyFilters';
import { isEmpty } from '@utils/helpers';

const PoliciesList: FC = () => {
const { t } = useNMStateTranslation();
Expand Down