Ignore virtual ethernet devices that disappear (#51581)

When checking if a device is up, today we can run into virtual ethernet
devices that disappear while we are in the middle of checking. This
leads to "no such device". This commit addresses such devices by
treating them as not being up, if they are virtual ethernet devices that
disappeared while we were checking.
This commit is contained in:
Jason Tedor 2020-01-28 18:44:06 -05:00
parent 3a7192966a
commit b080237837
No known key found for this signature in database
GPG Key ID: FA89F05560F16BC5
1 changed files with 4 additions and 0 deletions

View File

@ -172,6 +172,10 @@ public abstract class NetworkUtils {
try {
return intf.isUp();
} catch (final SocketException e) {
// virtual ethernet devices come and go, we will treat such a device that disappeared as not being up
if (intf.getName().startsWith("veth") && e.getMessage().equals("No such device (getFlags() failed)")) {
return false;
}
throw new IOException("failed to check if interface [" + intf.getName() + "] is up", e);
}
}