Copilot commented on code in PR #9027:
URL: https://github.com/apache/hadoop/pull/9027#discussion_r4691051389
##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/CombinedHostFileManager.java:
##########
@@ -192,12 +216,27 @@ private void refresh(final String hostsFile, final int
readTimeout) throws IOExc
InetSocketAddress addr = parseEntry(hostsFile,
properties.getHostName(), properties.getPort());
if (addr != null) {
- hostProps.add(addr.getAddress(), properties);
+ hostProps.add(addr.getAddress(), properties,
+ otherAddressesOf(addr.getAddress()));
}
}
refresh(hostProps);
}
+ /**
+ * @return the host's other addresses, e.g. its IPv6 address for an entry
+ * given as an IPv4 literal.
+ */
+ private static Collection<InetAddress> otherAddressesOf(InetAddress addr) {
+ try {
+ return
Arrays.stream(InetAddress.getAllByName(addr.getCanonicalHostName()))
+ .filter(a -> !a.equals(addr)).collect(Collectors.toList());
Review Comment:
This treats every address returned by the forward lookup of the PTR result
as an alias without verifying that the forward lookup contains the original
`addr`. If reverse and forward DNS disagree (for example, a stale PTR or a
hostname whose A/AAAA records were changed), an unrelated address is added to
the include/exclude/maintenance mapping and a DataNode on that address can be
accepted as the listed host. Please require the reverse name to resolve back to
`addr` before adding any aliases, consistent with the reverse/forward check in
`NameNodeRpcServer#getAdvertisedAddress` (NameNodeRpcServer.java:588-591).
##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeManager.java:
##########
@@ -1717,7 +1717,7 @@ public List<DatanodeDescriptor> getDatanodeListForReport(
nodes.add(dn);
}
- foundNodes.add(dn.getResolvedAddress());
+ foundNodes.add(hostConfigManager.getHostsFileAddress(dn));
Review Comment:
The new report de-duplication path is not covered by the added tests: they
exercise `HostProperties` directly, but this line depends on
`CombinedHostFileManager#getHostsFileAddress` and `HostSet.matchedBy` working
together. A regression that returns the registered IPv6 address here (or
mishandles the configured port) would still leave the unit tests green and
reintroduce the synthetic listed-address dead node. Add a report-level test
with a DN registered on an alias and assert that the configured entry is
matched exactly once.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]