Skip to content

Commit

Permalink
dont save result after grace period
Browse files Browse the repository at this point in the history
  • Loading branch information
BBesrour committed Sep 17, 2024
1 parent 70c3029 commit 991ac59
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public class SharedQueueProcessingService {

private boolean isPaused = false;

private boolean processResults = true;

public SharedQueueProcessingService(@Qualifier("hazelcastInstance") HazelcastInstance hazelcastInstance, ExecutorService localCIBuildExecutorService,
BuildJobManagementService buildJobManagementService, BuildLogsMap buildLogsMap, BuildAgentSshKeyService buildAgentSSHKeyService, TaskScheduler taskScheduler) {
this.hazelcastInstance = hazelcastInstance;
Expand Down Expand Up @@ -331,7 +333,12 @@ private void processBuild(BuildJobQueueItem buildJob) {
buildLogsMap.removeBuildLogs(buildJob.id());

ResultQueueItem resultQueueItem = new ResultQueueItem(buildResult, finishedJob, buildLogs, null);
resultQueue.add(resultQueueItem);
if (processResults) {
resultQueue.add(resultQueueItem);
}
else {
log.info("Build agent is paused. Not adding build result to result queue for build job: {}", buildJob);
}

// after processing a build job, remove it from the processing jobs
processingJobs.remove(buildJob.id());
Expand Down Expand Up @@ -366,7 +373,12 @@ private void processBuild(BuildJobQueueItem buildJob) {
failedResult.setBuildLogEntries(buildLogs);

ResultQueueItem resultQueueItem = new ResultQueueItem(failedResult, job, buildLogs, ex);
resultQueue.add(resultQueueItem);
if (processResults) {
resultQueue.add(resultQueueItem);
}
else {
log.info("Build agent is paused. Not adding build result to result queue for build job: {}", buildJob);
}

processingJobs.remove(buildJob.id());
localProcessingJobs.decrementAndGet();
Expand Down Expand Up @@ -411,6 +423,7 @@ private void pauseBuildAgent() {
return;
}

this.processResults = false;
Set<String> runningBuildJobIds = buildJobManagementService.getRunningBuildJobIds();
List<BuildJobQueueItem> runningBuildJobs = processingJobs.getAll(runningBuildJobIds).values().stream().toList();
runningBuildJobIds.forEach(buildJobManagementService::cancelBuildJob);
Expand All @@ -429,6 +442,7 @@ private void resumeBuildAgent() {

log.info("Resuming build agent with address {}", hazelcastInstance.getCluster().getLocalMember().getAddress().toString());
this.isPaused = false;
this.processResults = true;
this.listenerId = this.queue.addItemListener(new QueuedBuildJobItemListener(), true);
this.scheduledFuture = taskScheduler.scheduleAtFixedRate(this::checkAvailabilityAndProcessNextBuild, Duration.ofSeconds(10));
checkAvailabilityAndProcessNextBuild();
Expand Down

0 comments on commit 991ac59

Please sign in to comment.