From 04ef6521e0c2704d2cc8972befcb01eb750b5d76 Mon Sep 17 00:00:00 2001 From: Florian Hussonnois Date: Wed, 3 Jul 2024 16:58:40 +0200 Subject: [PATCH] fix(batch/runner): catch all exceptions while on killing job --- src/main/java/io/kestra/plugin/gcp/runner/Batch.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/kestra/plugin/gcp/runner/Batch.java b/src/main/java/io/kestra/plugin/gcp/runner/Batch.java index e07b61e0..3f5fa660 100644 --- a/src/main/java/io/kestra/plugin/gcp/runner/Batch.java +++ b/src/main/java/io/kestra/plugin/gcp/runner/Batch.java @@ -473,10 +473,12 @@ protected Map runnerAdditionalVars(RunContext runContext, TaskCo private void safelyKillJob(final RunContext runContext, final GoogleCredentials credentials, final String jobName) { + runContext.logger().info("Killing Job {}", jobName); // Use a dedicated BatchServiceClient, as the one used in the run method may be closed in the meantime. try (BatchServiceClient batchServiceClient = newBatchServiceClient(credentials)) { final Job job = batchServiceClient.getJob(jobName); if (isTerminated(job.getStatus().getState())) { + runContext.logger().debug("Job {} is already terminated. Skip deletion request.", jobName); // Job execution is already terminated, so we can skip deletion. return; } @@ -493,9 +495,8 @@ private void safelyKillJob(final RunContext runContext, } catch (InterruptedException e) { runContext.logger().warn("Interrupted while deleting Job: {}", jobName); Thread.currentThread().interrupt(); - } catch (ExecutionException | IOException e) { - Throwable t = e.getCause() != null ? e.getCause() : e; - runContext.logger().warn("Failed to delete Job: {}", jobName, t); + } catch (Exception e) { + runContext.logger().warn("Failed to delete Job: {}", jobName, e); } }