@@ -20,6 +20,7 @@ import (
2020 "context"
2121 "fmt"
2222 "io"
23+ "net"
2324 "strings"
2425
2526 "sigs.k8s.io/kind/pkg/errors"
@@ -53,9 +54,12 @@ func (n *node) Role() (string, error) {
5354func (n * node ) IP () (ipv4 string , ipv6 string , err error ) {
5455 // Give the node a chance to indicate its own canonical IPs.
5556 output , err := exec .Output (exec .Command ("docker" , "exec" , n .name , "/get-ips.sh" ))
56- if err == nil {
57- ips := strings .Split (strings .TrimSpace (string (output )), " " )
58- fmt .Printf ("Node %v provided IPs: %v\n " , n .name , ips )
57+ if err != nil {
58+ return "" , "" , errors .Wrap (err , fmt .Sprintf ("get-ips.sh failed. Output: %s" , output ))
59+ }
60+
61+ ips := strings .Split (strings .TrimSpace (string (output )), " " )
62+ if net .ParseIP (ips [0 ]) != nil && net .ParseIP (ips [1 ]) != nil {
5963 return ips [0 ], ips [1 ], nil
6064 }
6165
@@ -71,7 +75,7 @@ func (n *node) IP() (ipv4 string, ipv6 string, err error) {
7175 if len (lines ) != 1 {
7276 return "" , "" , errors .Errorf ("file should only be one line, got %d lines" , len (lines ))
7377 }
74- ips : = strings .Split (lines [0 ], "," )
78+ ips = strings .Split (lines [0 ], "," )
7579 if len (ips ) != 2 {
7680 return "" , "" , errors .Errorf ("container addresses should have 2 values, got %d values" , len (ips ))
7781 }
0 commit comments