You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "adoroszlai (via GitHub)" <gi...@apache.org> on 2025/01/06 19:22:48 UTC
[PR] HDDS-12012. Defer ozone repair prompt after subcommand validation [ozone]
adoroszlai opened a new pull request, #7653:
URL: https://github.com/apache/ozone/pull/7653
## What changes were proposed in this pull request?
`ozone repair` shows warning prompt on startup. HDDS-11945 added logic to skip it when showing top-level usage.
This PR further improves it by deferring the prompt to subcommands, so that it is not shown for:
- subcommand invoked without all required options and arguments
- subcommand invoked with `--help`
Integration tests running `ozone repair` now need to pass `y` to stdin.
https://issues.apache.org/jira/browse/HDDS-12012
## How was this patch tested?
```
$ ozone repair
Incomplete command
Usage: ozone repair [-hV] [--verbose] [-conf=<configurationPath>]
[-D=<String=String>]... [COMMAND]
Advanced tool to repair Ozone. The nodes being repaired must be stopped before
the tool is run.
-conf=<configurationPath>
-D, --set=<String=String>
-h, --help Show this help message and exit.
-V, --version Print version information and exit.
--verbose More verbose output. Show the stack trace of the errors.
Commands:
cert-recover Recover Deleted SCM Certificate from RocksDB
om Operational tool to repair OM.
quota Operational tool to repair quota in OM DB.
$ ozone repair om
Missing required subcommand
Usage: ozone repair om [COMMAND]
Operational tool to repair OM.
Commands:
fso-tree Identify and repair a disconnected FSO tree by marking
unreferenced entries for deletion. OM should be stopped
while this tool is run.
snapshot Subcommand for all snapshot related repairs.
update-transaction CLI to update the highest index in transactionInfoTable.
Currently it is only supported for OM.
$ ozone repair om fso-tree --help
Usage: ozone repair om fso-tree [-hrV] [--force] [--verbose] [-b=<bucket>]
--db=<dbPath> [-v=<volume>]
...
$ ozone repair om fso-tree
Missing required option: '--db=<dbPath>'
Usage: ozone repair om fso-tree [-hrV] [--force] [--verbose] [-b=<bucket>]
--db=<dbPath> [-v=<volume>]
...
$ ozone repair om fso-tree --db /data/metadata/om.db
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)? n
Aborting command.
$ ozone repair om fso-tree --db /data/metadata/om.db
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
Error: OM is currently running on this host with PID 7. Stop the service before running the repair tool.
```
CI:
https://github.com/adoroszlai/ozone/actions/runs/12637496667
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-12012. Defer ozone repair prompt after subcommand validation [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #7653:
URL: https://github.com/apache/ozone/pull/7653#discussion_r1909212945
##########
hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/IntLambda.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ozone.test;
+
+import java.util.function.IntSupplier;
+
+/** Test utilities for working with lambdas returning int value. */
+public interface IntLambda {
+
+ static ToIntExecutable withTextFromSystemIn(String... lines) {
+ return runnable -> {
+ try (AutoCloseable ignored = GenericTestUtils.supplyOnSystemIn(lines)) {
+ return runnable.getAsInt();
+ } catch (RuntimeException e) {
+ throw e;
Review Comment:
@nandakumar131 The goal of this `catch` block is to avoid wrapping `RuntimeException` in `RuntimeException` in the following block:
https://github.com/apache/ozone/blob/d2c0398cdaddeb850d8f3f970df2020aff9aef2a/hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/IntLambda.java#L29-L33
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-12012. Defer ozone repair prompt after subcommand validation [ozone]
Posted by "nandakumar131 (via GitHub)" <gi...@apache.org>.
nandakumar131 merged PR #7653:
URL: https://github.com/apache/ozone/pull/7653
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-12012. Defer ozone repair prompt after subcommand validation [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #7653:
URL: https://github.com/apache/ozone/pull/7653#discussion_r1909212945
##########
hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/IntLambda.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ozone.test;
+
+import java.util.function.IntSupplier;
+
+/** Test utilities for working with lambdas returning int value. */
+public interface IntLambda {
+
+ static ToIntExecutable withTextFromSystemIn(String... lines) {
+ return runnable -> {
+ try (AutoCloseable ignored = GenericTestUtils.supplyOnSystemIn(lines)) {
+ return runnable.getAsInt();
+ } catch (RuntimeException e) {
+ throw e;
Review Comment:
@nandakumar131 The goal of this `catch` block is to avoid wrapping `RuntimeException` in `RuntimeException`.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-12012. Defer ozone repair prompt after subcommand validation [ozone]
Posted by "nandakumar131 (via GitHub)" <gi...@apache.org>.
nandakumar131 commented on PR #7653:
URL: https://github.com/apache/ozone/pull/7653#issuecomment-2582073405
Thanks @adoroszlai for the contribution! Thanks @sarvekshayr @Tejaskriya & @errose28 for the review.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-12012. Defer ozone repair prompt after subcommand validation [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on PR #7653:
URL: https://github.com/apache/ozone/pull/7653#issuecomment-2574676940
@sarvekshayr updated
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-12012. Defer ozone repair prompt after subcommand validation [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on PR #7653:
URL: https://github.com/apache/ozone/pull/7653#issuecomment-2582081232
Thanks @errose28, @nandakumar131, @sarvekshayr, @Tejaskriya for the review.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-12012. Defer ozone repair prompt after subcommand validation [ozone]
Posted by "nandakumar131 (via GitHub)" <gi...@apache.org>.
nandakumar131 commented on code in PR #7653:
URL: https://github.com/apache/ozone/pull/7653#discussion_r1909179194
##########
hadoop-hdds/test-utils/src/main/java/org/apache/ozone/test/IntLambda.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ozone.test;
+
+import java.util.function.IntSupplier;
+
+/** Test utilities for working with lambdas returning int value. */
+public interface IntLambda {
+
+ static ToIntExecutable withTextFromSystemIn(String... lines) {
+ return runnable -> {
+ try (AutoCloseable ignored = GenericTestUtils.supplyOnSystemIn(lines)) {
+ return runnable.getAsInt();
+ } catch (RuntimeException e) {
+ throw e;
Review Comment:
We can remove this `catch` block as we are not doing anything with the caught exception other than throwing it again.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-12012. Defer ozone repair prompt after subcommand validation [ozone]
Posted by "sarvekshayr (via GitHub)" <gi...@apache.org>.
sarvekshayr commented on PR #7653:
URL: https://github.com/apache/ozone/pull/7653#issuecomment-2574527526
Hi @adoroszlai. Please resolve the conflicts.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-12012. Defer ozone repair prompt after subcommand validation [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #7653:
URL: https://github.com/apache/ozone/pull/7653#discussion_r1908562016
##########
hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/repair/om/TestTransactionInfoRepair.java:
##########
@@ -125,12 +126,14 @@ private void testCommand(ManagedRocksDB mdb, ColumnFamilyHandle columnFamilyHand
.thenReturn(transactionInfo2);
CommandLine cli = new OzoneRepair().getCmd();
- cli.execute(
- "om",
- "update-transaction",
- "--db", DB_PATH,
- "--term", String.valueOf(TEST_TERM),
- "--index", String.valueOf(TEST_INDEX));
+ withTextFromSystemIn("y")
Review Comment:
Removed the dependency.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-12012. Defer ozone repair prompt after subcommand validation [ozone]
Posted by "errose28 (via GitHub)" <gi...@apache.org>.
errose28 commented on code in PR #7653:
URL: https://github.com/apache/ozone/pull/7653#discussion_r1907582878
##########
hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/repair/om/TestTransactionInfoRepair.java:
##########
@@ -125,12 +126,14 @@ private void testCommand(ManagedRocksDB mdb, ColumnFamilyHandle columnFamilyHand
.thenReturn(transactionInfo2);
CommandLine cli = new OzoneRepair().getCmd();
- cli.execute(
- "om",
- "update-transaction",
- "--db", DB_PATH,
- "--term", String.valueOf(TEST_TERM),
- "--index", String.valueOf(TEST_INDEX));
+ withTextFromSystemIn("y")
Review Comment:
Can we do this without adding a new dependency? It does flow nicely but it might be better to avoid adding small/niche libraries that are rarely needed just for syntactic sugar.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-12012. Defer ozone repair prompt after subcommand validation [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #7653:
URL: https://github.com/apache/ozone/pull/7653#discussion_r1907592121
##########
hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/repair/om/TestTransactionInfoRepair.java:
##########
@@ -125,12 +126,14 @@ private void testCommand(ManagedRocksDB mdb, ColumnFamilyHandle columnFamilyHand
.thenReturn(transactionInfo2);
CommandLine cli = new OzoneRepair().getCmd();
- cli.execute(
- "om",
- "update-transaction",
- "--db", DB_PATH,
- "--term", String.valueOf(TEST_TERM),
- "--index", String.valueOf(TEST_INDEX));
+ withTextFromSystemIn("y")
Review Comment:
It's for test only.
Adding as dependency and copying/reimplementing it both have benefits and drawbacks. E.g.:
- (+) It has test coverage that I will not add if I need to implement it from scratch.
- (-) I wish it would allow lambdas with return type, to avoid the need for the `AtomicInteger` for catching exit code.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org