@@ -952,139 +952,128 @@ contents:
952952 # print initial state
953953 print_state
954954
955- if [ "$1" == "OVNKubernetes" ]; then
956- # Configures NICs onto OVS bridge "br-ex"
957- # Configuration is either auto-detected or provided through a config file written already in Network Manager
958- # key files under /etc/NetworkManager/system-connections/
959- # Managing key files is outside of the scope of this script
960-
961- # if the interface is of type vmxnet3 add multicast capability for that driver
962- # History: BZ:1854355
963- function configure_driver_options {
964- intf=$1
965- if [ ! -f "/sys/class/net/${intf}/device/uevent" ]; then
966- echo "Device file doesn't exist, skipping setting multicast mode"
967- else
968- driver=$(cat "/sys/class/net/${intf}/device/uevent" | grep DRIVER | awk -F "=" '{print $2}')
969- echo "Driver name is" $driver
970- if [ "$driver" = "vmxnet3" ]; then
971- ip link set dev "${intf}" allmulticast on
972- fi
973- fi
974- }
975-
976- ovnk_config_dir='/etc/ovnk'
977- ovnk_var_dir='/var/lib/ovnk'
978- extra_bridge_file="${ovnk_config_dir}/extra_bridge"
979- iface_default_hint_file="${ovnk_var_dir}/iface_default_hint"
980- ip_hint_file="/run/nodeip-configuration/primary-ip"
981- # explicitly specify which interface should be used with the default bridge
982- default_bridge_file="${ovnk_config_dir}/default_bridge"
983-
984- # make sure to create ovnk_config_dir if it does not exist, yet
985- mkdir -p "${ovnk_config_dir}"
986- # make sure to create ovnk_var_dir if it does not exist, yet
987- mkdir -p "${ovnk_var_dir}"
988-
989- # For upgrade scenarios, make sure that we stabilize what we already configured
990- # before. If we do not have a valid interface hint, find the physical interface
991- # that's attached to ovs-if-phys0.
992- # If we find such an interface, write it to the hint file.
993- iface_default_hint=$(get_iface_default_hint "${iface_default_hint_file}")
994- if [ "${iface_default_hint}" == "" ]; then
995- current_interface=$(get_bridge_physical_interface ovs-if-phys0)
996- if [ "${current_interface}" != "" ]; then
997- write_iface_default_hint "${iface_default_hint_file}" "${current_interface}"
955+ # Configures NICs onto OVS bridge "br-ex"
956+ # Configuration is either auto-detected or provided through a config file written already in Network Manager
957+ # key files under /etc/NetworkManager/system-connections/
958+ # Managing key files is outside of the scope of this script
959+
960+ # if the interface is of type vmxnet3 add multicast capability for that driver
961+ # History: BZ:1854355
962+ function configure_driver_options {
963+ intf=$1
964+ if [ ! -f "/sys/class/net/${intf}/device/uevent" ]; then
965+ echo "Device file doesn't exist, skipping setting multicast mode"
966+ else
967+ driver=$(cat "/sys/class/net/${intf}/device/uevent" | grep DRIVER | awk -F "=" '{print $2}')
968+ echo "Driver name is" $driver
969+ if [ "$driver" = "vmxnet3" ]; then
970+ ip link set dev "${intf}" allmulticast on
998971 fi
999972 fi
1000-
1001- # delete iface_default_hint_file if it has the same content as extra_bridge_file
1002- # in that case, we must also force a reconfiguration of our network interfaces
1003- # to make sure that we reconcile this conflict
1004- if [ -f "${iface_default_hint_file}" ] &&
1005- [ -f "${extra_bridge_file}" ] &&
1006- [ "$(cat "${iface_default_hint_file}")" == "$(cat "${extra_bridge_file}")" ]; then
1007- echo "${iface_default_hint_file} and ${extra_bridge_file} share the same content"
1008- echo "Deleting file ${iface_default_hint_file} to choose a different interface"
1009- rm -f "${iface_default_hint_file}"
1010- rm -f /run/configure-ovs-boot-done
973+ }
974+
975+ ovnk_config_dir='/etc/ovnk'
976+ ovnk_var_dir='/var/lib/ovnk'
977+ extra_bridge_file="${ovnk_config_dir}/extra_bridge"
978+ iface_default_hint_file="${ovnk_var_dir}/iface_default_hint"
979+ ip_hint_file="/run/nodeip-configuration/primary-ip"
980+ # explicitly specify which interface should be used with the default bridge
981+ default_bridge_file="${ovnk_config_dir}/default_bridge"
982+
983+ # make sure to create ovnk_config_dir if it does not exist, yet
984+ mkdir -p "${ovnk_config_dir}"
985+ # make sure to create ovnk_var_dir if it does not exist, yet
986+ mkdir -p "${ovnk_var_dir}"
987+
988+ # For upgrade scenarios, make sure that we stabilize what we already configured
989+ # before. If we do not have a valid interface hint, find the physical interface
990+ # that's attached to ovs-if-phys0.
991+ # If we find such an interface, write it to the hint file.
992+ iface_default_hint=$(get_iface_default_hint "${iface_default_hint_file}")
993+ if [ "${iface_default_hint}" == "" ]; then
994+ current_interface=$(get_bridge_physical_interface ovs-if-phys0)
995+ if [ "${current_interface}" != "" ]; then
996+ write_iface_default_hint "${iface_default_hint_file}" "${current_interface}"
1011997 fi
998+ fi
999+
1000+ # delete iface_default_hint_file if it has the same content as extra_bridge_file
1001+ # in that case, we must also force a reconfiguration of our network interfaces
1002+ # to make sure that we reconcile this conflict
1003+ if [ -f "${iface_default_hint_file}" ] &&
1004+ [ -f "${extra_bridge_file}" ] &&
1005+ [ "$(cat "${iface_default_hint_file}")" == "$(cat "${extra_bridge_file}")" ]; then
1006+ echo "${iface_default_hint_file} and ${extra_bridge_file} share the same content"
1007+ echo "Deleting file ${iface_default_hint_file} to choose a different interface"
1008+ rm -f "${iface_default_hint_file}"
1009+ rm -f /run/configure-ovs-boot-done
1010+ fi
10121011
1013- # on every boot we rollback and generate the configuration again, to take
1014- # in any changes that have possibly been applied in the standard
1015- # configuration sources
1016- if [ ! -f /run/configure-ovs-boot-done ]; then
1017- echo "Running on boot, restoring previous configuration before proceeding..."
1012+ # on every boot we rollback and generate the configuration again, to take
1013+ # in any changes that have possibly been applied in the standard
1014+ # configuration sources
1015+ if [ ! -f /run/configure-ovs-boot-done ]; then
1016+ echo "Running on boot, restoring previous configuration before proceeding..."
1017+ rollback_nm
1018+ print_state
1019+ fi
1020+ touch /run/configure-ovs-boot-done
1021+
1022+ iface=$(get_default_bridge_interface "${iface_default_hint_file}" "${extra_bridge_file}" "${ip_hint_file}" "${default_bridge_file}")
1023+
1024+ if [ "$iface" != "br-ex" ]; then
1025+ # Specified interface is not br-ex.
1026+ # Some deployments use a temporary solution where br-ex is moved out from the default gateway interface
1027+ # and bound to a different nic (https://github.com/trozet/openshift-ovn-migration).
1028+ # This is now supported through an extra bridge if requested. If that is the case, we rollback.
1029+ # We also rollback if it looks like we need to configure things, just in case there are any leftovers
1030+ # from previous attempts.
1031+ if [ -f "$extra_bridge_file" ] || [ -z "$(nmcli connection show --active br-ex 2> /dev/null)" ]; then
1032+ echo "Bridge br-ex is not active, restoring previous configuration before proceeding..."
10181033 rollback_nm
10191034 print_state
10201035 fi
1021- touch /run/configure-ovs-boot-done
1022-
1023- iface=$(get_default_bridge_interface "${iface_default_hint_file}" "${extra_bridge_file}" "${ip_hint_file}" "${default_bridge_file}")
1024-
1025- if [ "$iface" != "br-ex" ]; then
1026- # Specified interface is not br-ex.
1027- # Some deployments use a temporary solution where br-ex is moved out from the default gateway interface
1028- # and bound to a different nic (https://github.com/trozet/openshift-ovn-migration).
1029- # This is now supported through an extra bridge if requested. If that is the case, we rollback.
1030- # We also rollback if it looks like we need to configure things, just in case there are any leftovers
1031- # from previous attempts.
1032- if [ -f "$extra_bridge_file" ] || [ -z "$(nmcli connection show --active br-ex 2> /dev/null)" ]; then
1033- echo "Bridge br-ex is not active, restoring previous configuration before proceeding..."
1034- rollback_nm
1035- print_state
1036- fi
1037- fi
1036+ fi
10381037
1039- convert_to_bridge "$iface" "br-ex" "phys0" "${BRIDGE_METRIC}"
1038+ convert_to_bridge "$iface" "br-ex" "phys0" "${BRIDGE_METRIC}"
10401039
1041- # Check if we need to configure the second bridge
1042- if [ -f "$extra_bridge_file" ] && (! nmcli connection show br-ex1 &> /dev/null || ! nmcli connection show ovs-if-phys1 &> /dev/null); then
1043- interface=$(head -n 1 $extra_bridge_file)
1044- convert_to_bridge "$interface" "br-ex1" "phys1" "${BRIDGE1_METRIC}"
1045- fi
1040+ # Check if we need to configure the second bridge
1041+ if [ -f "$extra_bridge_file" ] && (! nmcli connection show br-ex1 &> /dev/null || ! nmcli connection show ovs-if-phys1 &> /dev/null); then
1042+ interface=$(head -n 1 $extra_bridge_file)
1043+ convert_to_bridge "$interface" "br-ex1" "phys1" "${BRIDGE1_METRIC}"
1044+ fi
10461045
1047- # Check if we need to remove the second bridge
1048- if [ ! -f "$extra_bridge_file" ] && (nmcli connection show br-ex1 &> /dev/null || nmcli connection show ovs-if-phys1 &> /dev/null); then
1049- remove_ovn_bridges br-ex1 phys1
1050- fi
1046+ # Check if we need to remove the second bridge
1047+ if [ ! -f "$extra_bridge_file" ] && (nmcli connection show br-ex1 &> /dev/null || nmcli connection show ovs-if-phys1 &> /dev/null); then
1048+ remove_ovn_bridges br-ex1 phys1
1049+ fi
10511050
1052- # Remove bridges created by openshift-sdn
1053- ovs-vsctl --timeout=30 --if-exists del-br br0
1054-
1055- # Make sure everything is activated. Do it in a specific order:
1056- # - activate br-ex first, due to autoconnect-slaves this will also
1057- # activate ovs-port-br-ex, ovs-port-phys0 and ovs-if-phys0. It is
1058- # important that ovs-if-phys0 activates with br-ex to avoid the
1059- # ovs-if-phys0 profile being overridden with a profile generated from
1060- # kargs. The activation of ovs-if-phys0, if a bond, might cause the
1061- # slaves to re-activate, but it should be with our profiles since they
1062- # have higher priority
1063- # - make sure that ovs-if-phys0 and its slaves, if any, are activated.
1064- # - finally activate ovs-if-br-ex which holds the IP configuration.
1065- connections=(br-ex ovs-if-phys0)
1066- if [ -f "$extra_bridge_file" ]; then
1067- connections+=(br-ex1 ovs-if-phys1)
1068- fi
1069- while IFS= read -r connection; do
1070- if [[ $connection == *"$MANAGED_NM_CONN_SUFFIX" ]]; then
1071- connections+=("$connection")
1072- fi
1073- done < <(nmcli -g NAME c)
1074- connections+=(ovs-if-br-ex)
1075- if [ -f "$extra_bridge_file" ]; then
1076- connections+=(ovs-if-br-ex1)
1051+ # Make sure everything is activated. Do it in a specific order:
1052+ # - activate br-ex first, due to autoconnect-slaves this will also
1053+ # activate ovs-port-br-ex, ovs-port-phys0 and ovs-if-phys0. It is
1054+ # important that ovs-if-phys0 activates with br-ex to avoid the
1055+ # ovs-if-phys0 profile being overridden with a profile generated from
1056+ # kargs. The activation of ovs-if-phys0, if a bond, might cause the
1057+ # slaves to re-activate, but it should be with our profiles since they
1058+ # have higher priority
1059+ # - make sure that ovs-if-phys0 and its slaves, if any, are activated.
1060+ # - finally activate ovs-if-br-ex which holds the IP configuration.
1061+ connections=(br-ex ovs-if-phys0)
1062+ if [ -f "$extra_bridge_file" ]; then
1063+ connections+=(br-ex1 ovs-if-phys1)
1064+ fi
1065+ while IFS= read -r connection; do
1066+ if [[ $connection == *"$MANAGED_NM_CONN_SUFFIX" ]]; then
1067+ connections+=("$connection")
10771068 fi
1078- activate_nm_connections "${connections[@]}"
1079- try_to_bind_ipv6_address
1080- set_nm_conn_files
1081- elif [ "$1" == "OpenShiftSDN" ]; then
1082- # Revert changes made by /usr/local/bin/configure-ovs.sh during SDN migration.
1083- rollback_nm
1084-
1085- # Remove bridges created by ovn-kubernetes
1086- ovs-vsctl --timeout=30 --if-exists del-br br-int -- --if-exists del-br br-local
1069+ done < <(nmcli -g NAME c)
1070+ connections+=(ovs-if-br-ex)
1071+ if [ -f "$extra_bridge_file" ]; then
1072+ connections+=(ovs-if-br-ex1)
10871073 fi
1074+ activate_nm_connections "${connections[@]}"
1075+ try_to_bind_ipv6_address
1076+ set_nm_conn_files
10881077 }
10891078
10901079 # Retry configure_ovs until it succeeds.
0 commit comments