diff --git a/locales/en/plugin__nmstate-console-plugin.json b/locales/en/plugin__nmstate-console-plugin.json index 8010d1db..8446bcf1 100644 --- a/locales/en/plugin__nmstate-console-plugin.json +++ b/locales/en/plugin__nmstate-console-plugin.json @@ -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", @@ -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>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>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.", diff --git a/src/utils/components/PolicyForm/PolicyWizard/steps/NodesConfigurationStep/components/NodeSelectionRadioGroup.tsx b/src/utils/components/PolicyForm/PolicyWizard/steps/NodesConfigurationStep/components/NodeSelectionRadioGroup.tsx index 30bdd36d..db7d518c 100644 --- a/src/utils/components/PolicyForm/PolicyWizard/steps/NodesConfigurationStep/components/NodeSelectionRadioGroup.tsx +++ b/src/utils/components/PolicyForm/PolicyWizard/steps/NodesConfigurationStep/components/NodeSelectionRadioGroup.tsx @@ -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 = { diff --git a/src/utils/components/PolicyForm/PolicyWizard/steps/UplinkConnectionStep/UplinkConnectionStep.tsx b/src/utils/components/PolicyForm/PolicyWizard/steps/UplinkConnectionStep/UplinkConnectionStep.tsx index ed551cff..1c47e8f8 100644 --- a/src/utils/components/PolicyForm/PolicyWizard/steps/UplinkConnectionStep/UplinkConnectionStep.tsx +++ b/src/utils/components/PolicyForm/PolicyWizard/steps/UplinkConnectionStep/UplinkConnectionStep.tsx @@ -65,7 +65,7 @@ const UplinkConnectionStep: FC = ({ setPolicy, policy const bondName = `bond-${getRandomChars(10)}`; const bridgePorts = getBridgePorts(draftPolicy); draftPolicy.spec.desiredState.interfaces = [ - getInitialBridgeInterface([...bridgePorts, { name: bondName }]), + getInitialBridgeInterface([...bridgePorts]), getInitialLinuxBondInterface(bondName), bridgeManagementInterface, ]; diff --git a/src/utils/components/PolicyForm/PolicyWizard/steps/UplinkConnectionStep/components/BondingInterfaceContent/BondingInterfaceContent.tsx b/src/utils/components/PolicyForm/PolicyWizard/steps/UplinkConnectionStep/components/BondingInterfaceContent/BondingInterfaceContent.tsx index eeb0ae0d..2a56c055 100644 --- a/src/utils/components/PolicyForm/PolicyWizard/steps/UplinkConnectionStep/components/BondingInterfaceContent/BondingInterfaceContent.tsx +++ b/src/utils/components/PolicyForm/PolicyWizard/steps/UplinkConnectionStep/components/BondingInterfaceContent/BondingInterfaceContent.tsx @@ -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'; @@ -39,7 +34,7 @@ const BondingInterfaceContent: FC = ({ const handleNameChange = (newName: string) => { setPolicy((draftPolicy) => { - getBondInterface(draftPolicy).name = newName; + getBond(draftPolicy).name = newName; }); setNameValidationMessage(validateName(newName)); }; @@ -68,14 +63,9 @@ const BondingInterfaceContent: FC = ({ - These network interfaces will be bonded together. The list contains unused network - interfaces available on all of the selected nodes. -
- Unused network interfaces available on all of the selected nodes. - - } + 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')} /> diff --git a/src/utils/components/PolicyForm/PolicyWizard/steps/UplinkConnectionStep/components/BondingInterfaceContent/components/AggregationModeSelect.tsx b/src/utils/components/PolicyForm/PolicyWizard/steps/UplinkConnectionStep/components/BondingInterfaceContent/components/AggregationModeSelect.tsx index 436157dd..bf6b4f4a 100644 --- a/src/utils/components/PolicyForm/PolicyWizard/steps/UplinkConnectionStep/components/BondingInterfaceContent/components/AggregationModeSelect.tsx +++ b/src/utils/components/PolicyForm/PolicyWizard/steps/UplinkConnectionStep/components/BondingInterfaceContent/components/AggregationModeSelect.tsx @@ -30,8 +30,6 @@ const AggregationModeSelect: FC = ({ policy, setPoli const handleAggregationModeChange = (_, selectedMode: string) => { setPolicy((draftPolicy) => { updateBondType(draftPolicy, selectedMode); - // getLinkAggregationSettings(draftPolicy).mode = - // selectedMode as NodeNetworkConfigurationInterfaceBondMode; }); setIsOpen(false); }; diff --git a/src/utils/components/PolicyForm/PolicyWizard/steps/UplinkConnectionStep/components/BondingInterfaceContent/utils/utils.ts b/src/utils/components/PolicyForm/PolicyWizard/steps/UplinkConnectionStep/components/BondingInterfaceContent/utils/utils.ts index 834e5ba6..32cbc55a 100644 --- a/src/utils/components/PolicyForm/PolicyWizard/steps/UplinkConnectionStep/components/BondingInterfaceContent/utils/utils.ts +++ b/src/utils/components/PolicyForm/PolicyWizard/steps/UplinkConnectionStep/components/BondingInterfaceContent/utils/utils.ts @@ -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]: { diff --git a/src/utils/components/PolicyForm/PolicyWizard/utils/initialState.ts b/src/utils/components/PolicyForm/PolicyWizard/utils/initialState.ts index e28ed9c2..11f91136 100644 --- a/src/utils/components/PolicyForm/PolicyWizard/utils/initialState.ts +++ b/src/utils/components/PolicyForm/PolicyWizard/utils/initialState.ts @@ -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'; @@ -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 || [], }, }); diff --git a/src/utils/components/PolicyForm/PolicyWizard/utils/selectors.ts b/src/utils/components/PolicyForm/PolicyWizard/utils/selectors.ts index 22c2810e..5e95f76d 100644 --- a/src/utils/components/PolicyForm/PolicyWizard/utils/selectors.ts +++ b/src/utils/components/PolicyForm/PolicyWizard/utils/selectors.ts @@ -29,7 +29,7 @@ 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; @@ -37,12 +37,14 @@ export const getMTU = (policy: V1NodeNetworkConfigurationPolicy) => 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; @@ -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; diff --git a/src/utils/components/PolicyForm/PolicyWizard/utils/utils.ts b/src/utils/components/PolicyForm/PolicyWizard/utils/utils.ts index d00bb075..fff0f8f2 100644 --- a/src/utils/components/PolicyForm/PolicyWizard/utils/utils.ts +++ b/src/utils/components/PolicyForm/PolicyWizard/utils/utils.ts @@ -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, @@ -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); } }; diff --git a/src/views/policies/list/PoliciesList.tsx b/src/views/policies/list/PoliciesList.tsx index 43cc5bfc..069c3302 100644 --- a/src/views/policies/list/PoliciesList.tsx +++ b/src/views/policies/list/PoliciesList.tsx @@ -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'; @@ -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();