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: Fix an issue with stale containers #10005

Merged
Merged
Changes from all 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 @@ -320,10 +320,16 @@ private BuildResult runScriptAndParseResults(BuildJobQueueItem buildJob, String
buildLogsMap.appendBuildLogEntry(buildJob.id(), msg);
log.info(msg);

TarArchiveInputStream testResultsTarInputStream;
TarArchiveInputStream testResultsTarInputStream = null;
BBesrour marked this conversation as resolved.
Show resolved Hide resolved

BuildResult buildResult;

try {
testResultsTarInputStream = buildJobContainerService.getArchiveFromContainer(containerId, LOCALCI_WORKING_DIRECTORY + LOCALCI_RESULTS_DIRECTORY);

buildResult = parseTestResults(testResultsTarInputStream, buildJob.buildConfig().branch(), assignmentRepoCommitHash, testRepoCommitHash, buildCompletedDate,
buildJob.id());
buildResult.setBuildLogEntries(buildLogsMap.getAndTruncateBuildLogs(buildJob.id()));
}
catch (NotFoundException e) {
msg = "Could not find test results in container " + containerName;
Expand All @@ -332,7 +338,22 @@ private BuildResult runScriptAndParseResults(BuildJobQueueItem buildJob, String
// If the test results are not found, this means that something went wrong during the build and testing of the submission.
return constructFailedBuildResult(buildJob.buildConfig().branch(), assignmentRepoCommitHash, testRepoCommitHash, buildCompletedDate);
}
catch (IOException | IllegalStateException e) {
msg = "Error while parsing test results";
buildLogsMap.appendBuildLogEntry(buildJob.id(), msg);
throw new LocalCIException(msg, e);
}
finally {
try {
if (testResultsTarInputStream != null) {
testResultsTarInputStream.close();
}
}
catch (IOException e) {
msg = "Could not close test results tar input stream";
buildLogsMap.appendBuildLogEntry(buildJob.id(), msg);
log.error(msg, e);
}
buildJobContainerService.stopContainer(containerName);

// Delete the cloned repositories
Expand All @@ -357,22 +378,6 @@ 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,
buildJob.id());
buildResult.setBuildLogEntries(buildLogsMap.getAndTruncateBuildLogs(buildJob.id()));
}
catch (IOException | IllegalStateException e) {
msg = "Error while parsing test results";
buildLogsMap.appendBuildLogEntry(buildJob.id(), msg);
throw new LocalCIException(msg, e);
}

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