sreejasahithi commented on code in PR #10547:
URL: https://github.com/apache/ozone/pull/10547#discussion_r3564713678
##########
hadoop-ozone/cli-debug/src/main/java/org/apache/hadoop/ozone/debug/datanode/container/analyze/AnalyzeSubcommand.java:
##########
@@ -34,65 +50,205 @@
*/
@Command(
name = "analyze",
- description = "Analyze container consistency between on-disk container " +
- "directories on this DataNode and SCM metadata. Must be run
locally on a DataNode.")
+ description = {
+ "Analyze container consistency between on-disk container directories
on this DataNode and SCM metadata.",
+ "Must be run locally on a DataNode.",
+ "",
+ "Reports:",
+ " Duplicate container directories: same containerID found on more
than one volume.",
+ " Orphan containers (requires --scm-db): present on disk but not
present in SCM metadata.",
+ " Containers marked DELETED in SCM but present on disk (requires
--scm-db).",
+ "",
+ "Each reported occurrence includes container directory path(s), size
and an on-disk metadata status:",
+ " MISSING_METADATA: metadata/{containerId}.container does not exist.",
+ " INVALID_METADATA: metadata file exists but cannot be parsed, or the
containerID in the",
+ " file does not match the directory name.",
+ " VALID: metadata file is present, parses correctly, and its
containerID matches the directory name."
+ })
public class AnalyzeSubcommand extends AbstractSubcommand implements
Callable<Void> {
+ @Deprecated
@CommandLine.Option(names = {"--count"},
- defaultValue = "20",
- description = "Number of containers to display")
- private int count;
+ hidden = true,
+ description = "Number of containers to display")
+ private Integer count;
+
+ @CommandLine.Mixin
+ private ListLimitOptions listOptions;
+
+ private static final Logger LOG =
LoggerFactory.getLogger(AnalyzeSubcommand.class);
+
+ @CommandLine.Option(names = {"--scm-db"},
+ description = "Path to an offline scm.db directory, or its parent
metadata directory.")
+ private File scmDb;
@Override
public Void call() throws Exception {
- if (count < 1) {
- throw new IOException("Count must be an integer greater than 0.");
- }
+ validateOptions();
OzoneConfiguration conf = getOzoneConf();
ContainerScanResult scanResult = ContainerDirectoryScanner.scan(conf);
Map<Long, List<ContainerDiskOccurrence>> enrichedDuplicates =
ContainerDirectoryScanner.enrichDuplicates(scanResult.getDuplicates());
- // TODO: SCM metadata lookup from --scm-db when provided.
- // TODO: For each id in scanResult.getSingles().keySet() classified
NOT_IN_SCM or DELETED:
- // enrichOccurrence(id, scanResult.getSingles().get(id)) and report.
- // TODO: For each id in enrichedDuplicates.keySet() classified NOT_IN_SCM
or DELETED:
- // enrichedDuplicates.get(id) is already enriched — just report.
+ if (scmDb != null && checkClusterIdConsistency(conf)) {
+ findOrphanAndDeletedButPresentContainers(conf, scanResult,
enrichedDuplicates);
+ } else if (scmDb == null) {
+ out().println("To identify orphan containers (wrt SCM) and containers
that are marked as DELETED in SCM but"
+ + " exist in the datanode's current directory, provide the SCM
database path using the --scm-db option."
+ );
+ }
Review Comment:
Updated to show better error message
When provided non existing path:
```
bash-5.1$ ozone debug datanode container analyze --scm-db /tmp/scm/metadata
SCM container consistency checks were skipped: SCM database directory not
found: /tmp/scm/metadata
Number of containers with duplicate container directories on this DataNode: 1
Container 1 (2 occurrences):
path=/data/hdds0/hdds/CID-63b980c0-c067-457b-8ddd-69c10a829eef/current/containerDir0/1
status=VALID size=512566 bytes
path=/data/hdds1/hdds/CID-63b980c0-c067-457b-8ddd-69c10a829eef/current/containerDir0/1
status=VALID size=512566 bytes
bash-5.1$
```
--
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]