-
Notifications
You must be signed in to change notification settings - Fork 573
HDDS-13825. Handle invalid OM DB path and rename FSO repair report fields for clarity #9216
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
base: master
Are you sure you want to change the base?
Conversation
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 for working on this @rich7420.
How did you test this change?
|
I tested with |
Yes, it would be good to add a test in |
|
@sarvekshayr thanks for your feedback! I've added a test and ci test passed! |
|
Tested the fix manually.
|
|
|
||
| @Order(2) | ||
| @Test | ||
| public void testAlternateOmDbDirNameDryRun() throws Exception { |
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.
This test currently passes with or without the fix because the previous implementation always expected om.db. Since om.db happens to exist in the same directory as om-db-backup, the tool silently picks up om.db and generates a valid report instead of returning a null report, which hides the bug. You can verify this behaviour once.
To properly validate the fix, please update the test so that om.db resides in a different path than om-db-backup.
Before the fix: the test should produce a null report.
After the fix: the test should correctly generate the report for the provided DB path.
|
@sarvekshayr thanks for the feeback! I'll try to fix it as soon as possible. |
Sure, it's a simple test fix. |
| @Order(2) | ||
| @Test | ||
| public void testAlternateOmDbDirNameDryRun() throws Exception { |
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.
We should assert the actual report values to ensure the report is not null, just verifying the presence of report fields is not enough.
Update the test to:
- change the order
- rename the method
- place it after all dry run tests
- validate the report content instead of only checking for field existence.
@Order(ORDER_DRY_RUN)
@Test
public void testAlternateOmDbDirName() throws Exception {
File original = new File(OMStorage.getOmDbDir(cluster.getConf()), OM_DB_NAME);
// Place backup under a different parent directory to ensure we don't
// accidentally open the original om.db due to path handling bugs.
File backupParent = new File(OMStorage.getOmDbDir(cluster.getConf()), "copy");
File backup = new File(backupParent, "om-db-backup");
if (backup.exists()) {
FileUtils.deleteDirectory(backup);
}
if (backupParent.exists()) {
FileUtils.deleteDirectory(backupParent);
}
boolean created = backupParent.mkdirs();
if (!created && !backupParent.exists()) {
throw new IOException("Failed to create backup parent directory: " + backupParent);
}
FileUtils.copyDirectory(original, backup);
out.reset();
String expectedOutput = serializeReport(fullReport);
int exitCode = executeWithDb(true, backup.getPath());
assertEquals(0, exitCode, err.getOutput());
String cliOutput = out.getOutput();
String reportOutput = extractRelevantSection(cliOutput);
assertEquals(expectedOutput, reportOutput);
FileUtils.deleteDirectory(backupParent);
}
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.
Use fullReport for validation.
|
@sarvekshayr thanks a lot! I've tried to modify function like you said. |
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 @rich7420 for patiently iterating on the patch. The changes look good to me now.
|
@sarvekshayr thanks the feedback! you helped me a lot. |
What changes were proposed in this pull request?
This PR fixes two issues in the FSO repair tool:
Fixed the DB path handling in getStoreFromPath() to use the actual directory name from the provided path instead of hardcoding "om.db". Now the tool supports any OM DB directory name (e.g., om-db-backup, om-copy).
Renamed internal method and report references for better clarity:
unreachable → pendingToDelete
unreferenced → orphaned
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-13825
How was this patch tested?
build-branch