Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(node): setup-networking component #3135

Draft
wants to merge 66 commits into
base: master
Choose a base branch
from

Conversation

andrewbattat
Copy link
Member

@andrewbattat andrewbattat commented Dec 12, 2024

NODE-1542

  • Replace large parts of our rust networking library with a new setup-networking component that uses netplan to generate networking.

The old networking crate would:

  1. Sort the interfaces by descending speed
  2. Test connectivity for each interface (bring the interface UP, assign an IPv6 address, loop pinging gateway)
  3. Write networkd configuration files for the selected interface.

The new networking component is much simpler and less error prone: it creates a bond containing all the interfaces sorted by speed and assigns the bond to the bridge using netplan.

A test script has been created to accompany the script.

@andrewbattat andrewbattat self-assigned this Dec 12, 2024
@andrewbattat andrewbattat changed the title feat(node) setup-networking component feat(node): setup-networking component Dec 12, 2024
@github-actions github-actions bot added the feat label Dec 12, 2024
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must merge setupos/hostos addition of Netplan packages before merging this PR: #3289

@tmshlvck
Copy link
Contributor

I wonder what is the state when the script runs? Do we have any systemd-networkd config active at that point? Assuming that Netplan (that uses systemd-networkd is installed there can be some interference that would eventually lead to install time issues. Maybe using netns for the tests may avoid that by just adding a few commands to the script.

Another concern is the interface name - we use the interface name in bridge setup and then in ethernet we use it as an identifier but we do not rename based on MAC. This will work as long as kernel+ACPI+udev do not change the interface name (unlikely but possible - there is a BIOS setting on some SuperMicro servers that allows to enable/disable ACPI tree element that carry "predictable name" -> interface name may change based on BIOS settings). If there is a change it would bind the interface based on MAC but it would fail bridge setup. Consider adding set-name statement (see https://netplan.readthedocs.io/en/latest/netplan-yaml/).

@tmshlvck
Copy link
Contributor

tmshlvck commented Dec 25, 2024

Btw. is the

      networkd:
        lldp: true

in 99-setup.yaml.template doing the expected thing (enabling LLDP on the ethernet interface)? I believe the Netplan config attribute for this is emit-lldp without the networkd nesting - please see https://netplan.readthedocs.io/en/latest/netplan-yaml/


# Dynamically add ethernets for each interface in descending speed
for IFACE in $SORTED_INTERFACES; do
sed -i "/^ ethernets:/a \ \ \ \ $IFACE:\n mtu: 1500\n optional: true\n emit-lldp: true\n" "$NETPLAN_OUTPUT"
Copy link
Member Author

@andrewbattat andrewbattat Dec 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spawned from: #3135 (comment)

In our old code, we were writing the following values to systemd-networkd directly (see Systemd.rs):

LLDP=true
EmitLLDP=true

Netplan does have an LLDP property, and only an emit-lldp property. Is this sufficient?

From my basic understanding, it seems the default of routers-only is sufficient

Comment on lines +70 to +76
SYS_NET_PATH="${SYS_NET_PATH:-/sys/class/net}"
INTERFACES=($(find "$SYS_NET_PATH" -type l -not -lname '*virtual*' -exec basename '{}' ';'))
declare -A SPEED_MAP

for IFACE in "${INTERFACES[@]}"; do
if [ -f "$SYS_NET_PATH/$IFACE/speed" ]; then
SPEED=$(cat "$SYS_NET_PATH/$IFACE/speed" 2>/dev/null || echo 0)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to draw attention to the way we're gathering interface speeds. I'm curious what PFOPS thinks of this. Does this seem proper? In the old code, we were parsing the output of Ethtool to gather speeds (see interfaces.rs)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At a high level, do we like moving forward with this idea of putting all the interfaces in a single bond and prioritizing interface usage by speed?

The only significant concern I have is if there are two interfaces connected, but the one selected first is just an internal connection. If that’s the case, I’m concerned that the bond won’t fall through to the next interface, and therefore, networking will fail. I understand that the internal networks are usually set up on the 1G ports, so hopefully this won’t be an issue as the 10G interfaces will be prioritized by speed, but this is still something I want to test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving this discussion to a thread (@tmshlvck)

I wonder what is the state when the script runs? Do we have any systemd-networkd config active at that point? Assuming that Netplan (that uses systemd-networkd is installed there can be some interference that would eventually lead to install time issues. Maybe using netns for the tests may avoid that by just adding a few commands to the script.

Is having the setup-networking.service files running Before=network.target network-online.target not sufficient?

Or is the "script" you're talking about the test-setup-networking.sh script? Sorry, I don't entirely follow.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving this discussion to a thread (@tmshlvck)

Another concern is the interface name - we use the interface name in bridge setup and then in ethernet we use it as an identifier but we do not rename based on MAC. This will work as long as kernel+ACPI+udev do not change the interface name (unlikely but possible - there is a BIOS setting on some SuperMicro servers that allows to enable/disable ACPI tree element that carry "predictable name" -> interface name may change based on BIOS settings). If there is a change it would bind the interface based on MAC but it would fail bridge setup. Consider adding set-name statement (see https://netplan.readthedocs.io/en/latest/netplan-yaml/).

I do want to keep the networking code as simple as possible. Is this change necessary? I'll follow you're judgement, I just want to be certain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants