From 7fa6a0e9693e4620834420330746ad9648fcc2e4 Mon Sep 17 00:00:00 2001 From: Mohamed Bilel Besrour Date: Wed, 4 Dec 2024 20:25:48 +0100 Subject: [PATCH] cancel task when timeout --- .../artemis/buildagent/service/BuildJobManagementService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobManagementService.java b/src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobManagementService.java index 5f1ad6d21439..5eaf3ee97bc8 100644 --- a/src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobManagementService.java +++ b/src/main/java/de/tum/cit/aet/artemis/buildagent/service/BuildJobManagementService.java @@ -167,6 +167,7 @@ public CompletableFuture executeBuildJob(BuildJobQueueItem buildJob // RejectedExecutionException is thrown if the queue size limit (defined in "artemis.continuous-integration.queue-size-limit") is reached. // Wrap the exception in a CompletionException so that the future is completed exceptionally and the thenAccept block is not run. // This CompletionException will not resurface anywhere else as it is thrown in this completable future's separate thread. + future.cancel(true); if (cancelledBuildJobs.contains(buildJobItem.id())) { finishCancelledBuildJob(buildJobItem.repositoryInfo().assignmentRepositoryUri(), buildJobItem.id(), containerName); String msg = "Build job with id " + buildJobItem.id() + " was cancelled."; @@ -233,7 +234,7 @@ private void finishBuildJobExceptionally(String buildJobId, String containerName String msg = "Error while executing build job " + buildJobId + ": " + exception.getMessage(); String stackTrace = stackTraceToString(exception); buildLogsMap.appendBuildLogEntry(buildJobId, new BuildLogDTO(ZonedDateTime.now(), msg + "\n" + stackTrace)); - log.error(msg); + log.error(msg, exception); log.info("Getting ID of running container {}", containerName); String containerId = buildJobContainerService.getIDOfRunningContainer(containerName);