Skip to content

Commit

Permalink
cancel task when timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
BBesrour committed Dec 4, 2024
1 parent c83645a commit 7fa6a0e
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public CompletableFuture<BuildResult> 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.";
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7fa6a0e

Please sign in to comment.