Skip to content

Commit

Permalink
Fix loopback IP to work when there's only one plane
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Jerram committed Oct 14, 2019
1 parent ce56080 commit 55cfb0a
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions pkg/internal/cluster/providers/docker/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,27 @@ func (n *node) IP() (ipv4 string, ipv6 string, err error) {
if len(lines) != 1 {
return "", "", errors.Errorf("file should only be one line, got %d lines", len(lines))
}
// If the node has a loopback address, that provides the IPv4.
loopAddr, err := n.Loopback()
if err == nil && loopAddr != "" {
fmt.Printf("%v: use IPv4 loopback address %v\n", n.name, loopAddr)
ipv4 = loopAddr
}
ips := strings.Split(lines[0], ",")
if len(ips) != 2 {
//return "", "", errors.Errorf("container addresses should have 2 values, got %d values", len(ips))
fmt.Printf("%v: %#v\n", n.name, ips)
// If the node has a loopback address, that overrides the IPv4 one.
loopAddr, err := n.Loopback()
if err == nil && loopAddr != "" {
fmt.Printf("%v: use IPv4 loopback address %v\n", n.name, loopAddr)
return loopAddr, ips[1], nil
for _, ip := range ips {
if strings.Contains(ip, ":") {
// IPv6.
if ipv6 == "" {
ipv6 = ip
}
} else {
// IPv4
if ipv4 == "" {
ipv4 = ip
}
}
return ips[0], "", nil
}
return ips[0], ips[1], nil
return
}

func (n *node) Command(command string, args ...string) exec.Cmd {
Expand Down

0 comments on commit 55cfb0a

Please sign in to comment.