-
Notifications
You must be signed in to change notification settings - Fork 520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HDDS-11227. Use server default key provider to encrypt/decrypt keys from multiple OMs. #7081
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2ba3624
HDDS-11227. Return required server default configurations. Use server…
0f72911
HDDS-11227. Returning null from OM when key provider is not present.
1099b18
HDDS-11227. Extended org.apache.hadoop.fs.FileSystem
42b54ab
HDDS-11227. Moved getServerDefaults() to BasicRootedOzoneFileSystem a…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
import org.apache.hadoop.crypto.key.KeyProvider; | ||
import org.apache.hadoop.fs.FileEncryptionInfo; | ||
import org.apache.hadoop.fs.Syncable; | ||
import org.apache.hadoop.util.Time; | ||
import org.apache.hadoop.hdds.client.DefaultReplicationConfig; | ||
import org.apache.hadoop.hdds.client.ECReplicationConfig; | ||
import org.apache.hadoop.hdds.client.ReplicationConfig; | ||
|
@@ -61,6 +62,7 @@ | |
import org.apache.hadoop.io.ByteBufferPool; | ||
import org.apache.hadoop.io.ElasticByteBufferPool; | ||
import org.apache.hadoop.io.Text; | ||
import org.apache.hadoop.ozone.OzoneFsServerDefaults; | ||
import org.apache.hadoop.ozone.OzoneAcl; | ||
import org.apache.hadoop.ozone.OzoneConfigKeys; | ||
import org.apache.hadoop.ozone.OzoneConsts; | ||
|
@@ -178,6 +180,8 @@ | |
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_CLIENT_KEY_PROVIDER_CACHE_EXPIRY; | ||
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_CLIENT_KEY_PROVIDER_CACHE_EXPIRY_DEFAULT; | ||
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_CLIENT_REQUIRED_OM_VERSION_MIN_KEY; | ||
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_CLIENT_SERVER_DEFAULTS_VALIDITY_PERIOD_MS; | ||
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_CLIENT_SERVER_DEFAULTS_VALIDITY_PERIOD_MS_DEFAULT; | ||
import static org.apache.hadoop.ozone.OzoneConsts.MAXIMUM_NUMBER_OF_PARTS_PER_UPLOAD; | ||
import static org.apache.hadoop.ozone.OzoneConsts.OLD_QUOTA_DEFAULT; | ||
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_MAXIMUM_ACCESS_ID_LENGTH; | ||
|
@@ -224,6 +228,9 @@ public class RpcClient implements ClientProtocol { | |
private final ContainerClientMetrics clientMetrics; | ||
private final MemoizedSupplier<ExecutorService> writeExecutor; | ||
private final AtomicBoolean isS3GRequest = new AtomicBoolean(false); | ||
private volatile OzoneFsServerDefaults serverDefaults; | ||
private volatile long serverDefaultsLastUpdate; | ||
private final long serverDefaultsValidityPeriod; | ||
|
||
/** | ||
* Creates RpcClient instance with the given configuration. | ||
|
@@ -330,6 +337,11 @@ public void onRemoval( | |
.getInstance(byteBufferPool, ecReconstructExecutor); | ||
this.clientMetrics = ContainerClientMetrics.acquire(); | ||
|
||
this.serverDefaultsValidityPeriod = conf.getTimeDuration( | ||
OZONE_CLIENT_SERVER_DEFAULTS_VALIDITY_PERIOD_MS, | ||
OZONE_CLIENT_SERVER_DEFAULTS_VALIDITY_PERIOD_MS_DEFAULT, | ||
TimeUnit.MILLISECONDS); | ||
|
||
TracingUtil.initTracing("client", conf); | ||
} | ||
|
||
|
@@ -2591,11 +2603,22 @@ public KeyProvider call() throws Exception { | |
} | ||
} | ||
|
||
@Override | ||
public OzoneFsServerDefaults getServerDefaults() throws IOException { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would be great to have a test to verify this where it makes sure a second call within the expiration time to this API does not invoke ozoneManagerClient.getServerDefaults() |
||
long now = Time.monotonicNow(); | ||
if ((serverDefaults == null) || | ||
(now - serverDefaultsLastUpdate > serverDefaultsValidityPeriod)) { | ||
serverDefaults = ozoneManagerClient.getServerDefaults(); | ||
serverDefaultsLastUpdate = now; | ||
} | ||
assert serverDefaults != null; | ||
return serverDefaults; | ||
} | ||
|
||
@Override | ||
public URI getKeyProviderUri() throws IOException { | ||
// TODO: fix me to support kms instances for difference OMs | ||
return OzoneKMSUtil.getKeyProviderUri(ugi, | ||
null, null, conf); | ||
null, getServerDefaults().getKeyProviderUri(), conf); | ||
} | ||
|
||
@Override | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OzoneFsServerDefaults.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* 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; | ||
|
||
import org.apache.hadoop.fs.FsServerDefaults; | ||
import org.apache.hadoop.hdds.annotation.InterfaceAudience; | ||
import org.apache.hadoop.hdds.annotation.InterfaceStability; | ||
|
||
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.FsServerDefaultsProto; | ||
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.FsServerDefaultsProto.Builder; | ||
|
||
|
||
/**************************************************** | ||
* Provides server default configuration values to clients. | ||
* | ||
****************************************************/ | ||
@InterfaceAudience.Public | ||
@InterfaceStability.Evolving | ||
public class OzoneFsServerDefaults extends FsServerDefaults { | ||
|
||
public OzoneFsServerDefaults() { | ||
} | ||
|
||
public OzoneFsServerDefaults(String keyProviderUri) { | ||
super(0L, 0, 0, (short)0, 0, false, 0L, null, keyProviderUri); | ||
} | ||
|
||
public FsServerDefaultsProto getProtobuf() { | ||
Builder builder = FsServerDefaultsProto.newBuilder(); | ||
if (getKeyProviderUri() != null) { | ||
builder.setKeyProviderUri(getKeyProviderUri()); | ||
} | ||
return builder.build(); | ||
} | ||
|
||
public static OzoneFsServerDefaults getFromProtobuf( | ||
FsServerDefaultsProto serverDefaults) { | ||
String keyProviderUri = null; | ||
if (serverDefaults.hasKeyProviderUri()) { | ||
keyProviderUri = serverDefaults.getKeyProviderUri(); | ||
} | ||
return new OzoneFsServerDefaults(keyProviderUri); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we should add the default unit otherwise there will be an unnecessary log like the one below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And
.ms
should be omitted from the property name.