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

guests/linux: Place ethernet devices at start of device list #7848

Merged
merged 2 commits into from
Sep 30, 2016

Conversation

chrisroberts
Copy link
Member

Always provide sorted ethernet devices at the start of the network devices list.

Fixes #7844

# Valid ethernet device prefix values.
# eth - classic prefix
# en - predictable interface names prefix
ETHERNET_PREFIX = ["eth", "en"]
Copy link
Contributor

Choose a reason for hiding this comment

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

We should freeze this.

Copy link
Contributor

Choose a reason for hiding this comment

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

And possibly name it something more descriptive like POSSIBLE_ETHERNET_PREFIXES

result = cap.network_interfaces(machine)
expect(result).to eq(["enp0s3", "enp0s5", "enp0s8", "bridge0", "docker0"])
end

Copy link
Contributor

Choose a reason for hiding this comment

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

Extra newline here

@@logger.debug("Unsorted list: #{ifaces.inspect}")
# Break out integers from strings and sort the arrays to provide
# a natural sort for the interface names
ifaces = ifaces.map do |iface|
unless eth_prefix
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it's Ruby, but neither @mitchellh or I are a fan of the "unless" and much prefer if ! or if .nil? since it mentally maps better to the Golang folks who might look at this code in some future.

@chrisroberts
Copy link
Member Author

@sethvargo updated

@lhernanz
Copy link

lhernanz commented Oct 4, 2016

Hi team,
after applying the new version of plugins/guests/linux/cap/network_interfaces.rb to an stock 1.8.6 version, the original problem is indeed fixed (the configuration process completes), but the algorithm is not working as intended. This is what I get:

DEBUG network_interfaces: Unsorted list: ["enp0s3", "enp0s8", "docker0"]
DEBUG network_interfaces: Sorted list: ["docker0", "enp0s3", "enp0s8"]
DEBUG network_interfaces: Ethernet preferred sorted list: ["enp0s3", "docker0", "enp0s8"]

The outcome is that the private network configuration is applied to docker0 instead of enp0s8.

Regards.

@chrisroberts
Copy link
Member Author

@lhernanz Hi and thanks for the update! There have been a few other cases pointed out as well that need some adjustment. I'll be pushing out a new PR with expanded specs and an update shortly. Cheers!

@ghost
Copy link

ghost commented Apr 3, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants