Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrated code lifecycle: Improve logging when build job times out #9955

Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ public void stopContainer(String containerName) {
// Get the container ID.
String containerId = container.getId();

log.info("Stopping container with id {}", containerId);

// Create a file "stop_container.txt" in the root directory of the container to indicate that the test results have been extracted or that the container should be stopped
// for some other reason.
// The container's main process is waiting for this file to appear and then stops the main process, thus stopping and removing the container.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,18 @@ private BuildResult runScriptAndParseResults(BuildJobQueueItem buildJob, String

ZonedDateTime buildCompletedDate = ZonedDateTime.now();

msg = "~~~~~~~~~~~~~~~~~~~~ Moving test results to specified directory for build job " + buildJob.id() + " ~~~~~~~~~~~~~~~~~~~~";
buildLogsMap.appendBuildLogEntry(buildJob.id(), msg);
log.debug(msg);

buildJobContainerService.moveResultsToSpecifiedDirectory(containerId, buildJob.buildConfig().resultPaths(), LOCALCI_WORKING_DIRECTORY + LOCALCI_RESULTS_DIRECTORY);

// Get an input stream of the test result files.

msg = "~~~~~~~~~~~~~~~~~~~~ Collecting test results from container " + containerId + " for build job " + buildJob.id() + " ~~~~~~~~~~~~~~~~~~~~";
buildLogsMap.appendBuildLogEntry(buildJob.id(), msg);
log.info(msg);

TarArchiveInputStream testResultsTarInputStream;

try {
Expand Down Expand Up @@ -349,6 +357,10 @@ private BuildResult runScriptAndParseResults(BuildJobQueueItem buildJob, String
}
}

msg = "~~~~~~~~~~~~~~~~~~~~ Parsing test results for build job " + buildJob.id() + " ~~~~~~~~~~~~~~~~~~~~";
buildLogsMap.appendBuildLogEntry(buildJob.id(), msg);
log.info(msg);

BuildResult buildResult;
try {
buildResult = parseTestResults(testResultsTarInputStream, buildJob.buildConfig().branch(), assignmentRepoCommitHash, testRepoCommitHash, buildCompletedDate,
Expand All @@ -362,7 +374,7 @@ private BuildResult runScriptAndParseResults(BuildJobQueueItem buildJob, String
}

msg = "Building and testing submission for repository " + assignmentRepositoryUri.repositorySlug() + " and commit hash " + assignmentRepoCommitHash + " took "
+ TimeLogUtil.formatDurationFrom(timeNanoStart);
+ TimeLogUtil.formatDurationFrom(timeNanoStart) + " for build job " + buildJob.id();
buildLogsMap.appendBuildLogEntry(buildJob.id(), msg);
log.info(msg);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Supplier;

Expand Down Expand Up @@ -176,6 +177,13 @@ public CompletableFuture<BuildResult> executeBuildJob(BuildJobQueueItem buildJob
}
else {
finishBuildJobExceptionally(buildJobItem.id(), containerName, e);
if (e instanceof TimeoutException) {
String msg = "Timed out after " + buildJobTimeoutSeconds + " seconds. "
+ "This may be due to an infinite loop or inefficient code. Please review your code for potential issues. "
+ "If the problem persists, contact your instructor for assistance. (Build job ID: " + buildJobItem.id() + ")";
BBesrour marked this conversation as resolved.
Show resolved Hide resolved
buildLogsMap.appendBuildLogEntry(buildJobItem.id(), msg);
log.warn(msg);
}
throw new CompletionException(e);
}
}
Expand Down
Loading