Skip to content

Commit

Permalink
Do not give up if Results is powering logs (actions#2893)
Browse files Browse the repository at this point in the history
* Do not give us if Results is powering logs

* No need to send telemtry to Actions server in Results only case
  • Loading branch information
yacaovsnc authored Sep 28, 2023
1 parent c3a7188 commit 463ec00
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
28 changes: 16 additions & 12 deletions src/Runner.Common/JobServerQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface IJobServerQueue : IRunnerService, IThrottlingReporter
TaskCompletionSource<int> JobRecordUpdated { get; }
event EventHandler<ThrottlingEventArgs> 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);
Expand Down Expand Up @@ -96,14 +96,14 @@ public override void Initialize(IHostContext hostContext)
_resultsServer = hostContext.GetService<IResultsServer>();
}

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);
}
Expand All @@ -119,7 +119,7 @@ public void Start(Pipelines.AgentJobRequestMessage jobRequest, bool resultServic
{
string liveConsoleFeedUrl = null;
Trace.Info("Initializing results client");
if (resultServiceOnly
if (resultsServiceOnly
&& serviceEndPoint.Data.TryGetValue("FeedStreamUrl", out var feedStreamUrl)
&& !string.IsNullOrEmpty(feedStreamUrl))
{
Expand Down Expand Up @@ -541,10 +541,12 @@ private async Task ProcessResultsUploadQueueAsync(bool runOnce = false)
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);
}
}
}

Expand Down Expand Up @@ -660,9 +662,11 @@ private async Task ProcessTimelinesUpdateQueueAsync(bool runOnce = false)
{
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))
Expand Down
2 changes: 1 addition & 1 deletion src/Runner.Worker/JobRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public async Task<TaskResult> RunAsync(AgentJobRequestMessage message, Cancellat
launchServer.InitializeLaunchClient(new Uri(launchReceiverEndpoint), accessToken);
}
_jobServerQueue = HostContext.GetService<IJobServerQueue>();
_jobServerQueue.Start(message, resultServiceOnly: true);
_jobServerQueue.Start(message, resultsServiceOnly: true);
}
else
{
Expand Down

0 comments on commit 463ec00

Please sign in to comment.