[
https://issues.apache.org/jira/browse/KNOX-2214?focusedWorklogId=385437&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-385437
]
ASF GitHub Bot logged work on KNOX-2214:
----------------------------------------
Author: ASF GitHub Bot
Created on: 11/Feb/20 20:55
Start Date: 11/Feb/20 20:55
Worklog Time Spent: 10m
Work Description: pzampino commented on pull request #257: KNOX-2214 -
Periodic job to evict expired tokens
URL: https://github.com/apache/knox/pull/257#discussion_r377890180
##########
File path:
gateway-server/src/main/java/org/apache/knox/gateway/services/token/impl/DefaultTokenStateService.java
##########
@@ -278,18 +281,34 @@ protected String getTimestampDisplay(long timestamp) {
* Method that deletes expired tokens based on the token timestamp.
*/
protected void evictExpiredTokens() {
- try {
- for (final String token : getTokens()) {
- if (isExpired(token)) {
+ for (final String token : getTokens()) {
+ try {
+ if (needsEviction(token)) {
log.evictToken(getTokenDisplayText(token));
removeToken(token);
}
+ } catch (final Exception e) {
+ log.failedExpiredTokenEviction(getTokenDisplayText(token), e);
}
- } catch(final Exception e) {
- log.failedExpiredTokenEviction(e);
}
}
+ /**
+ * Method that checks if an expired token is ready to be evicted
+ * by adding configured grace period to the expiry time.
+ * @param token
+ * @return
+ */
+ protected boolean needsEviction(final String token) {
+ boolean needsEviction;
+ needsEviction = isUnknown(token); // Check if the token exist
Review comment:
If the token is unknown in this case, you're going to get an
IllegalArgumentException when the subsequent removal is attempted because this
statement says an unknown token -> needsEviction. I would argue that an unknown
token means it has probably already been evicted.
The following call to getTokenExpiration will already invoked
validateToken(), so the up-front isUnknownToken check here is unnecessary (IMO)
and the conclusion is incorrect.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 385437)
Time Spent: 4h 10m (was: 4h)
> Reaping of expired Knox tokens
> ------------------------------
>
> Key: KNOX-2214
> URL: https://issues.apache.org/jira/browse/KNOX-2214
> Project: Apache Knox
> Issue Type: Bug
> Components: Server
> Affects Versions: 1.4.0
> Reporter: Philip Zampino
> Assignee: Sandeep More
> Priority: Major
> Time Spent: 4h 10m
> Remaining Estimate: 0h
>
> When the TokenStateService is employed, if Knox-issued tokens aren't
> explicitly cancelled, then they remain in the persistent store forever. The
> TokenStateService should maintain a thread that removes expired tokens.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)