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: Always order discovered network interfaces #7705

Merged

Conversation

chrisroberts
Copy link
Member

Ensure the order of discovered network interfaces is always consistent. Addresses issue described in #7668

@mvanbaak
Copy link

LGTM

@mvanbaak
Copy link

I will test today :)

@mvanbaak
Copy link

Tested and it fixes our problem! Thanks a lot!

@agusti-t
Copy link

agusti-t commented Aug 12, 2016

Hi, I'm also trying to build in the PR into my clone of vagrant. I'm relatively new to github and building vagrant myself. I managed to create a branch with the PR but when I issue:

bundle _1.12.5_ update

I get

...
Using vagrant-spec 0.0.1 from https://github.com/mitchellh/vagrant-spec.git (at master@9bba7e1)
...

How can I make it use the latest from my branch with the PR pulled?

UPDATE:

I know realised this is unrelated to my question, the output above relates to a separate repo. I still would like a way to verify the @chrisroberts PR is build into my newly built version.

@agusti-t
Copy link

agusti-t commented Aug 12, 2016

I think I got the patch in:

DEBUG guest: Found cap: configure_networks in redhat
 INFO guest: Execute capability: configure_networks [#<Vagrant::Machine: buildmaster (VagrantPlugins::ProviderVirtualBox::Provider)>, [{:type=>:static, :adapter_ip=>"192.168.33.1", :ip=>"192.168.33.10", :netmask=>"255.255.255.0", :auto_config=>true, :interface=>1}]] (redhat)
DEBUG ssh: Checking whether SSH is ready...
DEBUG ssh: Re-using SSH connection.
 INFO ssh: SSH is ready!
DEBUG ssh: Re-using SSH connection.
 INFO ssh: Execute:  (sudo=false)
DEBUG ssh: Exit status: 0
DEBUG guest: Searching for cap: network_scripts_dir
DEBUG guest: Checking in: redhat
DEBUG guest: Found cap: network_scripts_dir in redhat
 INFO guest: Execute capability: network_scripts_dir [#<Vagrant::Machine: buildmaster (VagrantPlugins::ProviderVirtualBox::Provider)>] (redhat)
DEBUG ssh: Checking whether SSH is ready...
DEBUG ssh: Re-using SSH connection.
 INFO ssh: SSH is ready!
DEBUG ssh: Re-using SSH connection.
 INFO ssh: Execute:  (sudo=false)
DEBUG ssh: Exit status: 0
DEBUG guest: Searching for cap: network_interfaces
DEBUG guest: Checking in: redhat
DEBUG guest: Checking in: linux
DEBUG guest: Found cap: network_interfaces in linux
 INFO guest: Execute capability: network_interfaces [#<Vagrant::Machine: buildmaster (VagrantPlugins::ProviderVirtualBox::Provider)>] (redhat)
DEBUG ssh: Re-using SSH connection.
 INFO ssh: Execute: /sbin/ip -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://' (sudo=true)
DEBUG ssh: Exit status: 0
DEBUG ssh: Uploading: /var/folders/hl/zb5t5j1d3txfm_bmnz2bc8902gxcq8/T/vagrant-redhat-configure-networks20160812-32065-dx7ywp to /tmp/vagrant-network-entry-eth1-1471008239-0
DEBUG ssh: Re-using SSH connection.
DEBUG ssh: Re-using SSH connection.
 INFO ssh: Execute: # Down the interface before munging the config file. This might
# fail if the interface is not actually set up yet so ignore
# errors.
/sbin/ifdown 'eth1' || true

# Move new config into place
mv '/tmp/vagrant-network-entry-eth1-1471008239-0' '/etc/sysconfig/network-scripts/ifcfg-eth1'

# Bring the interface up
ARPCHECK=no /sbin/ifup 'eth1'
 (sudo=true)
DEBUG ssh: stderr: usage: ifdown <configuration>

But still no ip:

[vagrant@buildmaster ~]$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:c3:c0:db brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic eth0
       valid_lft 86223sec preferred_lft 86223sec
    inet6 fe80::5054:ff:fec3:c0db/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:a4:0d:21 brd ff:ff:ff:ff:ff:ff`

What am I doing wrong?

@agusti-t
Copy link

agusti-t commented Aug 12, 2016

Now I'm starting to go crazy, and apparently, from the n00b-silence-of-death I'm getting, this is not the place to ask this. But now I went to:

[vagrant@buildmaster ~]$ more /etc/sysconfig/network-scripts/ifcfg-eth1
#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
NM_CONTROLLED=no
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.33.10
NETMASK=255.255.255.0
DEVICE=eth1
PEERDNS=no
#VAGRANT-END

And actually see that the IP is there, why, in the name of ClearCase, is not shown when I do ip addr show?

@agusti-t
Copy link

agusti-t commented Aug 12, 2016

Missed me?

Now I did this:

[vagrant@buildmaster ~]$ sudo systemctl restart network
[vagrant@buildmaster ~]$ sudo service network status
Configured devices:
lo eth0 eth1
Currently active devices:
lo eth0 eth1
[vagrant@buildmaster ~]$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:c3:c0:db brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic eth0
       valid_lft 86373sec preferred_lft 86373sec
    inet6 fe80::5054:ff:fec3:c0db/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:a4:0d:21 brd ff:ff:ff:ff:ff:ff
    inet 192.168.33.10/24 brd 192.168.33.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fea4:d21/64 scope link
       valid_lft forever preferred_lft forever

And it works!!!! What is then my problem? Is this a bug?

@chrisroberts @mvanbaak

@chrisroberts chrisroberts force-pushed the fix/linux-guest-net-iface branch from a4a8ab9 to 9222821 Compare August 12, 2016 15:26
@chrisroberts
Copy link
Member Author

Using the mvbcoding/awslinux box referenced in #7668 I was able to reproduce the error using v1.8.5 and able to resolve using this changeset. Added test coverage to validate interface ordering from the network interfaces capability to ensure consistent ordering in the future.

@chrisroberts
Copy link
Member Author

@agusti-t Hi! General help questions will be better answered on the mailing list: https://groups.google.com/forum/#!forum/vagrant-up

Thanks!

@sethvargo
Copy link
Contributor

This LGTM, but it might be good to log the "raw" and then "sorted" interfaces, just so we can better track down any potential bugs that might crop up on archaine OSes

@chrisroberts
Copy link
Member Author

👍

@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
Development

Successfully merging this pull request may close these issues.

5 participants