-
Notifications
You must be signed in to change notification settings - Fork 511
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
HDDS-1480. Prefer resolved datanode ip address over persisted ip address #7495
base: master
Are you sure you want to change the base?
Conversation
fe2316f
to
85546fa
Compare
85546fa
to
f0c156d
Compare
…tanode ip address
3f0d40f
to
e35572c
Compare
@ptlrs, please avoid unnecessary formatting changes to the code, this makes it hard to review the logical changes done in the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ptlrs Thanks for the patch. The changes look good to me, excepting for some nitpicky changes. LGTM
...r-service/src/main/java/org/apache/hadoop/ozone/container/common/helpers/ContainerUtils.java
Outdated
Show resolved
Hide resolved
if (!path.exists()) { | ||
throw new IOException("Datanode ID file not found."); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why extra line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Although I do prefer to add space around if-clauses and in some places to have a logical grouping of statements.
...rvice/src/test/java/org/apache/hadoop/ozone/container/common/helpers/TestContainerUtils.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM @ptlrs thanks for the patch
@nandakumar131 Do you want to take another look at the patch? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ptlrs for the patch.
try { | ||
InetAddress inetAddress = InetAddress.getByName(datanodeDetails.getHostName()); | ||
|
||
if (!inetAddress.getHostAddress().equals(datanodeDetails.getIpAddress())) { | ||
LOG.warn("Resolved IP address '{}' differs from the persisted IP address '{}' for the datanode '{}'", | ||
inetAddress.getHostAddress(), datanodeDetails.getIpAddress(), datanodeDetails.getHostName()); | ||
datanodeDetails.setIpAddress(inetAddress.getHostAddress()); | ||
} | ||
} catch (UnknownHostException e) { | ||
LOG.warn("Failed to validate IP address for the datanode '{}'", datanodeDetails.getHostName(), e); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please extract the new logic to a separate method (preferably in DatanodeDetails
). Previously readDatanodeDetailsFrom(File)
did what its name said.
private void assertWriteReadWithChangedIpAddress(@TempDir File tempDir, | ||
DatanodeDetails details) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Please do not format method signature like this. Whenever visibility / return type / method name / other modifiers are changed, we would have to reindent all parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adoroszlai Can you please point me to any existing methods which follow the preferred format for my reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is any strong preference we agreed on, but you can't go wrong by following existing style from the same file being edited:
Lines 145 to 146 in f1fdd50
private void assertWriteRead(@TempDir File tempDir, | |
DatanodeDetails details) throws IOException { |
Some would argue for:
- putting each argument on a separate line vs. grouping few of them while respecting line length limit
- putting the first argument on its own line
Consistent formatting has benefits, but coming to agreement is not easy, and reformatting all existing code makes backports harder initially.
File file = new File(tempDir, "valid-values.id"); | ||
ContainerUtils.writeDatanodeDetailsTo(details, file, conf); | ||
DatanodeDetails read = ContainerUtils.readDatanodeDetailsFrom(file); | ||
assertNotEquals(details.toString(), read.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a bit stronger assertion about the IP address?
...r-service/src/main/java/org/apache/hadoop/ozone/container/common/helpers/ContainerUtils.java
Outdated
Show resolved
Hide resolved
…ozone/container/common/helpers/ContainerUtils.java Co-authored-by: Siyao Meng <[email protected]>
Please describe your PR in detail:
DatanodeDetails
is persisted byContainerUtils
andDatanodeIdYaml
classes.The IP address in
DatanodeDetails
is also persisted.However, the IP address could have changed when reading back the persisted file.
The original task suggests removal of the IP address field.
Currently the IP address field of the
DatanodeDetails
class is used in several places.So removal of the IP address field either from persistence or from usage is not straightforward. As an alternative, we resolve the IP address based on the hostname to detect if the IP address has changed.
As part of this change:
UnknownHostException
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-1480
How was this patch tested?
CI: https://github.com/ptlrs/ozone/actions/runs/12135607178https://github.com/ptlrs/ozone/actions/runs/12627875515