HADOOP-15390. Yarn RM logs flooded by DelegationTokenRenewer trying to renew KMS tokens (xiaochen via rkanter)
(cherry picked from commit 7ab08a9c37
)
This commit is contained in:
parent
463fcfb50a
commit
101d9005dd
|
@ -58,9 +58,9 @@ public class KMSTokenRenewer extends TokenRenewer {
|
||||||
try {
|
try {
|
||||||
if (!(keyProvider instanceof
|
if (!(keyProvider instanceof
|
||||||
KeyProviderDelegationTokenExtension.DelegationTokenExtension)) {
|
KeyProviderDelegationTokenExtension.DelegationTokenExtension)) {
|
||||||
LOG.warn("keyProvider {} cannot renew token {}.",
|
throw new IOException(String
|
||||||
keyProvider == null ? "null" : keyProvider.getClass(), token);
|
.format("keyProvider %s cannot renew token [%s]",
|
||||||
return 0;
|
keyProvider == null ? "null" : keyProvider.getClass(), token));
|
||||||
}
|
}
|
||||||
return ((KeyProviderDelegationTokenExtension.DelegationTokenExtension)
|
return ((KeyProviderDelegationTokenExtension.DelegationTokenExtension)
|
||||||
keyProvider).renewDelegationToken(token);
|
keyProvider).renewDelegationToken(token);
|
||||||
|
@ -78,9 +78,9 @@ public class KMSTokenRenewer extends TokenRenewer {
|
||||||
try {
|
try {
|
||||||
if (!(keyProvider instanceof
|
if (!(keyProvider instanceof
|
||||||
KeyProviderDelegationTokenExtension.DelegationTokenExtension)) {
|
KeyProviderDelegationTokenExtension.DelegationTokenExtension)) {
|
||||||
LOG.warn("keyProvider {} cannot cancel token {}.",
|
throw new IOException(String
|
||||||
keyProvider == null ? "null" : keyProvider.getClass(), token);
|
.format("keyProvider %s cannot cancel token [%s]",
|
||||||
return;
|
keyProvider == null ? "null" : keyProvider.getClass(), token));
|
||||||
}
|
}
|
||||||
((KeyProviderDelegationTokenExtension.DelegationTokenExtension)
|
((KeyProviderDelegationTokenExtension.DelegationTokenExtension)
|
||||||
keyProvider).cancelDelegationToken(token);
|
keyProvider).cancelDelegationToken(token);
|
||||||
|
|
|
@ -592,6 +592,10 @@ public class DelegationTokenRenewer extends AbstractService {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
// calculate timer time
|
// calculate timer time
|
||||||
long expiresIn = token.expirationDate - System.currentTimeMillis();
|
long expiresIn = token.expirationDate - System.currentTimeMillis();
|
||||||
|
if (expiresIn <= 0) {
|
||||||
|
LOG.info("Will not renew token " + token);
|
||||||
|
return;
|
||||||
|
}
|
||||||
long renewIn = token.expirationDate - expiresIn/10; // little bit before the expiration
|
long renewIn = token.expirationDate - expiresIn/10; // little bit before the expiration
|
||||||
// need to create new task every time
|
// need to create new task every time
|
||||||
RenewalTimerTask tTask = new RenewalTimerTask(token);
|
RenewalTimerTask tTask = new RenewalTimerTask(token);
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.security;
|
||||||
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Mockito.doAnswer;
|
import static org.mockito.Mockito.doAnswer;
|
||||||
|
@ -1401,4 +1402,22 @@ public class TestDelegationTokenRenewer {
|
||||||
.contains(YarnConfiguration.RM_DELEGATION_TOKEN_MAX_CONF_SIZE));
|
.contains(YarnConfiguration.RM_DELEGATION_TOKEN_MAX_CONF_SIZE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test if the token renewer returned an invalid expiration time, that token's
|
||||||
|
// renewal should be ignored.
|
||||||
|
@Test
|
||||||
|
public void testTokenRenewerInvalidReturn() throws Exception {
|
||||||
|
DelegationTokenToRenew mockDttr = mock(DelegationTokenToRenew.class);
|
||||||
|
mockDttr.expirationDate = 0;
|
||||||
|
delegationTokenRenewer.setTimerForTokenRenewal(mockDttr);
|
||||||
|
assertNull(mockDttr.timerTask);
|
||||||
|
|
||||||
|
mockDttr.expirationDate = -1;
|
||||||
|
delegationTokenRenewer.setTimerForTokenRenewal(mockDttr);
|
||||||
|
assertNull(mockDttr.timerTask);
|
||||||
|
|
||||||
|
mockDttr.expirationDate = System.currentTimeMillis() - 1;
|
||||||
|
delegationTokenRenewer.setTimerForTokenRenewal(mockDttr);
|
||||||
|
assertNull(mockDttr.timerTask);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue