Skip to content

Commit

Permalink
Provide more logging in retry logic
Browse files Browse the repository at this point in the history
  • Loading branch information
vibe13 committed Sep 11, 2020
1 parent e5d4119 commit d2195d4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@
import java.util.concurrent.TimeoutException;
import java.util.function.Supplier;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @author <a href="mailto:[email protected]">Matej Lazar</a>
*/
public class ScheduledExecutorServiceWithTimeout {

private static final Logger logger = LoggerFactory.getLogger(ScheduledExecutorServiceWithTimeout.class);

private ScheduledExecutorService executorService;

public ScheduledExecutorServiceWithTimeout(ScheduledExecutorService executorService) {
Expand All @@ -51,6 +56,7 @@ public CancellableCompletableFuture<Void> scheduleWithFixedDelayAndTimeout(
completableFuture.complete(null);
}
} catch (Throwable t) {
logger.error("Error while calling supplier.get()", t);
completableFuture.completeExceptionally(t);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,10 @@ private void monitorInitialization(
// the status is not to be retried
onError.accept(new Exception(throwable));
} else {
logger.error("Creating build environment failed! Retrying...", throwable);
logger.error(
"Creating build environment failed! Retrying ({} retries left)...",
throwable,
retries);
retryEnvironment(onComplete, onError, retries);
}
}
Expand Down Expand Up @@ -570,6 +573,7 @@ private boolean isPodRunning() {
logger.debug("Pod {} status: {}", pod.getName(), podStatus);

if (Arrays.asList(POD_FAILED_STATUSES).contains(podStatus)) {
logger.debug("Pod failed with status: {}", podStatus);
gaugeMetric.ifPresent(g -> g.incrementMetric(METRICS_POD_STARTED_FAILED_REASON_KEY + "." + podStatus));
throw new PodFailedStartException("Pod failed with status: " + podStatus, podStatus);
}
Expand Down

0 comments on commit d2195d4

Please sign in to comment.