Add logic to dynamically discover primary interface name#196
Add logic to dynamically discover primary interface name#196liwenwu-amazon merged 1 commit intoaws:masterfrom
Conversation
mogren
left a comment
There was a problem hiding this comment.
On what images have you tested this change? Ubuntu? CentOS?
|
|
||
| log.Debugf("Trying to find primary interface that has mac : %s", primaryMAC) | ||
|
|
||
| interfaces, err := net.Interfaces() |
There was a problem hiding this comment.
This call to list all interfaces is probably the biggest change. 😄
There was a problem hiding this comment.
I have only tested using amazon linux worker AMI. Since net.Interface() should works on all flavors of Linux, such as CentOS or Ubuntu, this change should work for CentOS and Ubuntu.
There was a problem hiding this comment.
@mogren I just unit tested the net.Interfaces() call on ubuntu t3.large instance. It is working as expected.
Here is the test program
cat test.go
package main
import (
"fmt"
"net"
)
func main() {
interfaces, _ := net.Interfaces()
for _, intf := range interfaces {
fmt.Printf("interface %v, mac %v\n", intf.Name, intf.HardwareAddr)
}
}
Here is the test output
root@ip-172-31-0-186:/home/ubuntu# ./test
interface lo, mac
interface ens5, mac 0a:5f:92:e3:59:86
Here is the output of ifconfig
root@ip-172-31-0-186:/home/ubuntu# ifconfig
ens5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9001
inet 172.31.0.186 netmask 255.255.240.0 broadcast 172.31.15.255
inet6 fe80::85f:92ff:fee3:5986 prefixlen 64 scopeid 0x20<link>
ether 0a:5f:92:e3:59:86 txqueuelen 1000 (Ethernet)
RX packets 6072 bytes 7297970 (7.2 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1699 bytes 199849 (199.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 191 bytes 14956 (14.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 191 bytes 14956 (14.9 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
@ewbankkit @phyllisstein, can you verify if this PR fixed your CNI in your environment? thanks |
|
@liwenwu-amazon This is awesome, thanks so much for taking up the issue! I just migrated from Kops with Ubuntu back to EKS with Amazon's Kube AMI, but I'll try rebuilding my Kops cluster again with this change in the next couple of days. |
|
Yes, I should be able to verify in the next couple of days too. |
0764543 to
b569b59
Compare
|
@liwenwu-amazon I have verified that building from the latest |
|
Confirmed that v1.2.1 does the trick with Ubuntu 18.04 as well. Thanks again! |
Issue #171 , if available:
Description of changes:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.