duongkame commented on code in PR #4389:
URL: https://github.com/apache/ozone/pull/4389#discussion_r1145199658


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SecretStoreProvider.java:
##########
@@ -0,0 +1,37 @@
+/*
+ * 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.om;
+
+import org.apache.hadoop.conf.Configuration;
+
+import java.io.IOException;
+
+/**
+ * S3 secret store provider.
+ */
+public interface SecretStoreProvider {

Review Comment:
   nit: I can't really justify the necessity of this interface. Will we need 
more than 1 implementation?



##########
hadoop-ozone/s3-secret-store/src/main/java/org/apache/hadoop/ozone/s3/remote/vault/S3RemoteSecretStore.java:
##########
@@ -0,0 +1,198 @@
+/*
+ * 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.s3.remote.vault;
+
+import com.bettercloud.vault.SslConfig;
+import com.bettercloud.vault.Vault;
+import com.bettercloud.vault.VaultConfig;
+import com.bettercloud.vault.VaultException;
+import com.bettercloud.vault.response.LookupResponse;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.ozone.om.S3Batcher;
+import org.apache.hadoop.ozone.om.S3SecretStore;
+import org.apache.hadoop.ozone.om.helpers.S3SecretValue;
+import org.apache.hadoop.ozone.s3.remote.vault.auth.Auth;
+import org.apache.hadoop.ozone.s3.remote.vault.auth.AuthType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Objects;
+
+import static 
org.apache.hadoop.ozone.s3.remote.S3SecretStoreConfigurationKeys.ADDRESS;
+import static 
org.apache.hadoop.ozone.s3.remote.S3SecretStoreConfigurationKeys.ENGINE_VER;
+import static 
org.apache.hadoop.ozone.s3.remote.S3SecretStoreConfigurationKeys.KEY_STORE_PASSWORD;
+import static 
org.apache.hadoop.ozone.s3.remote.S3SecretStoreConfigurationKeys.KEY_STORE_PATH;
+import static 
org.apache.hadoop.ozone.s3.remote.S3SecretStoreConfigurationKeys.KEY_STORE_TYPE;
+import static 
org.apache.hadoop.ozone.s3.remote.S3SecretStoreConfigurationKeys.NAMESPACE;
+import static 
org.apache.hadoop.ozone.s3.remote.S3SecretStoreConfigurationKeys.SECRET_PATH;
+import static 
org.apache.hadoop.ozone.s3.remote.S3SecretStoreConfigurationKeys.TRUST_STORE_PASSWORD;
+import static 
org.apache.hadoop.ozone.s3.remote.S3SecretStoreConfigurationKeys.TRUST_STORE_PATH;
+import static 
org.apache.hadoop.ozone.s3.remote.S3SecretStoreConfigurationKeys.TRUST_STORE_TYPE;
+
+/**
+ * Based on HashiCorp Vault secret storage.
+ * Documentation link {@code https://developer.hashicorp.com/vault}.
+ */
+public class S3RemoteSecretStore implements S3SecretStore {
+  private static final Logger LOG =
+      LoggerFactory.getLogger(S3RemoteSecretStore.class);
+
+  private final VaultConfig config;
+  private Vault vault;
+  private final String secretPath;
+  private final Auth auth;
+
+  public S3RemoteSecretStore(String vaultAddress,

Review Comment:
   nit: maybe a simple unit test can help cover the data conversion and error 
handling in this class. 



##########
hadoop-ozone/s3-secret-store/pom.xml:
##########
@@ -0,0 +1,194 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed 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. See accompanying LICENSE file.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.ozone</groupId>
+    <artifactId>ozone</artifactId>
+    <version>1.4.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>ozone-s3-secret-store</artifactId>
+  <name>Apache Ozone S3 Secret Store</name>
+  <packaging>jar</packaging>
+  <version>1.4.0-SNAPSHOT</version>
+  <properties>
+    <file.encoding>UTF-8</file.encoding>
+    <downloadSources>true</downloadSources>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.ozone</groupId>
+      <artifactId>ozone-common</artifactId>
+      <scope>compile</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>com.bettercloud</groupId>
+      <artifactId>vault-java-driver</artifactId>
+    </dependency>
+<!--    <dependency>-->

Review Comment:
   nit: remove?



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/S3SecretManagerImpl.java:
##########
@@ -64,6 +69,10 @@ public String getSecretString(String awsAccessKey)
         "awsAccessKeyId cannot be null or empty.");
     LOG.trace("Get secret for awsAccessKey:{}", awsAccessKey);
 
+    S3SecretValue cacheValue = s3SecretCache.get(awsAccessKey);

Review Comment:
   Today, s3SecretCache is updated from `OMSetSecretRequest` and 
`S3GetSecretRequest` only. 
   It's not updated on normal S3 operations (key/bucket read/write). 
   Thus, there's a good chance that this cache doesn't help improve the 
performance or reduce the load to the external vault. 
   
   The Secret cache should be implemented as a read-through cache (or 
LoadingCache in Guava term).
   
   And IMHO, for simplicity, it can be just a `LoadingCache` directly put in 
`S3SecretManagerImpl`. I don't see it can be anything else (that needs the 
flexibility of a separate component/interface) in the future. 



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