YARN-8910. Fixed misleading log statement when container max retries is infinite.
Contributed by Chandni Singh
This commit is contained in:
parent
88cce32551
commit
47ad98b2e1
|
@ -1653,10 +1653,17 @@ public class ContainerImpl implements Container {
|
||||||
|
|
||||||
private void doRelaunch(final ContainerImpl container,
|
private void doRelaunch(final ContainerImpl container,
|
||||||
int remainingRetryAttempts, final int retryInterval) {
|
int remainingRetryAttempts, final int retryInterval) {
|
||||||
LOG.info("Relaunching Container " + container.getContainerId()
|
if (remainingRetryAttempts == ContainerRetryContext.RETRY_FOREVER) {
|
||||||
+ ". Remaining retry attempts(after relaunch) : "
|
LOG.info("Relaunching Container {}. " +
|
||||||
+ remainingRetryAttempts + ". Interval between retries is "
|
"retry interval {} ms", container.getContainerId(),
|
||||||
+ retryInterval + "ms");
|
retryInterval);
|
||||||
|
} else {
|
||||||
|
LOG.info("Relaunching Container {}. " +
|
||||||
|
"remaining retry attempts(after relaunch) {}, " +
|
||||||
|
"retry interval {} ms", container.getContainerId(),
|
||||||
|
remainingRetryAttempts, retryInterval);
|
||||||
|
}
|
||||||
|
|
||||||
container.wasLaunched = false;
|
container.wasLaunched = false;
|
||||||
container.metrics.endRunningContainer();
|
container.metrics.endRunningContainer();
|
||||||
if (retryInterval == 0) {
|
if (retryInterval == 0) {
|
||||||
|
|
|
@ -153,6 +153,10 @@ public class SlidingWindowRetryPolicy {
|
||||||
}
|
}
|
||||||
|
|
||||||
int getRemainingRetries() {
|
int getRemainingRetries() {
|
||||||
|
if (containerRetryContext.getMaxRetries() ==
|
||||||
|
ContainerRetryContext.RETRY_FOREVER) {
|
||||||
|
return ContainerRetryContext.RETRY_FOREVER;
|
||||||
|
}
|
||||||
return remainingRetries;
|
return remainingRetries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,12 @@ public class TestSlidingWindowRetryPolicy {
|
||||||
public void testNeverRetry() {
|
public void testNeverRetry() {
|
||||||
ContainerRetryContext retryContext =
|
ContainerRetryContext retryContext =
|
||||||
ContainerRetryContext.NEVER_RETRY_CONTEXT;
|
ContainerRetryContext.NEVER_RETRY_CONTEXT;
|
||||||
Assert.assertFalse("never retry", retryPolicy.shouldRetry(
|
SlidingWindowRetryPolicy.RetryContext windowContext = new
|
||||||
new SlidingWindowRetryPolicy.RetryContext(retryContext), 12));
|
SlidingWindowRetryPolicy.RetryContext(retryContext);
|
||||||
|
Assert.assertFalse("never retry", retryPolicy.shouldRetry(windowContext,
|
||||||
|
12));
|
||||||
|
Assert.assertEquals("remaining retries", 0,
|
||||||
|
windowContext.getRemainingRetries());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -52,8 +56,13 @@ public class TestSlidingWindowRetryPolicy {
|
||||||
ContainerRetryContext retryContext = ContainerRetryContext.newInstance(
|
ContainerRetryContext retryContext = ContainerRetryContext.newInstance(
|
||||||
ContainerRetryPolicy.RETRY_ON_ALL_ERRORS, null, -1,
|
ContainerRetryPolicy.RETRY_ON_ALL_ERRORS, null, -1,
|
||||||
0, 10);
|
0, 10);
|
||||||
Assert.assertTrue("always retry", retryPolicy.shouldRetry(
|
SlidingWindowRetryPolicy.RetryContext windowContext = new
|
||||||
new SlidingWindowRetryPolicy.RetryContext(retryContext), 12));
|
SlidingWindowRetryPolicy.RetryContext(retryContext);
|
||||||
|
Assert.assertTrue("always retry", retryPolicy.shouldRetry(windowContext,
|
||||||
|
12));
|
||||||
|
Assert.assertEquals("remaining retries",
|
||||||
|
ContainerRetryContext.RETRY_FOREVER,
|
||||||
|
windowContext.getRemainingRetries());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -65,19 +74,28 @@ public class TestSlidingWindowRetryPolicy {
|
||||||
Assert.assertTrue("retry 1",
|
Assert.assertTrue("retry 1",
|
||||||
retryPolicy.shouldRetry(windowRetryContext, 12));
|
retryPolicy.shouldRetry(windowRetryContext, 12));
|
||||||
retryPolicy.updateRetryContext(windowRetryContext);
|
retryPolicy.updateRetryContext(windowRetryContext);
|
||||||
|
Assert.assertEquals("remaining retries", 1,
|
||||||
|
windowRetryContext.getRemainingRetries());
|
||||||
|
|
||||||
clock.setTime(20);
|
clock.setTime(20);
|
||||||
Assert.assertTrue("retry 2",
|
Assert.assertTrue("retry 2",
|
||||||
retryPolicy.shouldRetry(windowRetryContext, 12));
|
retryPolicy.shouldRetry(windowRetryContext, 12));
|
||||||
retryPolicy.updateRetryContext(windowRetryContext);
|
retryPolicy.updateRetryContext(windowRetryContext);
|
||||||
|
Assert.assertEquals("remaining retries", 1,
|
||||||
|
windowRetryContext.getRemainingRetries());
|
||||||
|
|
||||||
clock.setTime(40);
|
clock.setTime(40);
|
||||||
Assert.assertTrue("retry 3",
|
Assert.assertTrue("retry 3",
|
||||||
retryPolicy.shouldRetry(windowRetryContext, 12));
|
retryPolicy.shouldRetry(windowRetryContext, 12));
|
||||||
retryPolicy.updateRetryContext(windowRetryContext);
|
retryPolicy.updateRetryContext(windowRetryContext);
|
||||||
|
Assert.assertEquals("remaining retries", 1,
|
||||||
|
windowRetryContext.getRemainingRetries());
|
||||||
|
|
||||||
clock.setTime(45);
|
clock.setTime(45);
|
||||||
Assert.assertFalse("retry failed",
|
Assert.assertFalse("retry failed",
|
||||||
retryPolicy.shouldRetry(windowRetryContext, 12));
|
retryPolicy.shouldRetry(windowRetryContext, 12));
|
||||||
|
retryPolicy.updateRetryContext(windowRetryContext);
|
||||||
|
Assert.assertEquals("remaining retries", 0,
|
||||||
|
windowRetryContext.getRemainingRetries());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue