mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-06-13 01:13:54 -07:00
pr feedback
This commit is contained in:
+54
-25
@@ -4413,8 +4413,6 @@ class KubernetesTaskRunner {
|
||||
await new Promise((resolve) => setTimeout(resolve, 3000));
|
||||
cloud_runner_logger_1.default.log(`Streaming logs from pod: ${podName} container: ${containerName} namespace: ${namespace} ${cloud_runner_1.default.buildParameters.kubeVolumeSize}/${cloud_runner_1.default.buildParameters.containerCpu}/${cloud_runner_1.default.buildParameters.containerMemory}`);
|
||||
const isRunning = await kubernetes_pods_1.default.IsPodRunning(podName, namespace, kubeClient);
|
||||
let extraFlags = ``;
|
||||
extraFlags += isRunning ? ` -f -c ${containerName} -n ${namespace}` : ` --previous -n ${namespace}`;
|
||||
const callback = (outputChunk) => {
|
||||
output += outputChunk;
|
||||
// split output chunk and handle per line
|
||||
@@ -4423,7 +4421,9 @@ class KubernetesTaskRunner {
|
||||
}
|
||||
};
|
||||
try {
|
||||
await cloud_runner_system_1.CloudRunnerSystem.Run(`kubectl logs ${podName}${extraFlags}`, false, true, callback);
|
||||
// Always specify container name explicitly to avoid containerd:// errors
|
||||
// Use -f for running pods, --previous for terminated pods
|
||||
await cloud_runner_system_1.CloudRunnerSystem.Run(`kubectl logs ${podName} -c ${containerName} -n ${namespace}${isRunning ? ' -f' : ' --previous'}`, false, true, callback);
|
||||
}
|
||||
catch (error) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 3000));
|
||||
@@ -5976,17 +5976,37 @@ class RemoteClientLogger {
|
||||
if (cloud_runner_options_1.default.providerStrategy !== 'k8s') {
|
||||
return;
|
||||
}
|
||||
cloud_runner_logger_1.default.log(`Collected Logs`);
|
||||
const collectedLogsMessage = `Collected Logs`;
|
||||
// For K8s, write to stdout so kubectl logs can capture it
|
||||
// This is critical because kubectl logs reads from stdout/stderr, not from GitHub Actions logs
|
||||
if (cloud_runner_options_1.default.providerStrategy === 'k8s') {
|
||||
process.stdout.write(`${collectedLogsMessage}\n`, 'utf8');
|
||||
process.stderr.write(`${collectedLogsMessage}\n`, 'utf8');
|
||||
}
|
||||
// Also log via CloudRunnerLogger for GitHub Actions
|
||||
cloud_runner_logger_1.default.log(collectedLogsMessage);
|
||||
// check for log file not existing
|
||||
if (!node_fs_1.default.existsSync(RemoteClientLogger.LogFilePath)) {
|
||||
cloud_runner_logger_1.default.log(`Log file does not exist`);
|
||||
const logFileMissingMessage = `Log file does not exist`;
|
||||
if (cloud_runner_options_1.default.providerStrategy === 'k8s') {
|
||||
process.stdout.write(`${logFileMissingMessage}\n`, 'utf8');
|
||||
}
|
||||
cloud_runner_logger_1.default.log(logFileMissingMessage);
|
||||
// check if CloudRunner.isCloudRunnerEnvironment is true, log
|
||||
if (!cloud_runner_1.default.isCloudRunnerEnvironment) {
|
||||
cloud_runner_logger_1.default.log(`Cloud Runner is not running in a cloud environment, not collecting logs`);
|
||||
const notCloudEnvMessage = `Cloud Runner is not running in a cloud environment, not collecting logs`;
|
||||
if (cloud_runner_options_1.default.providerStrategy === 'k8s') {
|
||||
process.stdout.write(`${notCloudEnvMessage}\n`, 'utf8');
|
||||
}
|
||||
cloud_runner_logger_1.default.log(notCloudEnvMessage);
|
||||
}
|
||||
return;
|
||||
}
|
||||
cloud_runner_logger_1.default.log(`Log file exist`);
|
||||
const logFileExistsMessage = `Log file exist`;
|
||||
if (cloud_runner_options_1.default.providerStrategy === 'k8s') {
|
||||
process.stdout.write(`${logFileExistsMessage}\n`, 'utf8');
|
||||
}
|
||||
cloud_runner_logger_1.default.log(logFileExistsMessage);
|
||||
await new Promise((resolve) => setTimeout(resolve, 1));
|
||||
// let hashedLogs = fs.readFileSync(RemoteClientLogger.LogFilePath).toString();
|
||||
//
|
||||
@@ -7533,23 +7553,25 @@ echo "CACHE_KEY=$CACHE_KEY"`;
|
||||
if [ ! -f "/data/cache/$CACHE_KEY/build/build-$BUILD_GUID.tar" ] && [ ! -f "/data/cache/$CACHE_KEY/build/build-$BUILD_GUID.tar.lz4" ]; then
|
||||
tar -cf "/data/cache/$CACHE_KEY/build/build-$BUILD_GUID.tar" --files-from /dev/null || touch "/data/cache/$CACHE_KEY/build/build-$BUILD_GUID.tar"
|
||||
fi
|
||||
# Run post-build tasks and pipe output through log stream to capture "Activation successful"
|
||||
# Use set +e to allow the command to fail without exiting the script, then restore set -e behavior
|
||||
set +e
|
||||
node ${builderPath} -m remote-cli-post-build | node ${builderPath} -m remote-cli-log-stream --logFile /home/job-log.txt || echo "Post-build command completed with warnings"
|
||||
set -e
|
||||
# Write end marker and pipe through log stream
|
||||
# Use set +e to prevent failure if builder path doesn't exist (builder might have been cleaned up)
|
||||
# Keep set +e for the rest of the script to prevent exit on error
|
||||
# Run post-build tasks and capture output
|
||||
# Note: Post-build may clean up the builder directory, so we write output directly to log file
|
||||
# Use set +e to allow the command to fail without exiting the script
|
||||
set +e
|
||||
# Run post-build and write output to both stdout (for K8s kubectl logs) and log file
|
||||
# For local-docker, stdout is captured by the log stream mechanism
|
||||
if [ -f "${builderPath}" ]; then
|
||||
echo "end of cloud runner job" | node ${builderPath} -m remote-cli-log-stream --logFile /home/job-log.txt || echo "end of cloud runner job" >> /home/job-log.txt
|
||||
echo "---${cloud_runner_1.default.buildParameters.logId}" | node ${builderPath} -m remote-cli-log-stream --logFile /home/job-log.txt || echo "---${cloud_runner_1.default.buildParameters.logId}" >> /home/job-log.txt
|
||||
# Use tee to write to both stdout and log file, ensuring output is captured
|
||||
# For K8s, kubectl logs reads from stdout, so we need stdout
|
||||
# For local-docker, the log file is read directly
|
||||
node ${builderPath} -m remote-cli-post-build 2>&1 | tee -a /home/job-log.txt || echo "Post-build command completed with warnings" | tee -a /home/job-log.txt
|
||||
else
|
||||
# Builder path doesn't exist, write directly to log file
|
||||
echo "end of cloud runner job" >> /home/job-log.txt
|
||||
echo "---${cloud_runner_1.default.buildParameters.logId}" >> /home/job-log.txt
|
||||
# Builder doesn't exist, skip post-build (shouldn't happen, but handle gracefully)
|
||||
echo "Builder path not found, skipping post-build" | tee -a /home/job-log.txt
|
||||
fi
|
||||
# Write end markers directly to log file (builder might be cleaned up by post-build)
|
||||
# Also write to stdout for K8s kubectl logs
|
||||
echo "end of cloud runner job" | tee -a /home/job-log.txt
|
||||
echo "---${cloud_runner_1.default.buildParameters.logId}" | tee -a /home/job-log.txt
|
||||
# Don't restore set -e - keep set +e to prevent script from exiting on error
|
||||
# This ensures the script completes successfully even if some operations fail
|
||||
# Mirror cache back into workspace for test assertions
|
||||
@@ -7568,11 +7590,18 @@ echo "CACHE_KEY=$CACHE_KEY"`;
|
||||
chmod -R +x "/entrypoint.sh"
|
||||
chmod -R +x "/steps"
|
||||
{ echo "game ci start"; echo "game ci start" >> /home/job-log.txt; echo "CACHE_KEY=$CACHE_KEY"; echo "$CACHE_KEY"; if [ -n "$LOCKED_WORKSPACE" ]; then echo "Retained Workspace: true"; fi; if [ -n "$LOCKED_WORKSPACE" ] && [ -d "$GITHUB_WORKSPACE/.git" ]; then echo "Retained Workspace Already Exists!"; fi; /entrypoint.sh; } | node ${builderPath} -m remote-cli-log-stream --logFile /home/job-log.txt
|
||||
# Run post-build and ensure output is captured in logs
|
||||
node ${builderPath} -m remote-cli-post-build | node ${builderPath} -m remote-cli-log-stream --logFile /home/job-log.txt || true
|
||||
# Write end marker through log stream to ensure it's captured in BuildResults
|
||||
echo "end of cloud runner job" | node ${builderPath} -m remote-cli-log-stream --logFile /home/job-log.txt
|
||||
echo "---${cloud_runner_1.default.buildParameters.logId}" | node ${builderPath} -m remote-cli-log-stream --logFile /home/job-log.txt`;
|
||||
# Run post-build and capture output to both stdout (for kubectl logs) and log file
|
||||
# Note: Post-build may clean up the builder directory, so write output directly
|
||||
set +e
|
||||
if [ -f "${builderPath}" ]; then
|
||||
# Use tee to write to both stdout and log file for K8s kubectl logs
|
||||
node ${builderPath} -m remote-cli-post-build 2>&1 | tee -a /home/job-log.txt || echo "Post-build command completed with warnings" | tee -a /home/job-log.txt
|
||||
else
|
||||
echo "Builder path not found, skipping post-build" | tee -a /home/job-log.txt
|
||||
fi
|
||||
# Write end markers to both stdout and log file (builder might be cleaned up by post-build)
|
||||
echo "end of cloud runner job" | tee -a /home/job-log.txt
|
||||
echo "---${cloud_runner_1.default.buildParameters.logId}" | tee -a /home/job-log.txt`;
|
||||
}
|
||||
// prettier-ignore
|
||||
return `
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user