Skip to content

Commit d610464

Browse files
authored
Merge pull request kubeedge#2739 from fisherxu/fix-getlocalip
pkg/util/util.go: fix get local ip issue
2 parents e0b29cc + a6cf000 commit d610464

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pkg/util/util.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ import (
3333

3434
func GetLocalIP(hostName string) (string, error) {
3535
var ipAddr net.IP
36-
addrs, err := net.LookupIP(hostName)
37-
if err != nil {
38-
return "", err
39-
}
36+
var err error
37+
38+
// If looks up host failed, will use utilnet.ChooseHostInterface() below,
39+
// So ignore the error here
40+
addrs, _ := net.LookupIP(hostName)
4041
for _, addr := range addrs {
4142
if err := ValidateNodeIP(addr); err != nil {
4243
continue
@@ -49,6 +50,7 @@ func GetLocalIP(hostName string) (string, error) {
4950
ipAddr = addr
5051
}
5152
}
53+
5254
if ipAddr == nil {
5355
ipAddr, err = utilnet.ChooseHostInterface()
5456
if err != nil {

0 commit comments

Comments
 (0)