You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Better error messages when IP address autodetection fails
This fix tries to improve error messages when IP address
autodetection fails, as is specified in 25141.
Previously, error messages only indicate that multiple IPs
exist when autodetection fails. In this fix, if one
interface consists of multiple addresses or multiple
interfaces consist of addresses, the error messages output
the address names and interface names so that end user could
take notice.
This fix is verified manually.
When multiple addresses exist on multiple interfaces:
```
$ sudo docker swarm init
Error response from daemon: could not choose an IP address
to advertise since this system has multiple addresses on different
interfaces (192.168.186.128 on ens33 and 192.168.100.199 on eth10)
- specify one with --advertise-addr
```
When multiple addresses exist on single interface:
```
$ sudo docker swarm init
Error response from daemon: could not choose an IP address
to advertise since this system has multiple addresses
on interface ens33 (192.168.186.128 and 192.168.55.199)
- specify one with --advertise-addr
```
This fix fixes 25141.
Signed-off-by: Yong Tang <[email protected]>
returnnil, 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
ifinterfaceAddr6!=nil {
215
-
returnnil, errMultipleIPs
215
+
returnnil, 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
ifinterfaceAddr4!=nil {
225
225
ifsystemAddr!=nil {
226
-
returnnil, errMultipleIPs
226
+
returnnil, 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
} elseifinterfaceAddr6!=nil {
230
231
ifsystemAddr!=nil {
231
-
returnnil, errMultipleIPs
232
+
returnnil, 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)
0 commit comments