ChenSammi commented on code in PR #10982:
URL: https://github.com/apache/ozone/pull/10982#discussion_r3775204276


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/lifecycle/OMLifecycleConfigurationSetRequest.java:
##########
@@ -203,6 +209,50 @@ public OMClientResponse 
validateAndUpdateCache(OzoneManager ozoneManager, Execut
     }
   }
 
+  /**
+   * Rejects lifecycle configurations where an AbortIncompleteMultipartUpload 
rule's
+   * daysAfterInitiation is greater than or equal to the cluster-wide MPU 
expire threshold
+   * (ozone.om.open.mpu.expire.threshold). When that happens, 
MultipartUploadCleanupService
+   * will reap the upload before the lifecycle rule ever fires, silently 
making the rule
+   * ineffective. Failing fast here surfaces the misconfiguration to the 
operator.
+   */
+  private static void validateAbortMpuDaysAgainstCleanupThreshold(
+      OzoneManager ozoneManager, LifecycleConfiguration config) throws 
OMException {
+    long expireThresholdMillis = 
ozoneManager.getConfiguration().getTimeDuration(
+        OMConfigKeys.OZONE_OM_MPU_EXPIRE_THRESHOLD,
+        OMConfigKeys.OZONE_OM_MPU_EXPIRE_THRESHOLD_DEFAULT,
+        TimeUnit.MILLISECONDS);
+
+    for (LifecycleRule rule : config.getRulesList()) {
+      if (!rule.getEnabled()) {
+        continue;
+      }
+      for (LifecycleAction action : rule.getActionList()) {
+        if (action.hasAbortIncompleteMultipartUpload()) {
+          int daysAfterInitiation = 
action.getAbortIncompleteMultipartUpload().getDaysAfterInitiation();
+          long daysAfterInitiationMillis = 
TimeUnit.DAYS.toMillis(daysAfterInitiation);
+          if (daysAfterInitiationMillis >= expireThresholdMillis) {
+            long expireThresholdDays = 
TimeUnit.MILLISECONDS.toDays(expireThresholdMillis);

Review Comment:
   We don't need to convert the expireThresholdMillis to expireThresholdDays, 
as the toDays() will do the truncate too. 
   
   We can just show the original value of following in the error message. 
   
   ```
    ozoneManager.getConfiguration().get(
                       OMConfigKeys.OZONE_OM_MPU_EXPIRE_THRESHOLD,
                       OMConfigKeys.OZONE_OM_MPU_EXPIRE_THRESHOLD_DEFAULT)
   ```



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