This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 22c611b806d HDDS-17407. Allow for clock skew with revocation (#11952)
22c611b806d is described below

commit 22c611b806d4a870caa76c4d1832c59193b64510
Author: fmorg-git <[email protected]>
AuthorDate: Tue Nov 10 00:02:13 2026 -0800

    HDDS-17407. Allow for clock skew with revocation (#11952)
---
 .../om/service/RevokedSTSTokenCleanupService.java  |  7 +++--
 .../service/TestRevokedSTSTokenCleanupService.java | 31 +++++++++++++++++++++-
 2 files changed, 35 insertions(+), 3 deletions(-)

diff --git 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/RevokedSTSTokenCleanupService.java
 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/RevokedSTSTokenCleanupService.java
index b5d7a1eb9a3..71a4e0fabd5 100644
--- 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/RevokedSTSTokenCleanupService.java
+++ 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/RevokedSTSTokenCleanupService.java
@@ -57,8 +57,11 @@ public class RevokedSTSTokenCleanupService extends 
BackgroundService {
   // Use a single thread
   private static final int REVOKED_STS_TOKEN_CLEANER_CORE_POOL_SIZE = 1;
   private static final Clock CLOCK = Clock.system(ZoneOffset.UTC);
-  // Keep revocation entries until max STS token lifetime after the cutoff was 
captured.
-  private static final long CLEANUP_THRESHOLD = 
TimeUnit.SECONDS.toMillis(S3STSUtils.MAX_DURATION_SECONDS); // 12 hours
+  // Allow for the purging OM's clock being ahead of a validating OM's clock.
+  private static final long CLOCK_SKEW_MARGIN = TimeUnit.MINUTES.toMillis(30);
+  // Keep revocation entries until max STS token lifetime plus clock skew 
margin after the cutoff was captured.
+  private static final long CLEANUP_THRESHOLD =
+      TimeUnit.SECONDS.toMillis(S3STSUtils.MAX_DURATION_SECONDS) + 
CLOCK_SKEW_MARGIN; // 12 hours+0.5 hour = 12.5 hours
 
   private final OzoneManager ozoneManager;
   private final AtomicBoolean suspended;
diff --git 
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/service/TestRevokedSTSTokenCleanupService.java
 
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/service/TestRevokedSTSTokenCleanupService.java
index 8d4149bb807..4311638450c 100644
--- 
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/service/TestRevokedSTSTokenCleanupService.java
+++ 
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/service/TestRevokedSTSTokenCleanupService.java
@@ -102,13 +102,42 @@ public void submitsCleanupRequestForOnlyExpiredTokens() 
throws Exception {
       final DeleteRevokedSTSTokensRequest deleteRevokedSTSTokensRequest =
           omRequest.getDeleteRevokedSTSTokensRequest();
       
assertThat(deleteRevokedSTSTokensRequest.getOriginalAccessKeyIdList()).containsExactly("original-access-key-a");
-      final long cleanupThresholdMillis = 
TimeUnit.SECONDS.toMillis(S3STSUtils.MAX_DURATION_SECONDS);
+      final long cleanupThresholdMillis = 
TimeUnit.SECONDS.toMillis(S3STSUtils.MAX_DURATION_SECONDS)
+          + TimeUnit.MINUTES.toMillis(30);
       
assertThat(deleteRevokedSTSTokensRequest.hasPurgeBeforeMillis()).isTrue();
       assertThat(deleteRevokedSTSTokensRequest.getPurgeBeforeMillis())
           .isBetween(nowMillis - cleanupThresholdMillis, 
System.currentTimeMillis() - cleanupThresholdMillis);
     }
   }
 
+  @Test
+  public void testKeepsCutoffForClockSkewMarginPastMaxTokenLifetime() throws 
Exception {
+    final long nowMillis = testClock.millis();
+    revokedStsTokenTable.put(
+        "original-access-key-within-margin",
+        nowMillis - TimeUnit.HOURS.toMillis(12) - 
TimeUnit.MINUTES.toMillis(1));
+    revokedStsTokenTable.put(
+        "original-access-key-past-margin",
+        nowMillis - TimeUnit.HOURS.toMillis(12) - 
TimeUnit.MINUTES.toMillis(31));
+
+    final AtomicReference<OMRequest> capturedRequest = new AtomicReference<>();
+
+    try (MockedStatic<OzoneManagerRatisUtils> ozoneManagerRatisUtilsMock = 
mockStatic(OzoneManagerRatisUtils.class)) {
+      mockRatisSubmitAndCapture(ozoneManagerRatisUtilsMock, capturedRequest);
+
+      final RevokedSTSTokenCleanupService revokedSTSTokenCleanupService = 
createAndRunCleanupService();
+
+      assertThat(revokedSTSTokenCleanupService.getRunCount()).isEqualTo(1);
+      
assertThat(revokedSTSTokenCleanupService.getSubmittedDeletedEntryCount()).isEqualTo(1);
+
+      final OMRequest omRequest = capturedRequest.get();
+      assertThat(omRequest).isNotNull();
+      assertThat(
+          
omRequest.getDeleteRevokedSTSTokensRequest().getOriginalAccessKeyIdList())
+          .containsExactly("original-access-key-past-margin");
+    }
+  }
+
   @Test
   public void doesNotSubmitRequestWhenThereAreNoExpiredTokens() throws 
Exception {
     // If only non-expired entries exist in the revoked sts token table, no 
cleanup request should be submitted and


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

Reply via email to