This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 7c13de865e HDDS-12041. Add ozone repair scm cert command and its
subcommand (#7671)
7c13de865e is described below
commit 7c13de865ee2e3fa34bfda4aa7b917308763d037
Author: Sarveksha Yeshavantha Raju
<[email protected]>
AuthorDate: Fri Jan 10 17:21:55 2025 +0530
HDDS-12041. Add ozone repair scm cert command and its subcommand (#7671)
---
.../apache/hadoop/ozone/repair/scm/SCMRepair.java | 38 ++++++++++++++++++++++
.../hadoop/ozone/repair/scm/cert/CertRepair.java | 35 ++++++++++++++++++++
.../{ => scm/cert}/RecoverSCMCertificate.java | 20 +++++-------
.../hadoop/ozone/repair/scm/cert/package-info.java | 22 +++++++++++++
.../hadoop/ozone/repair/scm/package-info.java | 22 +++++++++++++
5 files changed, 126 insertions(+), 11 deletions(-)
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/scm/SCMRepair.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/scm/SCMRepair.java
new file mode 100644
index 0000000000..d7e61a8ed2
--- /dev/null
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/scm/SCMRepair.java
@@ -0,0 +1,38 @@
+/*
+ * 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.hadoop.ozone.repair.scm;
+
+import org.apache.hadoop.hdds.cli.RepairSubcommand;
+import org.apache.hadoop.ozone.repair.scm.cert.CertRepair;
+import org.kohsuke.MetaInfServices;
+import picocli.CommandLine;
+
+/**
+ * Ozone Repair CLI for SCM.
+ */
[email protected](name = "scm",
+ description = "Operational tool to repair SCM.",
+ subcommands = {
+ CertRepair.class,
+ }
+)
+@MetaInfServices(RepairSubcommand.class)
+public class SCMRepair implements RepairSubcommand {
+
+}
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/scm/cert/CertRepair.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/scm/cert/CertRepair.java
new file mode 100644
index 0000000000..c1d687101f
--- /dev/null
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/scm/cert/CertRepair.java
@@ -0,0 +1,35 @@
+/*
+ * 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.hadoop.ozone.repair.scm.cert;
+
+import picocli.CommandLine;
+
+/**
+ * A dedicated subcommand for all certificate related repairs on SCM.
+ */
+
[email protected](name = "cert",
+ description = "Subcommand for all certificate related repairs on SCM",
+ subcommands = {
+ RecoverSCMCertificate.class
+ }
+)
+public class CertRepair {
+
+}
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/RecoverSCMCertificate.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/scm/cert/RecoverSCMCertificate.java
similarity index 95%
rename from
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/RecoverSCMCertificate.java
rename to
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/scm/cert/RecoverSCMCertificate.java
index b85ccfb1e8..29b92574b8 100644
---
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/RecoverSCMCertificate.java
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/scm/cert/RecoverSCMCertificate.java
@@ -15,9 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.hadoop.ozone.repair;
+package org.apache.hadoop.ozone.repair.scm.cert;
-import org.apache.hadoop.hdds.cli.RepairSubcommand;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.security.SecurityConfig;
import org.apache.hadoop.hdds.security.x509.certificate.authority.CAType;
@@ -31,7 +30,8 @@ import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.debug.DBDefinitionFactory;
import org.apache.hadoop.ozone.debug.RocksDBUtils;
import java.security.cert.CertificateFactory;
-import org.kohsuke.MetaInfServices;
+
+import org.apache.hadoop.ozone.repair.RepairTool;
import org.rocksdb.ColumnFamilyDescriptor;
import org.rocksdb.ColumnFamilyHandle;
import org.rocksdb.RocksDBException;
@@ -63,21 +63,19 @@ import static
org.apache.hadoop.ozone.om.helpers.OzoneFSUtils.removeTrailingSlas
* and private keys of the SCM are intact.
*/
@CommandLine.Command(
- name = "cert-recover",
+ name = "recover",
description = "Recover Deleted SCM Certificate from RocksDB")
-@MetaInfServices(RepairSubcommand.class)
-public class RecoverSCMCertificate extends RepairTool implements
RepairSubcommand {
-
+public class RecoverSCMCertificate extends RepairTool {
@CommandLine.Option(names = {"--db"},
required = true,
description = "SCM DB Path")
private String dbPath;
- @CommandLine.ParentCommand
- private OzoneRepair parent;
-
@Override
public void execute() throws Exception {
+ if (checkIfServiceIsRunning("SCM")) {
+ return;
+ }
dbPath = removeTrailingSlashIfNeeded(dbPath);
String tableName = VALID_SCM_CERTS.getName();
DBDefinition dbDefinition =
@@ -96,7 +94,7 @@ public class RecoverSCMCertificate extends RepairTool
implements RepairSubcomman
try (ManagedRocksDB db = ManagedRocksDB.openReadOnly(dbPath, cfDescList,
cfHandleList)) {
cfHandle = getColumnFamilyHandle(cfHandleList, tableNameBytes);
- SecurityConfig securityConfig = new
SecurityConfig(parent.getOzoneConf());
+ SecurityConfig securityConfig = new SecurityConfig(getOzoneConf());
Map<BigInteger, X509Certificate> allCerts =
getAllCerts(columnFamilyDefinition, cfHandle, db);
info("All Certs in DB : %s", allCerts.keySet());
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/scm/cert/package-info.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/scm/cert/package-info.java
new file mode 100644
index 0000000000..4086badcb7
--- /dev/null
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/scm/cert/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+/**
+ * SCM Cert Repair tools.
+ */
+package org.apache.hadoop.ozone.repair.scm.cert;
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/scm/package-info.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/scm/package-info.java
new file mode 100644
index 0000000000..76a2b0f5da
--- /dev/null
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/scm/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+/**
+ * SCM related repair tools.
+ */
+package org.apache.hadoop.ozone.repair.scm;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]