adoroszlai opened a new pull request, #7682:
URL: https://github.com/apache/ozone/pull/7682

   ## What changes were proposed in this pull request?
   
   1. Add `--dry-run` option to all `ozone repair` subcommands that modify 
state.  The new option currently defaults to `false`, so commands _perform 
repair by default_.  (Otherwise we'd need to use it as `--dry-run=false`.)
   2. Implement dry-run mode where needed.
   
   https://issues.apache.org/jira/browse/HDDS-11946
   
   ## How was this patch tested?
   
   ### Enforce `--dry-run` option
   
   Added unit test to verify that each subcommand under `ozone repair` 
satisfies one of the following:
   
   - has subcommands
   - has `--dry-run` option
   - implements `ReadOnlySubcommand` (currently only `QuotaStatus`)
   
   Test failure before implementing `ReadOnlyCommand` in `QuotaStatus`:
   
   ```
   [ERROR] Tests run: 3, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 
0.261 s <<< FAILURE! - in org.apache.hadoop.ozone.repair.TestOzoneRepair
   [ERROR] 
org.apache.hadoop.ozone.repair.TestOzoneRepair.subcommandsSupportDryRun  Time 
elapsed: 0.211 s  <<< FAILURE!
   java.lang.AssertionError: 
   ['ozone repair quota status' defined by class 
org.apache.hadoop.ozone.repair.quota.QuotaStatus should support --dry-run or 
implement interface org.apache.hadoop.ozone.repair.ReadOnlyCommand] 
   Expecting UnmodifiableSet:
     ["--service-id",
       "--om-service-id",
       "--service-host",
       "-h",
       "--help",
       "-V",
       "--version"]
   to contain:
     ["--dry-run"]
   but could not find the following element(s):
     ["--dry-run"]
   
        at 
org.apache.hadoop.ozone.repair.TestOzoneRepair.assertSubcommandOptionRecursively(TestOzoneRepair.java:84)
        at 
org.apache.hadoop.ozone.repair.TestOzoneRepair.assertSubcommandOptionRecursively(TestOzoneRepair.java:89)
        at 
org.apache.hadoop.ozone.repair.TestOzoneRepair.assertSubcommandOptionRecursively(TestOzoneRepair.java:89)
        at 
org.apache.hadoop.ozone.repair.TestOzoneRepair.subcommandsSupportDryRun(TestOzoneRepair.java:71)
   ```
   
   ### Tool operation
   
   Sample output of `ozone repair om fso-tree` from integration tests:
   
   ```
   [dry run] No running OM service detected. Proceeding with repair.
   [dry run] Creating database of reachable directories at 
hadoop-ozone/integration-test/target/test-dir/MiniOzoneClusterImpl-430e6515-4d93-4d63-99d9-2d0e1801aa90/ozone-meta/reachable.db
   [dry run] Processing volume: /vol2
   [dry run] Processing bucket: vol2/bucket1
   [dry run] Deleting unreferenced directory 
/-9223372036854768896/-9223372036854768384/-9223372036854767871/dir2
   [dry run] Deleting unreferenced file 
/-9223372036854768896/-9223372036854768384/-9223372036854767359/file3
   [dry run] Deleting unreferenced file 
/-9223372036854768896/-9223372036854768384/-9223372036854767871/file1
   [dry run] Deleting unreferenced file 
/-9223372036854768896/-9223372036854768384/-9223372036854767871/file2
   [dry run] Processing bucket: vol2/bucket2
   2025-01-10 16:46:50,087 [main] INFO  rocksdiff.RocksDBCheckpointDiffer 
(RocksDBCheckpointDiffer.java:close(307)) - Shutting down 
CompactionDagPruningService.
   [dry run] 
   Reachable:
        Directories: 4
        Files: 5
        Bytes: 50
   Unreachable:
        Directories: 0
        Files: 0
        Bytes: 0
   Unreferenced:
        Directories: 1
        Files: 3
        Bytes: 30
   ```
   
   Manual test of `ozone repair om update-transaction` in compose environment:
   
   ```
   $ ozone repair om update-transaction --db=/data/metadata/om.db --term 2 
--index 3 --dry-run
   [dry run] No running OM service detected. Proceeding with repair.
   [dry run] The original highest transaction Info was (t:1, i:14)
   [dry run] Updating transaction info to (t:2, i:3)
   
   $ ozone repair om update-transaction --db=/data/metadata/om.db --term 2 
--index 3 
   ATTENTION: Running as user hadoop. Make sure this is the same user used to 
run the Ozone process. Are you sure you want to continue (y/N)? y
   Run as user: hadoop
   No running OM service detected. Proceeding with repair.
   The original highest transaction Info was (t:1, i:14)
   Updating transaction info to (t:2, i:3)
   The highest transaction info has been updated to: (t:2, i:3)
   
   $ ozone repair om update-transaction --db=/data/metadata/om.db --term 2 
--index 3 --dry-run
   [dry run] No running OM service detected. Proceeding with repair.
   [dry run] The original highest transaction Info was (t:2, i:3)
   [dry run] Updating transaction info to (t:2, i:3)
   ```
   
   CI:
   https://github.com/adoroszlai/ozone/actions/runs/12714010228
   


-- 
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]

Reply via email to