You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/02/25 18:45:00 UTC

[GitHub] [pulsar] michaeljmarshall commented on a change in pull request #14252: Fixed detecting number of NICs in EC2

michaeljmarshall commented on a change in pull request #14252:
URL: https://github.com/apache/pulsar/pull/14252#discussion_r815009835



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LinuxBrokerHostUsageImpl.java
##########
@@ -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;

Review comment:
       @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 https://github.com/apache/pulsar/pull/14340 because this class is returning true in a new case.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org