You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by sa...@apache.org on 2026/10/15 03:42:04 UTC
(ozone) branch master updated: HDDS-16789. Fix RevokedSTSTokenCleanupService issues when checkpoint is installed (#11516)
This is an automated email from the ASF dual-hosted git repository.
ChenSammi 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 7b8ace09aa8 HDDS-16789. Fix RevokedSTSTokenCleanupService issues when checkpoint is installed (#11516)
7b8ace09aa8 is described below
commit 7b8ace09aa8d82fdfaf4f531e4ab20762d3f5685
Author: fmorg-git <fm...@gmail.com>
AuthorDate: Wed Oct 14 20:41:58 2026 -0700
HDDS-16789. Fix RevokedSTSTokenCleanupService issues when checkpoint is installed (#11516)
---
.../om/service/RevokedSTSTokenCleanupService.java | 6 ++---
.../service/TestRevokedSTSTokenCleanupService.java | 31 ++++++++++++++++++++++
2 files changed, 33 insertions(+), 4 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 24966bf8413..b3062efbe5e 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
@@ -35,7 +35,6 @@
import org.apache.hadoop.hdds.utils.db.Table;
import org.apache.hadoop.ozone.ClientVersion;
import org.apache.hadoop.ozone.om.OMConfigKeys;
-import org.apache.hadoop.ozone.om.OMMetadataManager;
import org.apache.hadoop.ozone.om.OzoneManager;
import org.apache.hadoop.ozone.om.helpers.S3STSUtils;
import org.apache.hadoop.ozone.om.ratis.utils.OzoneManagerRatisUtils;
@@ -62,7 +61,6 @@ public class RevokedSTSTokenCleanupService extends BackgroundService {
private static final long CLEANUP_THRESHOLD = TimeUnit.SECONDS.toMillis(S3STSUtils.MAX_DURATION_SECONDS); // 12 hours
private final OzoneManager ozoneManager;
- private final OMMetadataManager metadataManager;
private final AtomicBoolean suspended;
private final AtomicLong runCount;
private final AtomicLong submittedDeletedEntryCount;
@@ -85,7 +83,6 @@ public RevokedSTSTokenCleanupService(long interval, TimeUnit unit, long serviceT
"RevokedSTSTokenCleanupService", interval, unit, REVOKED_STS_TOKEN_CLEANER_CORE_POOL_SIZE,
serviceTimeout, ozoneManager.getThreadNamePrefix());
this.ozoneManager = ozoneManager;
- this.metadataManager = ozoneManager.getMetadataManager();
this.suspended = new AtomicBoolean(false);
this.runCount = new AtomicLong(0);
this.submittedDeletedEntryCount = new AtomicLong(0);
@@ -136,7 +133,8 @@ public BackgroundTaskResult call() throws Exception {
final long startTime = Time.monotonicNow();
runCount.incrementAndGet();
- final Table<String, Long> revokedStsTokenTable = metadataManager.getS3RevokedStsTokenTable();
+ // Read the metadata manager on every run, since installing a checkpoint replaces it
+ final Table<String, Long> revokedStsTokenTable = ozoneManager.getMetadataManager().getS3RevokedStsTokenTable();
long deletedInRun = 0;
final List<String> batch = new ArrayList<>();
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 2b734cea245..dd9b30454f5 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
@@ -389,6 +389,37 @@ public void testCallIdCountIncreasesAcrossBatches() throws Exception {
}
}
+ @Test
+ public void scansCurrentMetadataManagerAfterItIsReplaced() throws Exception {
+ // Installing a checkpoint replaces the OM metadata manager after the service has been created, so each run must
+ // scan the revoked STS token table of the current metadata manager rather than the original one.
+ final long expiredRevocationTimeMillis = testClock.millis() - TimeUnit.HOURS.toMillis(13);
+ revokedStsTokenTable.put("original-access-key-old", expiredRevocationTimeMillis);
+
+ final AtomicReference<OMRequest> capturedRequest = new AtomicReference<>();
+
+ try (MockedStatic<OzoneManagerRatisUtils> ozoneManagerRatisUtilsMock = mockStatic(OzoneManagerRatisUtils.class)) {
+ mockRatisSubmitAndCapture(ozoneManagerRatisUtilsMock, capturedRequest);
+
+ final RevokedSTSTokenCleanupService revokedSTSTokenCleanupService = new RevokedSTSTokenCleanupService(
+ 1, TimeUnit.HOURS, 1_000, ozoneManager);
+
+ final StringInMemoryTestTable<Long> newRevokedStsTokenTable = new StringInMemoryTestTable<>();
+ newRevokedStsTokenTable.put("original-access-key-new", expiredRevocationTimeMillis);
+ final OMMetadataManager newOmMetadataManager = mock(OMMetadataManager.class);
+ when(newOmMetadataManager.getS3RevokedStsTokenTable()).thenReturn(newRevokedStsTokenTable);
+ when(ozoneManager.getMetadataManager()).thenReturn(newOmMetadataManager);
+
+ revokedSTSTokenCleanupService.runPeriodicalTaskNow();
+
+ assertThat(revokedSTSTokenCleanupService.getSubmittedDeletedEntryCount()).isEqualTo(1);
+ final OMRequest omRequest = capturedRequest.get();
+ assertThat(omRequest).isNotNull();
+ assertThat(omRequest.getDeleteRevokedSTSTokensRequest().getOriginalAccessKeyIdList())
+ .containsExactly("original-access-key-new");
+ }
+ }
+
private RevokedSTSTokenCleanupService createAndRunCleanupService() throws Exception {
final RevokedSTSTokenCleanupService revokedSTSTokenCleanupService =
new RevokedSTSTokenCleanupService(1, TimeUnit.HOURS, 1_000, ozoneManager);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozone.apache.org
For additional commands, e-mail: commits-help@ozone.apache.org