Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed detecting number of NICs in EC2 #14252

Merged
merged 1 commit into from Feb 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -23,6 +23,7 @@
import com.sun.management.OperatingSystemMXBean;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -231,8 +232,15 @@ private boolean isPhysicalNic(Path path) {
Files.readAllBytes(path.resolve("speed"));
return true;
} catch (Exception e) {
// wireless nics don't report speed, ignore them.
return false;
// In some cases, VMs in EC2 won't have the speed reported on the NIC and will give a read-error.
// Check the type to make sure it's ethernet (type "1")
try {
String type = new String(Files.readAllBytes(path.resolve("type")), StandardCharsets.UTF_8).trim();
return Integer.parseInt(type) == 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@merlimat - by returning true here, in some cases, don't we also need to update the logic in getNicSpeedPath? We're seeing the new error here #14340 because this class is returning true in a new case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When that happens, we're ignoring that NIC and it causes that we cannot even manually override the NIC capacity in broker.conf

I see now that the point was to make it so it could be overridden.

} catch (IOException ioe) {
// wireless nics don't report speed, ignore them.
return false;
}
}
}
return false;
Expand Down