XComp commented on a change in pull request #18987: URL: https://github.com/apache/flink/pull/18987#discussion_r822589446
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/cleanup/DefaultResourceCleaner.java ########## @@ -166,21 +188,49 @@ private DefaultResourceCleaner( mainThreadExecutor.assertRunningInMainThread(); CompletableFuture<Void> cleanupFuture = FutureUtils.completedVoidFuture(); - for (T cleanup : prioritizedCleanup) { - cleanupFuture = cleanupFuture.thenCompose(ignoredValue -> withRetry(jobId, cleanup)); + for (Map.Entry<String, T> cleanup : prioritizedCleanup.entrySet()) { + cleanupFuture = + cleanupFuture.thenCompose( + ignoredValue -> withRetry(jobId, cleanup.getKey(), cleanup.getValue())); } return cleanupFuture.thenCompose( ignoredValue -> FutureUtils.completeAll( - regularCleanup.stream() - .map(cleanup -> withRetry(jobId, cleanup)) + regularCleanup.entrySet().stream() + .map( + cleanupEntry -> + withRetry( + jobId, + cleanupEntry.getKey(), + cleanupEntry.getValue())) .collect(Collectors.toList()))); } - private CompletableFuture<Void> withRetry(JobID jobId, T cleanup) { + private CompletableFuture<Void> withRetry(JobID jobId, String label, T cleanup) { return FutureUtils.retryWithDelay( - () -> cleanupFn.cleanupAsync(cleanup, jobId, cleanupExecutor), + () -> + cleanupFn + .cleanupAsync(cleanup, jobId, cleanupExecutor) + .whenComplete( + (value, throwable) -> { + if (throwable != null) { + final String logMessage = + String.format( + "Cleanup of %s failed for job %s due to a %s: %s", + label, + jobId, + throwable + .getClass() + .getSimpleName(), + throwable.getMessage()); + if (LOG.isTraceEnabled()) { + LOG.trace(logMessage, throwable); Review comment: good point 👍 -- 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. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org