Gargi-jais11 commented on code in PR #12170:
URL: https://github.com/apache/ozone/pull/12170#discussion_r4785393600


##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -491,6 +495,7 @@ Response handleGetRequest(ObjectRequestContext context, 
String keyPath)
       }
 
       addLastModifiedDate(responseBuilder, keyDetails);
+      addExpirationIfAny(responseBuilder, readResult);

Review Comment:
   I see that aws url encode the rule-id. Could we URL-encode the rule ID like 
AWS (percent-encoding, with a space as %20, not +)? and I think similar we need 
to do for PutObject as well.



##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmLCExpiration.java:
##########
@@ -61,15 +60,43 @@ public String getDate() {
     return date;
   }
 
+  /**
+   * Whether an object last modified at the given time has expired under this 
action, that is, the current time is
+   * after {@link #getExpiryTime(long)}.
+   *
+   * @param timestamp modification time of the object in milliseconds since 
epoch
+   */
   public boolean isExpired(long timestamp) {

Review Comment:
   I don't know if u are aware or not but `AbortIncompleteMultipartUpload` 
still uses m`odificationTime + DaysAfterInitiation` with no rounding. As far as 
I know, AWS rounds all day-based lifecycle actions to the next midnight UTC, 
not just Expiration.  It's fine as a follow-up JIRA if so.  Just pointing it 
here so that we don't miss it.



##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/protocol/ClientProtocol.java:
##########
@@ -161,9 +162,9 @@ OzoneVolume getVolumeDetails(String volumeName)
    * If Key exists, return returns OzoneKey.
    * If Key does not exist, throws an exception with error code KEY_NOT_FOUND
    *
-   * @return OzoneKey which gives basic information about the key.
+   * @return OzoneKey which gives basic information about the key, with its 
lifecycle expiration.
    */
-  OzoneKey headS3Object(String bucketName, String keyName) throws IOException;
+  S3KeyReadResult<OzoneKey> headS3Object(String bucketName, String keyName) 
throws IOException;

Review Comment:
   here changing the return types of **headS3Object** and **getS3KeyDetails** 
breaks both source and binary compatibility. ClientProtocol isn't marked 
`@InterfaceAudience.Private`, and applications can reach it through via proxy 
`OzoneClient.getProxy()`. I saw @chihsuan suggested an S3-specific result type. 
   but don't u think  it will be better if  we add new methods returning 
S3KeyReadResult and keep the existing ones (delegating) instead of changing 
their signatures? 



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataReader.java:
##########
@@ -236,6 +240,29 @@ public KeyInfoWithVolumeContext getKeyInfo(final OmKeyArgs 
args,
     }
   }
 
+  /**
+   * Returns when the key expires under the bucket lifecycle configuration, 
for the S3 x-amz-expiration header.
+   * Nothing is returned while the lifecycle service is disabled, since no key 
would be expired, nor for a key read
+   * from a snapshot. A failed lookup only omits the expiration.
+   */
+  @Nullable
+  private LifecycleExpirationInfo getLifecycleExpiration(ResolvedBucket 
bucket, String keyPath, OmKeyInfo keyInfo) {
+    OMMetadataManager metadataManager = keyManager.getMetadataManager();
+    if (!ozoneManager.getKeyLifecycleServiceConfig().isEnabled()
+        || metadataManager != ozoneManager.getMetadataManager()) {
+      return null;
+    }
+    try {
+      OmLifecycleConfiguration lifecycleConfiguration = 
metadataManager.getLifecycleConfigurationTable()
+          .get(metadataManager.getBucketKey(bucket.realVolume(), 
bucket.realBucket()));
+      return lifecycleConfiguration == null ? null : 
lifecycleConfiguration.getExpiration(keyInfo, keyPath);

Review Comment:
   I have a question as part of performance.
   **lifecycleConfigurationTable** is set up with plain 
**initializer.get(...)**, not getWithDbCache, so it isn't a full-cache table. 
With the service enabled, every S3 HEAD and GET now does a RocksDB lookup which 
mostly finds nothing because most buckets have no lifecycle rules. When there 
is a configuration, ithas to parse from protobuf (up to 1,000 rules) and every 
rule is checkedand that too all  are on the hot read path. Did you measure 
this? This table is small, so making it a full-cache table might be worth it.



-- 
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