pr feedback
parent
7f133d8cc7
commit
343b784d44
|
|
@ -79,10 +79,12 @@ class KubernetesTaskRunner {
|
||||||
const isKubectlLogsError =
|
const isKubectlLogsError =
|
||||||
errorMessage.includes('unable to retrieve container logs for containerd://') ||
|
errorMessage.includes('unable to retrieve container logs for containerd://') ||
|
||||||
errorMessage.toLowerCase().includes('unable to retrieve container logs');
|
errorMessage.toLowerCase().includes('unable to retrieve container logs');
|
||||||
|
|
||||||
if (isKubectlLogsError) {
|
if (isKubectlLogsError) {
|
||||||
CloudRunnerLogger.log(`Kubectl unable to retrieve logs, attempt ${kubectlLogsFailedCount}/${maxKubectlLogsFailures}`);
|
CloudRunnerLogger.log(
|
||||||
|
`Kubectl unable to retrieve logs, attempt ${kubectlLogsFailedCount}/${maxKubectlLogsFailures}`,
|
||||||
|
);
|
||||||
|
|
||||||
// If kubectl logs has failed multiple times, try reading the log file directly from the pod
|
// If kubectl logs has failed multiple times, try reading the log file directly from the pod
|
||||||
// This works even if the pod is terminated, as long as it hasn't been deleted
|
// This works even if the pod is terminated, as long as it hasn't been deleted
|
||||||
if (kubectlLogsFailedCount >= maxKubectlLogsFailures && !isRunning && !continueStreaming) {
|
if (kubectlLogsFailedCount >= maxKubectlLogsFailures && !isRunning && !continueStreaming) {
|
||||||
|
|
@ -91,7 +93,7 @@ class KubernetesTaskRunner {
|
||||||
// Try to read the log file from the pod
|
// Try to read the log file from the pod
|
||||||
// Use kubectl exec for running pods, or try to access via PVC if pod is terminated
|
// Use kubectl exec for running pods, or try to access via PVC if pod is terminated
|
||||||
let logFileContent = '';
|
let logFileContent = '';
|
||||||
|
|
||||||
if (isRunning) {
|
if (isRunning) {
|
||||||
// Pod is still running, try exec
|
// Pod is still running, try exec
|
||||||
logFileContent = await CloudRunnerSystem.Run(
|
logFileContent = await CloudRunnerSystem.Run(
|
||||||
|
|
@ -107,7 +109,7 @@ class KubernetesTaskRunner {
|
||||||
// and rely on the log file being written to the PVC (if mounted)
|
// and rely on the log file being written to the PVC (if mounted)
|
||||||
CloudRunnerLogger.logWarning(`Cannot read log file from terminated pod via exec`);
|
CloudRunnerLogger.logWarning(`Cannot read log file from terminated pod via exec`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (logFileContent && logFileContent.trim()) {
|
if (logFileContent && logFileContent.trim()) {
|
||||||
CloudRunnerLogger.log(`Successfully read log file from pod (${logFileContent.length} chars)`);
|
CloudRunnerLogger.log(`Successfully read log file from pod (${logFileContent.length} chars)`);
|
||||||
// Process the log file content line by line
|
// Process the log file content line by line
|
||||||
|
|
@ -122,7 +124,7 @@ class KubernetesTaskRunner {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we got the end of transmission marker
|
// Check if we got the end of transmission marker
|
||||||
if (FollowLogStreamService.DidReceiveEndOfTransmission) {
|
if (FollowLogStreamService.DidReceiveEndOfTransmission) {
|
||||||
CloudRunnerLogger.log('end of log stream (from log file)');
|
CloudRunnerLogger.log('end of log stream (from log file)');
|
||||||
|
|
@ -271,9 +273,7 @@ class KubernetesTaskRunner {
|
||||||
// These errors can be added via stderr even when kubectl fails
|
// These errors can be added via stderr even when kubectl fails
|
||||||
// We filter them out so they don't pollute the BuildResults
|
// We filter them out so they don't pollute the BuildResults
|
||||||
const lines = output.split('\n');
|
const lines = output.split('\n');
|
||||||
const filteredLines = lines.filter(
|
const filteredLines = lines.filter((line) => !line.toLowerCase().includes('unable to retrieve container logs'));
|
||||||
(line) => !line.toLowerCase().includes('unable to retrieve container logs'),
|
|
||||||
);
|
|
||||||
const filteredOutput = filteredLines.join('\n');
|
const filteredOutput = filteredLines.join('\n');
|
||||||
|
|
||||||
// Log if we filtered out significant content
|
// Log if we filtered out significant content
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue