Skip to content

Commit 67fcee5

Browse files
author
Fabian Morgan
committed
updates per design change
1 parent 97177d4 commit 67fcee5

File tree

5 files changed

+35
-35
lines changed

5 files changed

+35
-35
lines changed

hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2397,11 +2397,11 @@ message RevokeSTSTokenResponse {
23972397
}
23982398

23992399
/**
2400-
This will contain a list of revoked STS temporary access key IDs whose entries should be removed from
2400+
This will contain a list of revoked STS session tokens whose entries should be removed from
24012401
the s3RevokedStsTokenTable.
24022402
*/
24032403
message CleanupRevokedSTSTokensRequest {
2404-
repeated string accessKeyId = 1;
2404+
repeated string sessionToken = 1;
24052405
}
24062406

24072407
message CleanupRevokedSTSTokensResponse {

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/s3/security/S3CleanupRevokedSTSTokensRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, Execut
4343
final CleanupRevokedSTSTokensRequest request = getOmRequest().getCleanupRevokedSTSTokensRequest();
4444
final OMResponse.Builder omResponse = OmResponseUtil.getOMResponseBuilder(getOmRequest());
4545

46-
final List<String> accessKeyIds = request.getAccessKeyIdList();
47-
return new S3CleanupRevokedSTSTokensResponse(accessKeyIds, omResponse.build());
46+
final List<String> sessionTokens = request.getSessionTokenList();
47+
return new S3CleanupRevokedSTSTokensResponse(sessionTokens, omResponse.build());
4848
}
4949
}
5050

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/response/s3/security/S3CleanupRevokedSTSTokensResponse.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@
3636
@CleanupTableInfo(cleanupTables = {S3_REVOKED_STS_TOKEN_TABLE})
3737
public class S3CleanupRevokedSTSTokensResponse extends OMClientResponse {
3838

39-
private final List<String> accessKeyIds;
39+
private final List<String> sessionTokens;
4040

41-
public S3CleanupRevokedSTSTokensResponse(List<String> accessKeyIds, @Nonnull OMResponse omResponse) {
41+
public S3CleanupRevokedSTSTokensResponse(List<String> sessionTokens, @Nonnull OMResponse omResponse) {
4242
super(omResponse);
43-
this.accessKeyIds = accessKeyIds;
43+
this.sessionTokens = sessionTokens;
4444
}
4545

4646
@Override
4747
public void addToDBBatch(OMMetadataManager omMetadataManager, BatchOperation batchOperation) throws IOException {
48-
if (accessKeyIds == null || accessKeyIds.isEmpty()) {
48+
if (sessionTokens == null || sessionTokens.isEmpty()) {
4949
return;
5050
}
5151
if (!getOMResponse().hasStatus() || getOMResponse().getStatus() != OK) {
@@ -57,8 +57,8 @@ public void addToDBBatch(OMMetadataManager omMetadataManager, BatchOperation bat
5757
return;
5858
}
5959

60-
for (String accessKeyId : accessKeyIds) {
61-
table.deleteWithBatch(batchOperation, accessKeyId);
60+
for (String sessionToken : sessionTokens) {
61+
table.deleteWithBatch(batchOperation, sessionToken);
6262
}
6363
}
6464
}

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/RevokedSTSTokenCleanupService.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
/**
4949
* Background service that periodically scans the revoked STS token table and submits OM requests to
50-
* remove entries whose session token has expired.
50+
* remove entries have been present past the cleanup threshold.
5151
*/
5252
public class RevokedSTSTokenCleanupService extends BackgroundService {
5353
private static final Logger LOG = LoggerFactory.getLogger(RevokedSTSTokenCleanupService.class);
@@ -127,19 +127,19 @@ public BackgroundTaskResult call() throws Exception {
127127
final Table<String, Long> revokedStsTokenTable = metadataManager.getS3RevokedStsTokenTable();
128128

129129
// Collect entries that have existed for over 12 hours during the scan
130-
final List<String> accessKeyIdsToCleanup = new ArrayList<>();
130+
final List<String> sessionTokensToCleanup = new ArrayList<>();
131131

132132
// Iterate over all entries in the revoked STS token table and remove
133133
// those whose initialCreationTimeMillis is more than 12 hours
134134
try (Table.KeyValueIterator<String, Long> iterator = revokedStsTokenTable.iterator()) {
135135
iterator.seekToFirst();
136136
while (iterator.hasNext()) {
137137
final Table.KeyValue<String, Long> entry = iterator.next();
138-
final String accessKeyId = entry.getKey();
138+
final String sessionToken = entry.getKey();
139139
final Long initialCreationTimeMillis = entry.getValue();
140140

141141
if (shouldCleanup(initialCreationTimeMillis)) {
142-
accessKeyIdsToCleanup.add(accessKeyId);
142+
sessionTokensToCleanup.add(sessionToken);
143143
}
144144
}
145145
} catch (IOException e) {
@@ -149,11 +149,11 @@ public BackgroundTaskResult call() throws Exception {
149149
}
150150

151151
final long deletedInRun;
152-
if (!accessKeyIdsToCleanup.isEmpty()) {
153-
LOG.info("Found {} revoked STS token entries to clean up.", accessKeyIdsToCleanup.size());
154-
final boolean success = submitCleanupRequest(accessKeyIdsToCleanup);
152+
if (!sessionTokensToCleanup.isEmpty()) {
153+
LOG.info("Found {} revoked STS token entries to clean up.", sessionTokensToCleanup.size());
154+
final boolean success = submitCleanupRequest(sessionTokensToCleanup);
155155
if (success) {
156-
deletedInRun = accessKeyIdsToCleanup.size();
156+
deletedInRun = sessionTokensToCleanup.size();
157157
} else {
158158
deletedInRun = 0;
159159
LOG.warn(
@@ -178,7 +178,7 @@ public BackgroundTaskResult call() throws Exception {
178178
}
179179

180180
/**
181-
* Returns true if the given STS session token has expired.
181+
* Returns true if the given STS session token has been in the table past the cleanup threshold.
182182
*/
183183
private boolean shouldCleanup(long initialCreationTimeMillis) {
184184
final long now = CLOCK.millis();
@@ -197,9 +197,9 @@ private boolean shouldCleanup(long initialCreationTimeMillis) {
197197
/**
198198
* Builds and submits an OMRequest to delete the provided revoked STS token(s).
199199
*/
200-
private boolean submitCleanupRequest(List<String> expiredAccessKeyIds) {
200+
private boolean submitCleanupRequest(List<String> sessionTokens) {
201201
final CleanupRevokedSTSTokensRequest request = CleanupRevokedSTSTokensRequest.newBuilder()
202-
.addAllAccessKeyId(expiredAccessKeyIds)
202+
.addAllSessionToken(sessionTokens)
203203
.build();
204204

205205
final OMRequest omRequest = OMRequest.newBuilder()

hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/service/TestRevokedSTSTokenCleanupService.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ public void setUp() {
6666

6767
@Test
6868
public void submitsCleanupRequestForOnlyExpiredTokens() throws Exception {
69-
// If there are two revoked entries, one expired and one not expired, only the expired access key id should be
69+
// If there are two revoked entries, one expired and one not expired, only the expired session token should be
7070
// submitted for cleanup.
7171
final long nowMillis = testClock.millis();
7272
final long expiredCreationTimeMillis = nowMillis - TimeUnit.HOURS.toMillis(13); // older than 12h threshold
7373
final long validCreationTimeMillis = nowMillis - TimeUnit.HOURS.toMillis(1);
74-
revokedStsTokenTable.put("ASIA1234567890", expiredCreationTimeMillis);
75-
revokedStsTokenTable.put("ASIA4567890123", validCreationTimeMillis);
74+
revokedStsTokenTable.put("session-token-a", expiredCreationTimeMillis);
75+
revokedStsTokenTable.put("session-token-b", validCreationTimeMillis);
7676

7777
final AtomicReference<OMRequest> capturedRequest = new AtomicReference<>();
7878

@@ -91,7 +91,7 @@ public void submitsCleanupRequestForOnlyExpiredTokens() throws Exception {
9191

9292
final CleanupRevokedSTSTokensRequest cleanupRevokedSTSTokensRequest =
9393
omRequest.getCleanupRevokedSTSTokensRequest();
94-
assertThat(cleanupRevokedSTSTokensRequest.getAccessKeyIdList()).containsExactly("ASIA1234567890");
94+
assertThat(cleanupRevokedSTSTokensRequest.getSessionTokenList()).containsExactly("session-token-a");
9595
}
9696
}
9797

@@ -100,8 +100,8 @@ public void doesNotSubmitRequestWhenThereAreNoExpiredTokens() throws Exception {
100100
// If only non-expired entries exist in the revoked sts token table, no cleanup request should be submitted and
101101
// no metrics should be updated.
102102
final long nowMillis = testClock.millis();
103-
revokedStsTokenTable.put("ASIA1234567890", nowMillis - TimeUnit.HOURS.toMillis(1));
104-
revokedStsTokenTable.put("ASIA0123456789", nowMillis - TimeUnit.HOURS.toMillis(2));
103+
revokedStsTokenTable.put("session-token-c", nowMillis - TimeUnit.HOURS.toMillis(1));
104+
revokedStsTokenTable.put("session-token-d", nowMillis - TimeUnit.HOURS.toMillis(2));
105105

106106
final AtomicReference<OMRequest> capturedRequest = new AtomicReference<>();
107107

@@ -140,8 +140,8 @@ public void doesNotUpdateMetricsOnRatisSubmissionServiceExceptionFailure() throw
140140
// If there are expired tokens in the table but the OM request submission to clean up the entries fails with a
141141
// service exception, the metrics should not be updated
142142
final long nowMillis = testClock.millis();
143-
revokedStsTokenTable.put("ASIA1234567890", nowMillis - TimeUnit.HOURS.toMillis(13));
144-
revokedStsTokenTable.put("ASIA0987654321", nowMillis - TimeUnit.HOURS.toMillis(14));
143+
revokedStsTokenTable.put("session-token-e", nowMillis - TimeUnit.HOURS.toMillis(13));
144+
revokedStsTokenTable.put("session-token-f", nowMillis - TimeUnit.HOURS.toMillis(14));
145145

146146
final AtomicInteger submitAttempts = new AtomicInteger(0);
147147

@@ -163,7 +163,7 @@ public void doesNotUpdateMetricsOnNonSuccessfulResponse() throws Exception {
163163
// If there is an expired token in the table but the OM request submission to clean up the entries gets a
164164
// non-successful response, the metrics should not be updated
165165
final long nowMillis = testClock.millis();
166-
revokedStsTokenTable.put("ASIA1234567890", nowMillis - TimeUnit.HOURS.toMillis(20));
166+
revokedStsTokenTable.put("session-token-f", nowMillis - TimeUnit.HOURS.toMillis(20));
167167

168168
try (MockedStatic<OzoneManagerRatisUtils> ozoneManagerRatisUtilsMock = mockStatic(OzoneManagerRatisUtils.class)) {
169169
// Return a non-successful response
@@ -181,9 +181,9 @@ public void doesNotUpdateMetricsOnNonSuccessfulResponse() throws Exception {
181181
public void handlesAllExpiredTokens() throws Exception {
182182
// If all the tokens in the table are expired on a particular run, ensure the metrics are updated appropriately
183183
final long nowMillis = testClock.millis();
184-
revokedStsTokenTable.put("ASIA1234567890", nowMillis - TimeUnit.HOURS.toMillis(13));
185-
revokedStsTokenTable.put("ASIA0123456789", nowMillis - TimeUnit.HOURS.toMillis(14));
186-
revokedStsTokenTable.put("ASIA9876543210", nowMillis - TimeUnit.HOURS.toMillis(15));
184+
revokedStsTokenTable.put("session-token-g", nowMillis - TimeUnit.HOURS.toMillis(13));
185+
revokedStsTokenTable.put("session-token-h", nowMillis - TimeUnit.HOURS.toMillis(14));
186+
revokedStsTokenTable.put("session-token-i", nowMillis - TimeUnit.HOURS.toMillis(15));
187187

188188
final AtomicReference<OMRequest> capturedRequest = new AtomicReference<>();
189189

@@ -202,8 +202,8 @@ public void handlesAllExpiredTokens() throws Exception {
202202

203203
final CleanupRevokedSTSTokensRequest cleanupRevokedSTSTokensRequest =
204204
omRequest.getCleanupRevokedSTSTokensRequest();
205-
assertThat(cleanupRevokedSTSTokensRequest.getAccessKeyIdList())
206-
.containsExactlyInAnyOrder("ASIA1234567890", "ASIA0123456789", "ASIA9876543210");
205+
assertThat(cleanupRevokedSTSTokensRequest.getSessionTokenList())
206+
.containsExactlyInAnyOrder("session-token-g", "session-token-h", "session-token-i");
207207
}
208208
}
209209

0 commit comments

Comments
 (0)