-
Notifications
You must be signed in to change notification settings - Fork 616
HDDS-10979. Support STANDARD_IA S3 storage class to accept EC replication config. #8399
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
Changes from 5 commits
58d4603
718bea2
b0f7a6e
9f6a48d
57edbeb
f9187da
b273851
5773d58
4581468
7f66cd6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # 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. | ||
|
|
||
| *** Settings *** | ||
| Documentation S3 gateway test with aws cli with STANDARD_IA storage class | ||
| Library OperatingSystem | ||
| Library String | ||
| Resource ../commonlib.robot | ||
| Resource commonawslib.robot | ||
| Resource mpu_lib.robot | ||
| Test Timeout 5 minutes | ||
| Suite Setup Setup EC Multipart Tests | ||
| Suite Teardown Teardown EC Multipart Tests | ||
| Test Setup Generate random prefix | ||
| Default Tags ec-storage-class | ||
|
|
||
| *** Keywords *** | ||
| Setup EC Multipart Tests | ||
| Setup s3 tests | ||
| Create Random File KB 1023 /tmp/1mb | ||
|
|
||
| Teardown EC Multipart Tests | ||
| Remove Files /tmp/1mb | ||
|
|
||
| *** Variables *** | ||
| ${ENDPOINT_URL} http://s3g:9878 | ||
| ${BUCKET} generated | ||
|
|
||
| *** Test Cases *** | ||
|
Contributor
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. Maybe add a ozone sh command to validate the replication configuration? |
||
|
|
||
| Put Object with STANDARD_IA storage class | ||
| ${file_checksum} = Execute md5sum /tmp/1mb | awk '{print $1}' | ||
|
|
||
| ${result} = Execute AWSS3ApiCli put-object --bucket ${BUCKET} --key ${PREFIX}/ecKey32 --body /tmp/1mb --storage-class STANDARD_IA | ||
| ${eTag} = Execute and checkrc echo '${result}' | jq -r '.ETag' 0 | ||
|
adoroszlai marked this conversation as resolved.
Outdated
|
||
| Should Be Equal ${eTag} \"${file_checksum}\" | ||
|
|
||
| ${result} = Execute AWSS3ApiCli put-object --bucket ${BUCKET} --key ${PREFIX}/ecKey63 --body /tmp/1mb --storage-class STANDARD_IA --metadata="storage-config=rs-6-3-1024k" | ||
| ${eTag} = Execute and checkrc echo '${result}' | jq -r '.ETag' 0 | ||
| Should Be Equal ${eTag} \"${file_checksum}\" | ||
|
|
||
| Test multipart upload with STANDARD_IA storage | ||
| ${uploadID} = Initiate MPU ${BUCKET} ${PREFIX}/ecmultipartKey32 0 --storage-class STANDARD_IA | ||
| ${eTag1} = Upload MPU part ${BUCKET} ${PREFIX}/ecmultipartKey32 ${uploadID} 1 /tmp/1mb | ||
| ${result} = Execute AWSS3APICli list-parts --bucket ${BUCKET} --key ${PREFIX}/ecmultipartKey32 --upload-id ${uploadID} | ||
| ${part1} = Execute and checkrc echo '${result}' | jq -r '.Parts[0].ETag' 0 | ||
| Should Be equal ${part1} ${eTag1} | ||
| Should contain ${result} STANDARD_IA | ||
| ${result} = Abort MPU ${BUCKET} ${PREFIX}/ecmultipartKey32 ${uploadID} 0 | ||
|
|
||
| ${uploadID} = Initiate MPU ${BUCKET} ${PREFIX}/ecmultipartKey63 0 --storage-class STANDARD_IA --metadata="storage-config=rs-6-3-1024k" | ||
| ${eTag1} = Upload MPU part ${BUCKET} ${PREFIX}/ecmultipartKey63 ${uploadID} 1 /tmp/part1 | ||
| ${result} = Execute AWSS3APICli list-parts --bucket ${BUCKET} --key ${PREFIX}/ecmultipartKey63 --upload-id ${uploadID} | ||
| ${part1} = Execute and checkrc echo '${result}' | jq -r '.Parts[0].ETag' 0 | ||
| Should Be equal ${part1} ${eTag1} | ||
| Should contain ${result} STANDARD_IA | ||
| ${result} = Abort MPU ${BUCKET} ${PREFIX}/ecmultipartKey63 ${uploadID} 0 | ||
|
|
||
| Copy Object change storage class to STANDARD_IA | ||
| ${file_checksum} = Execute md5sum /tmp/1mb | awk '{print $1}' | ||
| ${result} = Execute AWSS3ApiCli put-object --bucket ${BUCKET} --key ${PREFIX}/copyobject/Key1 --body /tmp/1mb | ||
| ${eTag} = Execute and checkrc echo '${result}' | jq -r '.ETag' 0 | ||
| Should Be Equal ${eTag} \"${file_checksum}\" | ||
|
|
||
| ${result} = Execute AWSS3APICli copy-object --storage-class STANDARD_IA --bucket ${BUCKET} --key ${PREFIX}/copyobject/Key1 --copy-source ${BUCKET}/${PREFIX}/copyobject/Key1 | ||
| Should contain ${result} ETag | ||
| ${eTag} = Execute and checkrc echo '${result}' | jq -r '.CopyObjectResult.ETag' 0 | ||
| Should Be Equal ${eTag} \"${file_checksum}\" | ||
|
|
||
| ${result} = Execute AWSS3APICli copy-object --storage-class STANDARD_IA --metadata="storage-config=rs-6-3-1024k" --bucket ${BUCKET} --key ${PREFIX}/copyobject/Key1 --copy-source ${BUCKET}/${PREFIX}/copyobject/Key1 | ||
| Should contain ${result} ETag | ||
| ${eTag} = Execute and checkrc echo '${result}' | jq -r '.CopyObjectResult.ETag' 0 | ||
| Should Be Equal ${eTag} \"${file_checksum}\" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |
| import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.newError; | ||
| import static org.apache.hadoop.ozone.s3.util.S3Consts.AWS_TAG_PREFIX; | ||
| import static org.apache.hadoop.ozone.s3.util.S3Consts.CUSTOM_METADATA_HEADER_PREFIX; | ||
| import static org.apache.hadoop.ozone.s3.util.S3Consts.STORAGE_CONFIG_HEADER; | ||
| import static org.apache.hadoop.ozone.s3.util.S3Consts.TAG_HEADER; | ||
| import static org.apache.hadoop.ozone.s3.util.S3Consts.TAG_KEY_LENGTH_LIMIT; | ||
| import static org.apache.hadoop.ozone.s3.util.S3Consts.TAG_NUM_LIMIT; | ||
|
|
@@ -97,7 +98,7 @@ public abstract class EndpointBase implements Auditor { | |
| private ContainerRequestContext context; | ||
|
|
||
| private Set<String> excludeMetadataFields = | ||
| new HashSet<>(Arrays.asList(OzoneConsts.GDPR_FLAG)); | ||
| new HashSet<>(Arrays.asList(OzoneConsts.GDPR_FLAG, STORAGE_CONFIG_HEADER)); | ||
|
Contributor
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. what does this mean
Contributor
Author
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. We store any x-amz-meta-key=value for an object in KeyArgs.metadata (or ex., Etag). ^^This will exclude storing EC storage config in the metadata because it will be available in replication config. We only want to use this header to determine EC replication config when client uses STANDARD_IA storage class. |
||
| private static final Logger LOG = | ||
| LoggerFactory.getLogger(EndpointBase.class); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,12 +49,14 @@ | |
| import static org.apache.hadoop.ozone.s3.util.S3Consts.COPY_SOURCE_IF_MODIFIED_SINCE; | ||
| import static org.apache.hadoop.ozone.s3.util.S3Consts.COPY_SOURCE_IF_UNMODIFIED_SINCE; | ||
| import static org.apache.hadoop.ozone.s3.util.S3Consts.CUSTOM_METADATA_COPY_DIRECTIVE_HEADER; | ||
| import static org.apache.hadoop.ozone.s3.util.S3Consts.CUSTOM_METADATA_HEADER_PREFIX; | ||
| import static org.apache.hadoop.ozone.s3.util.S3Consts.CopyDirective; | ||
| import static org.apache.hadoop.ozone.s3.util.S3Consts.DECODED_CONTENT_LENGTH_HEADER; | ||
| import static org.apache.hadoop.ozone.s3.util.S3Consts.MP_PARTS_COUNT; | ||
| import static org.apache.hadoop.ozone.s3.util.S3Consts.RANGE_HEADER; | ||
| import static org.apache.hadoop.ozone.s3.util.S3Consts.RANGE_HEADER_SUPPORTED_UNIT; | ||
| import static org.apache.hadoop.ozone.s3.util.S3Consts.STORAGE_CLASS_HEADER; | ||
| import static org.apache.hadoop.ozone.s3.util.S3Consts.STORAGE_CONFIG_HEADER; | ||
| import static org.apache.hadoop.ozone.s3.util.S3Consts.TAG_COUNT_HEADER; | ||
| import static org.apache.hadoop.ozone.s3.util.S3Consts.TAG_DIRECTIVE_HEADER; | ||
| import static org.apache.hadoop.ozone.s3.util.S3Utils.urlDecode; | ||
|
|
@@ -230,7 +232,7 @@ public Response put( | |
| boolean auditSuccess = true; | ||
| PerformanceStringBuilder perf = new PerformanceStringBuilder(); | ||
|
|
||
| String copyHeader = null, storageType = null; | ||
| String copyHeader = null, storageType = null, storageConfig = null; | ||
| DigestInputStream digestInputStream = null; | ||
| try { | ||
| if (aclMarker != null) { | ||
|
|
@@ -256,12 +258,13 @@ public Response put( | |
|
|
||
| copyHeader = headers.getHeaderString(COPY_SOURCE_HEADER); | ||
| storageType = headers.getHeaderString(STORAGE_CLASS_HEADER); | ||
| storageConfig = headers.getHeaderString(CUSTOM_METADATA_HEADER_PREFIX + STORAGE_CONFIG_HEADER); | ||
|
Contributor
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. curious: how will a client add the header to the request? is it supported by s3 cli or hadoop aws cloud connector? i wonder where we add this information in the developer doc.
Contributor
Author
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. All s3 clients should support it. They would just need to add the "x-amz-metadata-storage-class=" to their requests. |
||
| boolean storageTypeDefault = StringUtils.isEmpty(storageType); | ||
|
|
||
| // Normal put object | ||
| OzoneBucket bucket = volume.getBucket(bucketName); | ||
| ReplicationConfig replicationConfig = | ||
| getReplicationConfig(bucket, storageType); | ||
| getReplicationConfig(bucket, storageType, storageConfig); | ||
|
|
||
| boolean enableEC = false; | ||
| if ((replicationConfig != null && | ||
|
|
@@ -817,14 +820,15 @@ public Response initializeMultipartUpload( | |
| try { | ||
| OzoneBucket ozoneBucket = getBucket(bucket); | ||
| String storageType = headers.getHeaderString(STORAGE_CLASS_HEADER); | ||
| String storageConfig = headers.getHeaderString(CUSTOM_METADATA_HEADER_PREFIX + STORAGE_CONFIG_HEADER); | ||
|
|
||
| Map<String, String> customMetadata = | ||
| getCustomMetadataFromHeaders(headers.getRequestHeaders()); | ||
|
|
||
| Map<String, String> tags = getTaggingFromHeaders(headers); | ||
|
|
||
| ReplicationConfig replicationConfig = | ||
| getReplicationConfig(ozoneBucket, storageType); | ||
| getReplicationConfig(ozoneBucket, storageType, storageConfig); | ||
|
|
||
| OmMultipartInfo multipartInfo = | ||
| ozoneBucket.initiateMultipartUpload(key, replicationConfig, customMetadata, tags); | ||
|
|
@@ -857,21 +861,20 @@ public Response initializeMultipartUpload( | |
| } | ||
|
|
||
| private ReplicationConfig getReplicationConfig(OzoneBucket ozoneBucket, | ||
| String storageType) throws OS3Exception { | ||
| if (StringUtils.isEmpty(storageType)) { | ||
| S3StorageType defaultStorageType = S3StorageType.getDefault(ozoneConfiguration); | ||
| storageType = (defaultStorageType != null ? defaultStorageType.toString() : null); | ||
| } | ||
| String storageType, String storageConfig) throws OS3Exception { | ||
|
|
||
| ReplicationConfig clientConfiguredReplicationConfig = null; | ||
| String replication = ozoneConfiguration.get(OZONE_REPLICATION); | ||
|
|
||
| if (replication != null) { | ||
| clientConfiguredReplicationConfig = ReplicationConfig.parse( | ||
| ReplicationType.valueOf(ozoneConfiguration | ||
| .get(OZONE_REPLICATION_TYPE, OZONE_REPLICATION_TYPE_DEFAULT)), | ||
| replication, ozoneConfiguration); | ||
| ReplicationType replicationType = ReplicationType.valueOf( | ||
| ozoneConfiguration.get(OZONE_REPLICATION_TYPE, OZONE_REPLICATION_TYPE_DEFAULT)); | ||
| clientConfiguredReplicationConfig = | ||
| (replicationType == ReplicationType.EC) ? | ||
| new ECReplicationConfig(replication) : ReplicationConfig.parse( | ||
| replicationType, replication, ozoneConfiguration); | ||
| } | ||
|
adoroszlai marked this conversation as resolved.
Outdated
|
||
| return S3Utils.resolveS3ClientSideReplicationConfig(storageType, | ||
| return S3Utils.resolveS3ClientSideReplicationConfig(storageType, storageConfig, | ||
| clientConfiguredReplicationConfig, ozoneBucket.getReplicationConfig()); | ||
| } | ||
|
|
||
|
|
@@ -974,9 +977,10 @@ private Response createMultipartKey(OzoneVolume volume, String bucket, | |
|
|
||
| copyHeader = headers.getHeaderString(COPY_SOURCE_HEADER); | ||
| String storageType = headers.getHeaderString(STORAGE_CLASS_HEADER); | ||
| String storageConfig = headers.getHeaderString(CUSTOM_METADATA_HEADER_PREFIX + STORAGE_CONFIG_HEADER); | ||
| final OzoneBucket ozoneBucket = volume.getBucket(bucket); | ||
| ReplicationConfig replicationConfig = | ||
| getReplicationConfig(ozoneBucket, storageType); | ||
| getReplicationConfig(ozoneBucket, storageType, storageConfig); | ||
|
|
||
| boolean enableEC = false; | ||
| if ((replicationConfig != null && | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,27 +21,29 @@ | |
| import org.apache.hadoop.hdds.client.ReplicationConfig; | ||
| import org.apache.hadoop.hdds.client.ReplicationFactor; | ||
| import org.apache.hadoop.hdds.client.ReplicationType; | ||
| import org.apache.hadoop.hdds.conf.ConfigurationSource; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos; | ||
| import org.apache.hadoop.ozone.OzoneConfigKeys; | ||
|
|
||
| /** | ||
| * Maps S3 storage class values to Ozone replication values. | ||
| */ | ||
|
|
||
| public enum S3StorageType { | ||
|
|
||
| REDUCED_REDUNDANCY(ReplicationType.RATIS, ReplicationFactor.ONE), | ||
| STANDARD(ReplicationType.RATIS, ReplicationFactor.THREE); | ||
| REDUCED_REDUNDANCY(ReplicationType.RATIS, ReplicationFactor.ONE, null), | ||
| STANDARD(ReplicationType.RATIS, ReplicationFactor.THREE, null), | ||
| STANDARD_IA(ReplicationType.EC, null, ECReplicationConfig.EcCodec.RS + "-3-2-1024k"); | ||
|
|
||
| private final ReplicationType type; | ||
| private final ReplicationFactor factor; | ||
| private final String ecReplicationString; | ||
|
|
||
| S3StorageType( | ||
| ReplicationType type, | ||
| ReplicationFactor factor) { | ||
| ReplicationFactor factor, | ||
| String ecReplicationString) { | ||
|
adoroszlai marked this conversation as resolved.
Outdated
|
||
| this.type = type; | ||
| this.factor = factor; | ||
| this.ecReplicationString = ecReplicationString; | ||
| } | ||
|
|
||
| public ReplicationFactor getFactor() { | ||
|
|
@@ -52,33 +54,13 @@ public ReplicationType getType() { | |
| return type; | ||
| } | ||
|
|
||
| /** | ||
| * Get default S3StorageType for a new key to be uploaded. | ||
| * This should align to the ozone cluster configuration. | ||
| * @param config OzoneConfiguration | ||
| * @return S3StorageType which wraps ozone replication type and factor | ||
| */ | ||
| public static S3StorageType getDefault(ConfigurationSource config) { | ||
| String replicationString = config.get(OzoneConfigKeys.OZONE_REPLICATION); | ||
| ReplicationFactor configFactor; | ||
| if (replicationString == null) { | ||
| // if no config is set then let server take decision | ||
| return null; | ||
| } | ||
| try { | ||
| configFactor = ReplicationFactor.valueOf( | ||
| Integer.parseInt(replicationString)); | ||
| } catch (NumberFormatException ex) { | ||
| // conservatively defaults to STANDARD on wrong config value | ||
| return STANDARD; | ||
| } | ||
| return configFactor == ReplicationFactor.ONE | ||
| ? REDUCED_REDUNDANCY : STANDARD; | ||
| public String getEcReplicationString() { | ||
| return ecReplicationString; | ||
| } | ||
|
|
||
| public static S3StorageType fromReplicationConfig(ReplicationConfig config) { | ||
| if (config instanceof ECReplicationConfig) { | ||
| return S3StorageType.STANDARD; | ||
| if (config.getReplicationType() == HddsProtos.ReplicationType.EC) { | ||
| return STANDARD_IA; | ||
|
Contributor
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. map EC type to STANDARD_IA.
Contributor
Author
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. This is done here. STANDARD_IA is mapped to EC/RS-3-2-1024k by default. |
||
| } | ||
| if (config.getReplicationType() == HddsProtos.ReplicationType.STAND_ALONE || | ||
| config.getRequiredNodes() == 1) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.