|
| 1 | +variant: openshift |
| 2 | +version: 4.16.0 |
| 3 | +metadata: |
| 4 | + name: 00-master-bm-vlan-mtu-9000 |
| 5 | + labels: |
| 6 | + machineconfiguration.openshift.io/role: master |
| 7 | +storage: |
| 8 | + files: |
| 9 | + - mode: 0755 |
| 10 | + path: "/usr/local/sbin/bm-mtu-configure.sh" |
| 11 | + contents: |
| 12 | + inline: | |
| 13 | + #!/bin/bash |
| 14 | + # Configure MTU=9000 on VLAN-backed bare metal interfaces |
| 15 | + # This script runs at boot to ensure OVN-Kubernetes has sufficient MTU |
| 16 | + # for its Geneve overlay (8900+ 58 bytes encapsulation = 8958 minimum) |
| 17 | + # |
| 18 | + # Problem: Bare metal shapes with VLAN-backed networking (like BM.Standard.E5.192, |
| 19 | + # BM.Standard.E6.256) default to MTU 1500 on RHCOS, causing OVN to fail. |
| 20 | + # |
| 21 | + # Solution: Dynamically detect VLAN interfaces and set MTU=9000 on parent+VLAN. |
| 22 | + # Uses ip commands directly (no NetworkManager dependency). |
| 23 | + # Includes guards to skip VM workers and already-configured nodes. |
| 24 | + |
| 25 | + set -euo pipefail |
| 26 | + |
| 27 | + # Guard 1: No VLAN interfaces => no-op (virtual workers) |
| 28 | + vlans=$(ip -o link show type vlan | awk '{print $2}' | sed 's/:$//' | sed 's/@.*//' || true) |
| 29 | + if [ -z "$vlans" ]; then |
| 30 | + echo "[INFO] No VLAN interfaces found, exiting (no-op for VM workers)" |
| 31 | + exit 0 |
| 32 | + fi |
| 33 | + |
| 34 | + echo "[INFO] Found VLAN interfaces: $vlans" |
| 35 | + |
| 36 | + # Process each VLAN interface |
| 37 | + for vlan in $vlans; do |
| 38 | + # Extract parent interface name |
| 39 | + # VLAN interfaces are named: parent.vlanid or parent.vlanid@parent |
| 40 | + # Strip everything from first dot onwards to get parent |
| 41 | + parent=$(echo "$vlan" | sed 's/\..*//') |
| 42 | + |
| 43 | + if [ -z "$parent" ] || [ "$parent" = "$vlan" ]; then |
| 44 | + echo "[WARN] Could not determine parent for $vlan, skipping" |
| 45 | + continue |
| 46 | + fi |
| 47 | + |
| 48 | + # Get current MTU from actual devices (not NetworkManager) |
| 49 | + parent_mtu=$(ip link show "$parent" 2>/dev/null | grep -oP 'mtu \K[0-9]+' || echo 0) |
| 50 | + vlan_mtu=$(ip link show "$vlan" 2>/dev/null | grep -oP 'mtu \K[0-9]+' || echo 0) |
| 51 | + |
| 52 | + echo "[INFO] $parent: MTU=$parent_mtu, $vlan: MTU=$vlan_mtu" |
| 53 | + |
| 54 | + # Guard 2: Already jumbo => no-op (idempotent) |
| 55 | + if [ "$parent_mtu" -ge 9000 ] && [ "$vlan_mtu" -ge 9000 ]; then |
| 56 | + echo "[INFO] $parent and $vlan already have MTU >= 9000, no changes needed" |
| 57 | + continue |
| 58 | + fi |
| 59 | + |
| 60 | + echo "[ACTION] Setting MTU=9000 on $parent and $vlan" |
| 61 | + |
| 62 | + # Set MTU on parent device (if needed) |
| 63 | + if [ "$parent_mtu" -lt 9000 ]; then |
| 64 | + ip link set dev "$parent" mtu 9000 |
| 65 | + echo "[SUCCESS] Set MTU=9000 on $parent" |
| 66 | + fi |
| 67 | + |
| 68 | + # Set MTU on VLAN device (if needed) |
| 69 | + if [ "$vlan_mtu" -lt 9000 ]; then |
| 70 | + ip link set dev "$vlan" mtu 9000 |
| 71 | + echo "[SUCCESS] Set MTU=9000 on $vlan" |
| 72 | + fi |
| 73 | + |
| 74 | + echo "[SUCCESS] MTU configuration complete for $parent and $vlan" |
| 75 | + done |
| 76 | + |
| 77 | + # Also set br-ex MTU if it exists (OVS bridge created by ovs-configuration.service) |
| 78 | + # This handles the case where the script runs after OVS has started |
| 79 | + if ip link show br-ex &>/dev/null; then |
| 80 | + br_ex_mtu=$(ip link show br-ex 2>/dev/null | grep -oP 'mtu \K[0-9]+' || echo 0) |
| 81 | + if [ "$br_ex_mtu" -lt 9000 ]; then |
| 82 | + echo "[ACTION] Setting MTU=9000 on br-ex" |
| 83 | + if command -v ovs-vsctl &>/dev/null; then |
| 84 | + ovs-vsctl set Interface br-ex mtu_request=9000 && echo "[SUCCESS] Set MTU=9000 on br-ex" |
| 85 | + fi |
| 86 | + else |
| 87 | + echo "[INFO] br-ex already has MTU >= 9000" |
| 88 | + fi |
| 89 | + fi |
| 90 | + |
| 91 | + echo "[INFO] bm-mtu-configure.sh completed successfully" |
| 92 | + exit 0 |
| 93 | +systemd: |
| 94 | + units: |
| 95 | + - name: bm-mtu-configure.service |
| 96 | + enabled: true |
| 97 | + contents: | |
| 98 | + [Unit] |
| 99 | + Description=Configure MTU=9000 on VLAN-backed bare metal interfaces |
| 100 | + Documentation=https://github.com/oracle-quickstart/oci-openshift/issues/78 |
| 101 | + After=NetworkManager.service oci-eval-user-data.service |
| 102 | + Before=ovs-configuration.service kubelet.service |
| 103 | + ConditionPathExists=/usr/local/sbin/bm-mtu-configure.sh |
| 104 | + |
| 105 | + [Service] |
| 106 | + Type=oneshot |
| 107 | + ExecStart=/usr/local/sbin/bm-mtu-configure.sh |
| 108 | + RemainAfterExit=yes |
| 109 | + StandardOutput=journal+console |
| 110 | + StandardError=journal+console |
| 111 | + |
| 112 | + [Install] |
| 113 | + WantedBy=multi-user.target |
0 commit comments