Better error messages when IP address autodetection fails
| ... | ... |
@@ -8,7 +8,6 @@ import ( |
| 8 | 8 |
|
| 9 | 9 |
var ( |
| 10 | 10 |
errNoSuchInterface = errors.New("no such interface")
|
| 11 |
- errMultipleIPs = errors.New("could not choose an IP address to advertise since this system has multiple addresses")
|
|
| 12 | 11 |
errNoIP = errors.New("could not find the system's IP address")
|
| 13 | 12 |
errMustSpecifyListenAddr = errors.New("must specify a listening address because the address to advertise is not recognized as a system address")
|
| 14 | 13 |
errBadListenAddr = errors.New("listen address must be an IP address or network interface (with optional port number)")
|
| ... | ... |
@@ -159,6 +158,7 @@ func (c *Cluster) resolveSystemAddr() (net.IP, error) {
|
| 159 | 159 |
} |
| 160 | 160 |
|
| 161 | 161 |
var systemAddr net.IP |
| 162 |
+ var systemInterface net.Interface |
|
| 162 | 163 |
|
| 163 | 164 |
// List Docker-managed subnets |
| 164 | 165 |
v4Subnets := c.config.NetworkSubnetsProvider.V4Subnets() |
| ... | ... |
@@ -197,7 +197,7 @@ ifaceLoop: |
| 197 | 197 |
} |
| 198 | 198 |
|
| 199 | 199 |
if interfaceAddr4 != nil {
|
| 200 |
- return nil, errMultipleIPs |
|
| 200 |
+ return nil, fmt.Errorf("could not choose an IP address to advertise since this system has multiple addresses on interface %s (%s and %s)", intf.Name, interfaceAddr4, ipAddr.IP)
|
|
| 201 | 201 |
} |
| 202 | 202 |
|
| 203 | 203 |
interfaceAddr4 = ipAddr.IP |
| ... | ... |
@@ -212,7 +212,7 @@ ifaceLoop: |
| 212 | 212 |
} |
| 213 | 213 |
|
| 214 | 214 |
if interfaceAddr6 != nil {
|
| 215 |
- return nil, errMultipleIPs |
|
| 215 |
+ return nil, fmt.Errorf("could not choose an IP address to advertise since this system has multiple addresses on interface %s (%s and %s)", intf.Name, interfaceAddr6, ipAddr.IP)
|
|
| 216 | 216 |
} |
| 217 | 217 |
|
| 218 | 218 |
interfaceAddr6 = ipAddr.IP |
| ... | ... |
@@ -223,14 +223,16 @@ ifaceLoop: |
| 223 | 223 |
// and exactly one IPv6 address, favor IPv4 over IPv6. |
| 224 | 224 |
if interfaceAddr4 != nil {
|
| 225 | 225 |
if systemAddr != nil {
|
| 226 |
- return nil, errMultipleIPs |
|
| 226 |
+ return nil, fmt.Errorf("could not choose an IP address to advertise since this system has multiple addresses on different interfaces (%s on %s and %s on %s)", systemAddr, systemInterface.Name, interfaceAddr4, intf.Name)
|
|
| 227 | 227 |
} |
| 228 | 228 |
systemAddr = interfaceAddr4 |
| 229 |
+ systemInterface = intf |
|
| 229 | 230 |
} else if interfaceAddr6 != nil {
|
| 230 | 231 |
if systemAddr != nil {
|
| 231 |
- return nil, errMultipleIPs |
|
| 232 |
+ return nil, fmt.Errorf("could not choose an IP address to advertise since this system has multiple addresses on different interfaces (%s on %s and %s on %s)", systemAddr, systemInterface.Name, interfaceAddr6, intf.Name)
|
|
| 232 | 233 |
} |
| 233 | 234 |
systemAddr = interfaceAddr6 |
| 235 |
+ systemInterface = intf |
|
| 234 | 236 |
} |
| 235 | 237 |
} |
| 236 | 238 |
|