[ 
https://issues.apache.org/jira/browse/HDDS-16490?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Chung-En Lee updated HDDS-16490:
--------------------------------
    Status: Patch Available  (was: Open)

> Implement GetObjectRetention
> ----------------------------
>
>                 Key: HDDS-16490
>                 URL: https://issues.apache.org/jira/browse/HDDS-16490
>             Project: Apache Ozone
>          Issue Type: Sub-task
>            Reporter: Chung-En Lee
>            Assignee: Meng-Shuan Tsai
>            Priority: Major
>              Labels: pull-request-available
>
> Implement the S3 {{GetObjectRetention}} operation for a single key. It 
> returns the key's retention: {{Mode}}, {{RetainUntilDate}}, and the event 
> hold ({{EventHold}} / {{EventHoldDuration}}). The task covers S3 Gateway 
> routing and S3 action mapping, the OM protocol and client, authorization 
> (native ACLs or Ranger), and the OM read path. The key-level model 
> ({{OmKeyInfo#getRetention}} returning {{ObjectRetention}}) comes from 
> HDDS-16485 on the {{HDDS-15945-worm}} branch.
> *1. S3 Gateway ({{hadoop-ozone/s3gateway}})*
>  * Add a handler for {{GET /\{bucket}/\{key}?retention}} and add it to the 
> {{ObjectEndpoint}} handler chain before 
> {{ObjectOperationNotImplementedHandler}}.
>   ** {{ObjectRetentionHandler}} handles every HTTP method of {{?retention}}: 
> it serves {{GET}} and rejects {{PUT}} and {{DELETE}} with {{NotImplemented}}, 
> like the other subresource handlers, so {{retention}} is removed from the 
> subresources of {{ObjectOperationNotImplementedHandler}}. {{PUT ?retention}} 
> therefore still does not fall through to {{PutObject}} (which would overwrite 
> the key with the request body), and {{DELETE ?retention}} does not delete it. 
> HDDS-16489 adds {{PUT}} to the same handler.
>  * S3 action mapping (moved here from HDDS-16486):
>  ** {{S3GAction.GET_OBJECT_RETENTION}}.
>  ** {{S3GActionIamMapper}}: {{GET_OBJECT_RETENTION}} -> 
> {{GetObjectRetention}}.
>  ** {{IamSessionPolicyResolver.S3Action}}: {{GET_OBJECT_RETENTION}} with 
> {{READ}} at volume, bucket and object level, as for {{GET_OBJECT_TAGGING}}.
>  * Serialize the S3 {{Retention}} XML:
>  ** {{Mode}} and {{RetainUntilDate}} (ISO-8601, UTC).
>  ** While the event hold is {{ON}}: also {{EventHold=ON}} and 
> {{EventHoldDuration}}; {{RetainUntilDate}} is the effective date computed by 
> OM.
>  ** After the event hold is released: {{EventHold=OFF}} and no 
> {{EventHoldDuration}}; {{RetainUntilDate}} is the fixed date set at release.
>  ** If the key never had an event hold: no {{EventHold}} element at all (same 
> as AWS S3, verified with the AWS CLI).
>  * Map OM errors to S3 errors:
>  ** {{KEY_NOT_FOUND}} -> {{404 NoSuchKey}}.
>  ** New {{OBJECT_LOCK_CONFIG_NOT_FOUND}} -> new {{404 
> NoSuchObjectLockConfiguration}} ("The specified object does not have an 
> ObjectLock configuration") when the key has no retention.
>  ** {{INVALID_REQUEST}} -> {{400 InvalidRequest}} (existing mapping) when the 
> bucket does not have Object Lock enabled.
> *2. Protobuf ({{OmClientProtocol.proto}}) and client*
>  * Add a read-only request type {{GetObjectRetention}}, modeled on 
> {{GetObjectTagging}}:
>  ** {{GetObjectRetentionRequest}}: {{KeyArgs keyArgs}} (volume, bucket, key).
>  ** {{GetObjectRetentionResponse}}: the key's {{KeyRetention}}, with the 
> retain-until date replaced by the effective date computed by OM.
>  ** Take the next free {{Type}} / {{OMRequest}} / {{OMResponse}} numbers when 
> the PR is opened; other Object Lock sub-tasks add types too.
>  * Register the type in {{OmUtils.isReadOnly}} and 
> {{OmUtils.shouldSendToFollower}}, as for {{GetObjectTagging}}. While the 
> event hold is {{ON}}, the effective date uses the clock of the OM that serves 
> the read; it is informational only, since the lock does not depend on it.
>  * Client: {{ClientProtocol}}, {{RpcClient}}, 
> {{OzoneManagerProtocolClientSideTranslatorPB}}, and 
> {{OzoneBucket#getObjectRetention(String keyName)}} returning 
> {{ObjectRetention}} (design doc, New Ozone APIs).
>  * Once the Object Lock {{OzoneManagerVersion}} exists (no sub-task owns it 
> yet), check it in the client before sending the request.
> *3. OM read path ({{hadoop-ozone/ozone-manager}})*
>  * Follow {{GetObjectTagging}}: 
> {{OzoneManagerRequestHandler#handleReadRequest}} -> {{OmMetadataReader}} -> 
> {{KeyManager}}, with bucket link resolution, audit and metrics.
>  * Authorize with key-level {{READ}} in both models. With Ranger, the S3 
> action is {{GetObjectRetention}}; policy items with {{action-matches}} apply 
> once RANGER-5894 is released.
>  * If the bucket does not have Object Lock enabled, throw {{INVALID_REQUEST}}.
>  * If the key does not exist, throw {{KEY_NOT_FOUND}}.
>  * If {{OmKeyInfo#getRetention()}} is {{null}}, throw 
> {{OBJECT_LOCK_CONFIG_NOT_FOUND}}.
>  * Otherwise return the stored {{ObjectRetention}} and the effective 
> retain-until date:
>  ** Event hold {{ON}}: {{max(retentionDate, now + duration)}}, using 
> {{RetentionUtil.calculateRetainUntilDate}}. {{retentionDate == 0}} means 
> unset (a key that only got {{DefaultEventHold}}).
>  ** Otherwise: {{retentionDate}}. An expired date is still returned. Do not 
> call {{RetentionUtil.validateObjectRetention}} on this path; it rejects past 
> dates.
> *4. Tests*
>  * OM: fixed retention; event hold {{ON}} with and without {{retentionDate}}; 
> released hold; expired retention; no retention; bucket without Object Lock; 
> missing key.
>  * S3 Gateway: XML for each case, error mapping, and {{PUT ?retention}} still 
> returning {{NotImplemented}}.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

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

Reply via email to