adoroszlai commented on code in PR #4760: URL: https://github.com/apache/ozone/pull/4760#discussion_r1203603032
########## hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/FetchKeySubCommand.java: ########## @@ -0,0 +1,60 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.admin.om; + +import java.util.Base64; +import java.util.concurrent.Callable; +import org.apache.hadoop.hdds.cli.HddsVersionProvider; +import org.apache.hadoop.hdds.security.symmetric.ManagedSecretKey; +import org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol; +import picocli.CommandLine; + +import javax.crypto.SecretKey; + +/** + * Handler of ozone admin om fetch-current-key command. + */ [email protected]( + name = "fetch-current-key", + description = "CLI command to fetch the latest key", + mixinStandardHelpOptions = true, + versionProvider = HddsVersionProvider.class +) +public class FetchKeySubCommand implements Callable<Void> { + @CommandLine.ParentCommand + private OMAdmin parent; + + @CommandLine.Option( + names = {"-id", "--service-id"}, + description = "Ozone Manager Service ID", + required = true + ) + private String omServiceId; + + @Override + public Void call() throws Exception { + OzoneManagerProtocol client = parent.createOmClient(omServiceId); + ManagedSecretKey managedSecretKey = client.getCurrentSecretKey(); + SecretKey key = managedSecretKey.getSecretKey(); + byte[] encodedKey = key.getEncoded(); + String keyString = Base64.getEncoder().encodeToString(encodedKey); + System.out.println("Current Secret Key: " + keyString); + return null; Review Comment: Please close `client` after use (use try-with-resources). ########## hadoop-hdds/framework/pom.xml: ########## @@ -170,6 +170,12 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd"> <groupId>org.awaitility</groupId> <artifactId>awaitility</artifactId> </dependency> + <dependency> + <groupId>org.apache.ozone</groupId> + <artifactId>ozone-interface-client</artifactId> + <version>1.4.0-SNAPSHOT</version> Review Comment: Please don't add dependency from `hadoop-ozone` in `hadoop-hdds`. ########## hadoop-ozone/common/pom.xml: ########## @@ -111,6 +111,10 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd"> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-hdfs-client</artifactId> </dependency> + <dependency> + <groupId>org.apache.ozone</groupId> + <artifactId>hdds-server-framework</artifactId> Review Comment: Please avoid this. `hdds-server-framework` is for server-only shared code. `ozone-common` is shared between client and server. Client should not be getting server-side code and dependencies. ########## hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/FetchKeySubCommand.java: ########## @@ -0,0 +1,60 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.admin.om; + +import java.util.Base64; +import java.util.concurrent.Callable; +import org.apache.hadoop.hdds.cli.HddsVersionProvider; +import org.apache.hadoop.hdds.security.symmetric.ManagedSecretKey; +import org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol; +import picocli.CommandLine; + +import javax.crypto.SecretKey; + +/** + * Handler of ozone admin om fetch-current-key command. + */ [email protected]( + name = "fetch-current-key", Review Comment: Nit: Can we fetch old or future keys? If not, please omit `current`, simplify to `fetch-key`. -- 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]
