From 463ec00cb43e0707280aead478cfcb44d0bf9b17 Mon Sep 17 00:00:00 2001 From: Yang Cao Date: Thu, 28 Sep 2023 16:05:11 -0400 Subject: [PATCH] Do not give up if Results is powering logs (#2893) * Do not give us if Results is powering logs * No need to send telemtry to Actions server in Results only case --- src/Runner.Common/JobServerQueue.cs | 28 ++++++++++++++++------------ src/Runner.Worker/JobRunner.cs | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Runner.Common/JobServerQueue.cs b/src/Runner.Common/JobServerQueue.cs index 5717894bf..6234b4bdd 100644 --- a/src/Runner.Common/JobServerQueue.cs +++ b/src/Runner.Common/JobServerQueue.cs @@ -17,7 +17,7 @@ namespace GitHub.Runner.Common TaskCompletionSource JobRecordUpdated { get; } event EventHandler JobServerQueueThrottling; Task ShutdownAsync(); - void Start(Pipelines.AgentJobRequestMessage jobRequest, bool resultServiceOnly = false); + void Start(Pipelines.AgentJobRequestMessage jobRequest, bool resultsServiceOnly = false); void QueueWebConsoleLine(Guid stepRecordId, string line, long? lineNumber = null); void QueueFileUpload(Guid timelineId, Guid timelineRecordId, string type, string name, string path, bool deleteSource); void QueueResultsUpload(Guid timelineRecordId, string name, string path, string type, bool deleteSource, bool finalize, bool firstBlock, long totalLines); @@ -96,14 +96,14 @@ namespace GitHub.Runner.Common _resultsServer = hostContext.GetService(); } - public void Start(Pipelines.AgentJobRequestMessage jobRequest, bool resultServiceOnly = false) + public void Start(Pipelines.AgentJobRequestMessage jobRequest, bool resultsServiceOnly = false) { Trace.Entering(); - _resultsServiceOnly = resultServiceOnly; + _resultsServiceOnly = resultsServiceOnly; var serviceEndPoint = jobRequest.Resources.Endpoints.Single(x => string.Equals(x.Name, WellKnownServiceEndpointNames.SystemVssConnection, StringComparison.OrdinalIgnoreCase)); - if (!resultServiceOnly) + if (!resultsServiceOnly) { _jobServer.InitializeWebsocketClient(serviceEndPoint); } @@ -119,7 +119,7 @@ namespace GitHub.Runner.Common { string liveConsoleFeedUrl = null; Trace.Info("Initializing results client"); - if (resultServiceOnly + if (resultsServiceOnly && serviceEndPoint.Data.TryGetValue("FeedStreamUrl", out var feedStreamUrl) && !string.IsNullOrEmpty(feedStreamUrl)) { @@ -541,10 +541,12 @@ namespace GitHub.Runner.Common Trace.Error(ex); errorCount++; - // If we hit any exceptions uploading to Results, let's skip any additional uploads to Results - _resultsClientInitiated = false; - - SendResultsTelemetry(ex); + // If we hit any exceptions uploading to Results, let's skip any additional uploads to Results unless Results is serving logs + if (!_resultsServiceOnly) + { + _resultsClientInitiated = false; + SendResultsTelemetry(ex); + } } } @@ -660,9 +662,11 @@ namespace GitHub.Runner.Common { Trace.Info("Catch exception during update steps, skip update Results."); Trace.Error(e); - _resultsClientInitiated = false; - - SendResultsTelemetry(e); + if (!_resultsServiceOnly) + { + _resultsClientInitiated = false; + SendResultsTelemetry(e); + } } if (_bufferedRetryRecords.Remove(update.TimelineId)) diff --git a/src/Runner.Worker/JobRunner.cs b/src/Runner.Worker/JobRunner.cs index 0b0ca7a64..aa6580402 100644 --- a/src/Runner.Worker/JobRunner.cs +++ b/src/Runner.Worker/JobRunner.cs @@ -72,7 +72,7 @@ namespace GitHub.Runner.Worker launchServer.InitializeLaunchClient(new Uri(launchReceiverEndpoint), accessToken); } _jobServerQueue = HostContext.GetService(); - _jobServerQueue.Start(message, resultServiceOnly: true); + _jobServerQueue.Start(message, resultsServiceOnly: true); } else {