-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-17922. Lookup old S3 encryption configs for JCEKS #3462
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
Closed
Closed
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d6b6473
HADOOP-17922. Lookup old S3 encryption configs for JCEKS
mehakmeet 6706bc1
HADOOP-17922. test fixes
mehakmeet 09f877c
HADOOP-17922. review comments
mehakmeet 01d7480
HADOOP-17922. How are deprecated properties resolved per-bucket?
steveloughran 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 hidden or 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 |
|---|---|---|
|
|
@@ -58,8 +58,9 @@ | |
| import static org.apache.hadoop.fs.s3a.Constants.AWS_S3_CENTRAL_REGION; | ||
| import static org.apache.hadoop.fs.s3a.Constants.EXPERIMENTAL_AWS_INTERNAL_THROTTLING; | ||
| import static org.apache.hadoop.fs.s3a.Constants.EXPERIMENTAL_AWS_INTERNAL_THROTTLING_DEFAULT; | ||
| import static org.apache.hadoop.fs.s3a.Constants.S3_ENCRYPTION_ALGORITHM; | ||
| import static org.apache.hadoop.fs.s3a.Constants.S3_ENCRYPTION_KEY; | ||
| import static org.apache.hadoop.fs.s3a.S3AUtils.getEncryptionAlgorithm; | ||
| import static org.apache.hadoop.fs.s3a.S3AUtils.getS3EncryptionKey; | ||
| import static org.apache.hadoop.fs.s3a.S3AUtils.translateException; | ||
|
|
||
| /** | ||
|
|
@@ -96,6 +97,9 @@ public class DefaultS3ClientFactory extends Configured | |
| /** Exactly once log to inform about ignoring the AWS-SDK Warnings for CSE. */ | ||
| private static final LogExactlyOnce IGNORE_CSE_WARN = new LogExactlyOnce(LOG); | ||
|
|
||
| /** Bucket name. */ | ||
| private String bucket; | ||
|
|
||
| /** | ||
| * Create the client by preparing the AwsConf configuration | ||
| * and then invoking {@code buildAmazonS3Client()}. | ||
|
|
@@ -105,9 +109,10 @@ public AmazonS3 createS3Client( | |
| final URI uri, | ||
| final S3ClientCreationParameters parameters) throws IOException { | ||
| Configuration conf = getConf(); | ||
| bucket = uri.getHost(); | ||
| final ClientConfiguration awsConf = S3AUtils | ||
| .createAwsConf(conf, | ||
| uri.getHost(), | ||
| bucket, | ||
| Constants.AWS_SERVICE_IDENTIFIER_S3); | ||
| // add any headers | ||
| parameters.getHeaders().forEach((h, v) -> | ||
|
|
@@ -126,10 +131,13 @@ public AmazonS3 createS3Client( | |
| awsConf.setUserAgentSuffix(parameters.getUserAgentSuffix()); | ||
| } | ||
|
|
||
| // Get the encryption method for this bucket. | ||
| S3AEncryptionMethods encryptionMethods = | ||
| getEncryptionAlgorithm(uri.getHost(), conf); | ||
|
||
| try { | ||
| if (S3AEncryptionMethods.getMethod(S3AUtils. | ||
| lookupPassword(conf, S3_ENCRYPTION_ALGORITHM, null)) | ||
| .equals(S3AEncryptionMethods.CSE_KMS)) { | ||
| // If CSE is enabled then build a S3EncryptionClient. | ||
| if (S3AEncryptionMethods.CSE_KMS.getMethod() | ||
| .equals(encryptionMethods.getMethod())) { | ||
| return buildAmazonS3EncryptionClient( | ||
| awsConf, | ||
| parameters); | ||
|
|
@@ -163,12 +171,11 @@ protected AmazonS3 buildAmazonS3EncryptionClient( | |
| new AmazonS3EncryptionClientV2Builder(); | ||
| Configuration conf = getConf(); | ||
|
|
||
| //CSE-KMS Method | ||
| String kmsKeyId = S3AUtils.lookupPassword(conf, | ||
| S3_ENCRYPTION_KEY, null); | ||
| // CSE-KMS Method | ||
| String kmsKeyId = getS3EncryptionKey(bucket, conf); | ||
| // Check if kmsKeyID is not null | ||
| Preconditions.checkArgument(kmsKeyId != null, "CSE-KMS method " | ||
| + "requires KMS key ID. Use " + S3_ENCRYPTION_KEY | ||
| Preconditions.checkArgument(!StringUtils.isBlank(kmsKeyId), "CSE-KMS " | ||
| + "method requires KMS key ID. Use " + S3_ENCRYPTION_KEY | ||
| + " property to set it. "); | ||
|
|
||
| EncryptionMaterialsProvider materialsProvider = | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
final?
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.
Cannot make it final. Assigning it a value in a method