devmadhuu opened a new pull request, #12160:
URL: https://github.com/apache/ozone/pull/12160

   ## What changes were proposed in this pull request?
   S3 Gateway does not send a storage policy to OM today. `x-amz-storage-class` 
only picks replication, so a `GLACIER` upload becomes RATIS/THREE with the 
bucket's policy instead of COLD. `S3StorageClassResolver` (HDDS-16039, 
HDDS-17607) is built at startup but no endpoint uses it. HDDS-17839 added 
`CreateKeyOptions`, so one `createKey` call can now carry both the storage 
policy and derived-key piggybacking. This PR wires the header through to OM. 
**Streaming write path change for carrying policy will be done in follow up 
PR.**
   
   **Mapping**
   
   | `x-amz-storage-class` | Replication | Storage policy sent to OM |
   |---|---|---|
   | absent | unchanged (client default, then bucket) | none: OM uses the 
bucket policy, then the cluster default |
   | `STANDARD`, `REDUCED_REDUNDANCY`, `STANDARD_IA` | unchanged | 
`ozone.s3g.storage-class.*.storage-policy`, or none when empty (default) |
   | `GLACIER` | RATIS/THREE | COLD |
   | `DEEP_ARCHIVE` | EC | COLD |
   | unknown | `400 InvalidStorageClass`, as before | none |
   
   **Changes**
   
   - `EndpointBase.resolveStorageClass(bucket)` resolves the header once, with 
the injected `S3StorageClassResolver`, into replication and storage policy. 
`getReplicationConfig`  delegates to it, so it no longer goes through 
`S3Utils.resolveS3ClientSideReplicationConfig`
     or re-reads `ozone.s3g.standard.storage-class.use-client-default`. This 
also removes the duplicated header logic noted in the #11867 review.
   - `ObjectEndpoint`:
     - PutObject, conditional PutObject (`If-None-Match: *`, `If-None-Match: 
<etag>`,
       `If-Match`) and CopyObject build one `CreateKeyOptions` with the policy.
     - CreateMultipartUpload uses `MultipartUploadOptions` with the policy. 
Parts inherit it
       from the open key, as before.
     - CopyObject takes the policy from the request header only. It does not 
copy the source
       key's policy.
     - A write that carries a policy uses the normal write path even when 
datastream is enabled.
       The streaming path cannot send the policy until HDDS-16679.
   - Client:
     - Add `CreateKeyOptions` overloads of `createKeyIfNotExists`, 
`createKeyIfNoneMatch` and
       `rewriteKeyIfMatch` to `ClientProtocol`, `RpcClient`, `S3ClientProtocol` 
and `OzoneBucket`.
       The existing positional overloads delegate to them, and each keeps its 
existing OM version
       check.
     - `RpcClient` rejects a key storage policy before sending it when OM does 
not support
       `STORAGE_POLICY_SUPPORT`, so an old OM cannot silently drop it during a 
rolling upgrade.
       This matches the existing MPU check. Writes without a policy are 
unaffected.
   - Test stubs: `ClientProtocolStub` and `OzoneBucketStub` implement the new 
overloads and record
     the policy on the key and the MPU. `KeyMetadataAwareOutputStream` copies 
its metadata map, as
     the real client stream does.
   
   **Not in this PR**
   
   - Streaming PutObject/CopyObject with a policy, and streaming MPU part 
uploads, need HDDS-16679.  With datastream enabled, MPU part blocks may still 
land on the datanode's default volume type,  although OM records the right 
policy.
   - Reporting the storage class on `GET/HEAD/LIST` is HDDS-17880.
   - A gateway setting to prefer bucket settings over the header is HDDS-17521.
   - User docs for ozone-site are tracked in HDDS-17545.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-17727
   
   ## How was this patch tested?
   
   - New unit tests:
     - `TestObjectPut`:
       - each storage class maps to the expected replication and policy;
       - no header sends no policy;
       - a configured STANDARD policy is sent;
       - each conditional write carries the policy;
       - datastream with a policy uses the normal path;
       - copy with and without the header.
     - `TestInitiateMultipartUpload`: the policy set at initiate is kept on 
complete.
     - `TestRpcClient`:
       - each options-based write sends the policy, the piggyback flag and its 
condition field;
       - an OM without `STORAGE_POLICY_SUPPORT` rejects a policy before the 
request is sent, and
         accepts the same write without one;
       - null options are rejected.
     - `TestOzoneBucket`: null options are rejected.
   - Updated `TestPermissionCheck` to mock the options-based calls.
   - `ozone-s3gateway` and `ozone-client` unit tests pass: 1838 and 639 tests.
   - Added the AWS SDK integration test `TestS3StorageClassWrite`: PUT, Copy 
and MPU with GLACIER
     give a COLD key. It could not be run locally because the S3 Gateway 
integration tests,
     including the existing `TestS3GatewayHealthCheck`, cannot reach the 
gateway on the local
     machine; it relies on CI.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to