Skip to content

HDDS-6349. IncompleteReadError on get MPU key from TDE bucket#3116

Merged
adoroszlai merged 7 commits intoapache:masterfrom
adoroszlai:HDDS-6349
Feb 24, 2022
Merged

HDDS-6349. IncompleteReadError on get MPU key from TDE bucket#3116
adoroszlai merged 7 commits intoapache:masterfrom
adoroszlai:HDDS-6349

Conversation

@adoroszlai
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

MultipartCryptoKeyInputStream may need to adjust read position and/or length to make sure it reads enough data to fill the crypto buffer. Position adjustment means read starts at a location before the actual requested position. Length adjustment means more data is read at the end. Extra data is discarded in both cases.

This PR fixes a bug in length adjustment: the position of the underlying stream was left at the position after the discarded part, this is where the next read started. Thus this part was missing from the final data at the client side.

The bug can be reproduced with MPU parts that are not whole multiples of the crypto buffer size, which defaults to 8KB. Hence test case is added where the first part has 1KB more, to trigger length adjustment in the second part.

The PR also adds the KMS configs necessary to test S3 Gateway with encrypted bucket, and runs all S3 tests with encrypted bucket, too (in non-HA case for now).

https://issues.apache.org/jira/browse/HDDS-6349

How was this patch tested?

Added Robot test to reproduce the problem:
https://github.com/adoroszlai/hadoop-ozone/runs/5263846303#step:5:528

And verified the fix:
https://github.com/adoroszlai/hadoop-ozone/runs/5265040205#step:5:524

@adoroszlai adoroszlai self-assigned this Feb 20, 2022
@adoroszlai adoroszlai added the bug Something isn't working label Feb 20, 2022
@adoroszlai adoroszlai changed the title HDDS-6349. Cannot get object uploaded via MPU to encrypted bucket HDDS-6349. IncompleteReadError on get MPU key from TDE bucket Feb 22, 2022
@avijayanhwx
Copy link
Copy Markdown
Contributor

cc @kerneltime for review.

@hanishakoneru
Copy link
Copy Markdown
Contributor

Thanks @adoroszlai for fixing this.
Patch LGTM.

I have a minor suggestion. The acceptance test looks great. Can we also add a check in the integration test TestOzoneAtRestEncryption#testMultipartUploadWithEncryption to verify that the inputStream position is as expected after a read.
Something like this at line 531:

diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneAtRestEncryption.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneAtRestEncryption.java
index 4ebcc8745..a247b0e79 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneAtRestEncryption.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneAtRestEncryption.java
@@ -528,6 +528,9 @@ public void testMultipartUploadWithEncryption(OzoneBucket bucket,
         inputStream.read(readData, 0, readDataLen);

         assertReadContent(inputData, readData, readFromPosition);
+        Assert.assertEquals("Position of CryptoInputStream after a read is " +
+                "not as expected", readFromPosition + readDataLen,
+            cryptoInputStream.getPos());
       }
     }
   }

It would be good if this test also checked reading the file consecutively without reseting position. If not this, at least a check for verifying position would be good to have.

@adoroszlai
Copy link
Copy Markdown
Contributor Author

Thanks @hanishakoneru for the review and the pointer to TestOzoneAtRestEncryption. Added checks as suggested.

[INFO] Tests run: 16, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 55.158 s - in org.apache.hadoop.ozone.client.rpc.TestOzoneAtRestEncryption

while same test on master:

[ERROR]   TestOzoneAtRestEncryption.testMPUwithLinkBucket:458->testMultipartUploadWithEncryption:538 expected:<263462> but was:<265108>
[ERROR]   TestOzoneAtRestEncryption.testMPUwithLinkBucket:458->testMultipartUploadWithEncryption:538 expected:<266843> but was:<270090>
[ERROR]   TestOzoneAtRestEncryption.testMPUwithOnePart:425->testMultipartUploadWithEncryption:538 expected:<89586> but was:<90112>
[ERROR]   TestOzoneAtRestEncryption.testMPUwithOnePart:425->testMultipartUploadWithEncryption:538 expected:<89455> but was:<90112>
[ERROR]   TestOzoneAtRestEncryption.testMPUwithThreePartsOverride:441->testMultipartUploadWithEncryption:538 expected:<528440> but was:<528739>
[ERROR]   TestOzoneAtRestEncryption.testMPUwithThreePartsOverride:441->testMultipartUploadWithEncryption:538 expected:<527370> but was:<534235>
[ERROR]   TestOzoneAtRestEncryption.testMPUwithTwoParts:433->testMultipartUploadWithEncryption:538 expected:<264508> but was:<267719>
[ERROR]   TestOzoneAtRestEncryption.testMPUwithTwoParts:433->testMultipartUploadWithEncryption:538 expected:<264261> but was:<270519>

@adoroszlai adoroszlai added the s3 S3 Gateway label Feb 24, 2022
Copy link
Copy Markdown
Contributor

@hanishakoneru hanishakoneru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @adoroszlai. LGTM. +1 for merge.

@adoroszlai adoroszlai merged commit 5f4c31a into apache:master Feb 24, 2022
@adoroszlai adoroszlai deleted the HDDS-6349 branch February 24, 2022 16:41
@adoroszlai
Copy link
Copy Markdown
Contributor Author

Thanks @hanishakoneru for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working s3 S3 Gateway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants