-
Notifications
You must be signed in to change notification settings - Fork 592
HDDS-6214. [Multi-Tenant] Fix KMS Encryption/Decryption #3010
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
Conversation
Change-Id: Ifd842b379a05e929c5457e83d1c65e7cb8857a15
Change-Id: If68c79168c2292f05efdbeb63188a31b5ba5dd4c
Change-Id: I80b178bd3f29b1a691e62eb16e026347f5000390
prashantpogde
left a comment
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.
Minor comments and nitpicks.
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java
Outdated
Show resolved
Hide resolved
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
Outdated
Show resolved
Hide resolved
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneAclUtils.java
Outdated
Show resolved
Hide resolved
...gration-test/src/test/java/org/apache/hadoop/ozone/om/multitenant/TestMultiTenantVolume.java
Show resolved
Hide resolved
Change-Id: I993d05598f3ea66ac1819934ab5c5a94b9e50c70
|
Thanks @smengcl. Looks good to me.. Can you please also update the PR with the manual testing steps with KMS setup? That would be helpful |
Done. One should be able to follow the steps above to make encrypted buckets work with multi-tenancy. |
errose28
left a comment
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.
Thanks for working on this @smengcl. Some comments inline.
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
Show resolved
Hide resolved
...n/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java
Outdated
Show resolved
Hide resolved
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java
Outdated
Show resolved
Hide resolved
…lumeResponse` -> `GetS3VolumeInfoResponse`. Change-Id: Ie78d21ba242d1b176b3d11e7cc469d16e1da7599
…ass. Change-Id: I61edd834067e53b2aef9bcfdbbb7647a1288ec49
…eTenant`. Change-Id: I18e1ff588b26aa973afcc5dc580b5e95af400a4f
|
Also triggered a CI in my fork on a branch that has HDDS-6239 applied: |
Change-Id: I6859133b2f72971f0b68ea8116f4b539c484445d
|
Renamed Triggered proper CI here: https://github.com/smengcl/hadoop-ozone/commits/HDDS-6214-CI-2 |
|
CI passed on my fork. |
errose28
left a comment
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.
Thanks for the updates @smengcl. Looks like the name of the response proto got updated but the corresponding request proto did not. Other than that the rest of the changes look good.
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/S3VolumeContext.java
Show resolved
Hide resolved
…VolumeContext Change-Id: Ic54e8e1e854721503526db2507e31bd62fe3791d
Change-Id: Ib4f72918f86c289ad209387d9b1214fb3c183513
errose28
left a comment
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.
Thanks for the quick updates @smengcl. LGTM +1.
|
Thanks @errose28 and @prashantpogde for reviewing this. |
* HDDS-4944: (268 commits) HDDS-6366. [Multi-Tenant] Disallow specifying custom accessId in OzoneManager (apache#3166) HDDS-6275. [Multi-Tenant] Add feature documentation and CLI quick start guide (apache#3095) HDDS-6063. [Multi-Tenant] Use VOLUME_LOCK in read and write requests, and some minor refactoring (apache#3051) HDDS-6214. [Multi-Tenant] Fix KMS Encryption/Decryption (apache#3010) HDDS-6322. Fix Recon getting inccorrect sequenceNumber from OM (apache#3090) HDDS-5913. Avoid integer overflow when setting dfs.container.ratis.lo… (apache#2785) HDDS-6313. Remove replicas in ContainerStateMap when a container is deleted (apache#3086) HDDS-6186. Selective checks: skip integration check for unit test changes (apache#3061) HDDS-6310. Update json-smart to 2.4.7. (apache#3080) HDDS-6190. Cleanup unnecessary datanode id path checks. (apache#2993) HDDS-6304. Add enforcer to make sure ozone.version equals project.version (apache#3075) HDDS-6309. Update ozone-runner version to 20220212-1 (apache#3079) HDDS-6293. Allow using custom ozone-runner image (apache#3072) HDDS-4126. Freon key generator should support >2GB files. (apache#3054) HDDS-6088. Implement O3FS/OFS getFileChecksum() using file checksum helpers - addendum: fix checkstyle HDDS-6088. Implement O3FS/OFS getFileChecksum() using file checksum helpers. (apache#2935) HDDS-6084. [Multi-Tenant] Handle upgrades to version supporting S3 multi-tenancy (apache#3018) HDDS-6257. Wrong stack trace for S3 errors (apache#3066) HDDS-6278 Improve memory profile for listStatus API call. (apache#3053) HDDS-6285. ozonesecure-mr intermittently failing with timeout downloading packages (apache#3057) ...
https://issues.apache.org/jira/browse/HDDS-6214
Goal: Pass the correct user principal from the client to KMS to get the correct DEK.
Before this patch, in multi-tenancy, accessId is passed to KMS as the user name rather than the actual user principal (which is not desired).
Testing
Manual testing with Ranger KMS
Deployment and Configuration
keyadminuser, edit the policy (or add a new policy) to grantsystestuserCreate,Get Metadata,Generate EEKandDecrypt EEKpermission for the purpose of this test. Save and log out.kms-site.xml(orcore-site.xml, as long as the KMS would pick it up) to allows3g(assuming this is the login user of S3 Gateway) to impersonate other users when its talking to the KMS:In a production cluster, the value for
hadoop.kms.proxyuser.s3g.hostsshall be limited to the S3G host only for better security. i.e. https://github.com/apache/ozone/blob/cef8bf5/hadoop-hdds/docs/content/security/SecuringTDE.md?plain=1#L109hadoop.kms.proxyuser.s3g.userscould also be limited to the users that would use S3 Gateway.Be sure to restart the Ranger KMS after making the config change to take effect.
Commands
Set up a test tenant
kinitas an Ozone admin (omuser in this case)Create an encrypted bucket
kinitas a regular user (systestuser in this case)$ kinit -kt /cdep/keytabs/systest.keytab systest $ hadoop key create encKey ... encKey has been successfully created with options Options{cipher='AES/CTR/NoPadding', bitLength=128, description='null', attributes=null}. org.apache.hadoop.crypto.key.kms.LoadBalancingKMSClientProvider@434a63ab has been updated. $ ozone sh bucket create -k encKey --layout=FILE_SYSTEM_OPTIMIZED /tenant1/encrypted-bucket1 22/02/01 23:29:36 INFO rpc.RpcClient: Creating Bucket: tenant1/encrypted-bucket1, with systest as owner and Versioning false and Storage Type set to DISK and Encryption set to trueNote that we can only create encrypted buckets via OzoneShell for now, and
--layout=FILE_SYSTEM_OPTIMIZEDis required here if we want to use HCFS (ofs / o3fs) to access the bucket (because the default layout isOBJECT_STOREfor now, and it will break HCFS access).Run
ozone sh bucket infoto confirm the DEKs (data encryption keys actually used to encrypt each file, which also differs for every file) in the bucket will be encrypted by the key name inencryptionKeyNamefield:$ ozone sh bucket info /tenant1/encrypted-bucket1 { "metadata" : { }, "volumeName" : "tenant1", "name" : "encrypted-bucket1", "storageType" : "DISK", "versioning" : false, "usedBytes" : 805306368, "usedNamespace" : 1, "creationTime" : "2022-02-01T23:29:36.926Z", "modificationTime" : "2022-02-01T23:29:36.926Z", "encryptionKeyName" : "encKey", "quotaInBytes" : -1, "quotaInNamespace" : -1, "bucketLayout" : "FILE_SYSTEM_OPTIMIZED", "owner" : "systest", "link" : false }Ozone Shell access
$ vim file1.txt # this is test file1 $ ozone sh key put /tenant1/encrypted-bucket1/file1.txt file1.txt ...We can run
ozone sh key infoto confirm that the key is encrypted. It should print the IV and EDEK (encryptedDataEncryptionKey) of this key.$ ozone sh key info /tenant1/encrypted-bucket1/file1.txt { "volumeName" : "tenant1", "bucketName" : "encrypted-bucket1", "name" : "file1.txt", "dataSize" : 15, "creationTime" : "2022-02-01T23:34:22.062Z", "modificationTime" : "2022-02-01T23:34:27.373Z", "replicationConfig" : { "replicationFactor" : "THREE", "requiredNodes" : 3, "replicationType" : "RATIS" }, "ozoneKeyLocations" : [ { "containerID" : 4, "localID" : 109611004723200011, "length" : 15, "offset" : 0, "keyOffset" : 0 } ], "metadata" : { }, "fileEncryptionInfo" : { "cipherSuite" : "AES_CTR_NOPADDING", "iv" : "WWdijCnKdz9vu/PPuFAR4A==", "keyName" : "encKey", "ezKeyVersionName" : "orMslQ2AuxFLRCV0kAgDFv51HWyZm5KHanH4U4sW5Du", "encryptedDataEncryptionKey" : "RUxfXOmy/LAr0auDFZurbw==", "cryptoProtocolVersion" : "ENCRYPTION_ZONES" }, "replicationType" : "RATIS", "replicationFactor" : 3 }File retrieval via Ozone Shell should work, as expected:
$ ozone sh key cat /tenant1/encrypted-bucket1/file1.txt ... this is test file1S3 API access via S3 Gateway
Here we use AWS CLI to perform the testing, other S3 API compatible clients should also work seamlessly.
Install AWS CLI
Configure Access Key and Secret
Testing S3API
Optionally, we are defining an alias first to reduce the clutter in the AWS CLI command. If the S3 Gateway endpoint enables HTTPS and its certificate is not signed by a trusted CA, you will need to specify the CA bundle to pass the certiticate check.
Reading the file1 we uploaded earlier via Ozone Shell:
$ aws3 list-buckets { "Buckets": [ { "Name": "encrypted-bucket1", "CreationDate": "2022-02-01T23:29:36.926000+00:00" } ] } $ aws3 list-objects --bucket encrypted-bucket1 { "Contents": [ { "Key": "file1.txt", "LastModified": "2022-02-01T23:34:27.373000+00:00", "ETag": "2022-02-01T23:34:27.373Z", "Size": 15, "StorageClass": "STANDARD" } ] } $ aws3 get-object --bucket encrypted-bucket1 --key file1.txt file1-get.txt { "AcceptRanges": "bytes", "LastModified": "2022-02-01T23:34:27+00:00", "ContentLength": 15, "CacheControl": "no-cache", "ContentType": "application/octet-stream", "Expires": "2022-02-01T23:59:46+00:00", "Metadata": {} } $ cat file1-get.txt this is test file1Put a new file via S3 Gateway, then get it back:
This concludes the multi-tenancy manual testing with KMS encryption on the bucket via Ozone Shell and S3 API.