From c46dac6736deae8ac151001a3fece8057eb7325b Mon Sep 17 00:00:00 2001 From: Tingluo Huang Date: Thu, 21 Nov 2024 16:10:12 -0500 Subject: [PATCH] Ignore error when fail to report worker crash. (#3588) --- src/Runner.Listener/JobDispatcher.cs | 44 ++++++++++++++++------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/Runner.Listener/JobDispatcher.cs b/src/Runner.Listener/JobDispatcher.cs index e58e1ea7b..1b8196091 100644 --- a/src/Runner.Listener/JobDispatcher.cs +++ b/src/Runner.Listener/JobDispatcher.cs @@ -545,28 +545,36 @@ namespace GitHub.Runner.Listener detailInfo = string.Join(Environment.NewLine, workerOutput); Trace.Info($"Return code {returnCode} indicate worker encounter an unhandled exception or app crash, attach worker stdout/stderr to JobRequest result."); - var jobServer = await InitializeJobServerAsync(systemConnection); - var unhandledExceptionIssue = new Issue() { Type = IssueType.Error, Message = detailInfo }; - unhandledExceptionIssue.Data[Constants.Runner.InternalTelemetryIssueDataKey] = Constants.Runner.WorkerCrash; - switch (jobServer) + try { - case IJobServer js: - { - await LogWorkerProcessUnhandledException(js, message, unhandledExceptionIssue); - // Go ahead to finish the job with result 'Failed' if the STDERR from worker is System.IO.IOException, since it typically means we are running out of disk space. - if (detailInfo.Contains(typeof(System.IO.IOException).ToString(), StringComparison.OrdinalIgnoreCase)) + var jobServer = await InitializeJobServerAsync(systemConnection); + var unhandledExceptionIssue = new Issue() { Type = IssueType.Error, Message = detailInfo }; + unhandledExceptionIssue.Data[Constants.Runner.InternalTelemetryIssueDataKey] = Constants.Runner.WorkerCrash; + switch (jobServer) + { + case IJobServer js: { - Trace.Info($"Finish job with result 'Failed' due to IOException."); - await ForceFailJob(js, message); - } + await LogWorkerProcessUnhandledException(js, message, unhandledExceptionIssue); + // Go ahead to finish the job with result 'Failed' if the STDERR from worker is System.IO.IOException, since it typically means we are running out of disk space. + if (detailInfo.Contains(typeof(System.IO.IOException).ToString(), StringComparison.OrdinalIgnoreCase)) + { + Trace.Info($"Finish job with result 'Failed' due to IOException."); + await ForceFailJob(js, message); + } + break; + } + case IRunServer rs: + await ForceFailJob(rs, message, unhandledExceptionIssue); break; - } - case IRunServer rs: - await ForceFailJob(rs, message, unhandledExceptionIssue); - break; - default: - throw new NotSupportedException($"JobServer type '{jobServer.GetType().Name}' is not supported."); + default: + throw new NotSupportedException($"JobServer type '{jobServer.GetType().Name}' is not supported."); + } + } + catch (Exception ex) + { + Trace.Error($"Catch exception during log worker process unhandled exception."); + Trace.Error(ex); } }