-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Update Runner to send step updates to Results #2510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4a54263
Also send Steps update to Results service
yacaovsnc 506ee7e
Refactor to separate results server from current job server
yacaovsnc 499bb79
If hit any error while uploading to Results, skip Results upload
yacaovsnc a55f68f
Add proxy authentication and buffer request for WinHttpHandler
yacaovsnc f77cba4
Remove unnecessary null guard
yacaovsnc 43773b0
Also send Results telemetry when step update fails
yacaovsnc 5f1697f
IResultsServer is not disposable
yacaovsnc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using GitHub.DistributedTask.WebApi; | ||
| using GitHub.Services.Results.Client; | ||
|
|
||
| namespace GitHub.Runner.Common | ||
| { | ||
| [ServiceLocator(Default = typeof(ResultServer))] | ||
| public interface IResultsServer : IRunnerService | ||
| { | ||
| void InitializeResultsClient(Uri uri, string token); | ||
|
|
||
| // logging and console | ||
| Task CreateResultsStepSummaryAsync(string planId, string jobId, Guid stepId, string file, | ||
| CancellationToken cancellationToken); | ||
|
|
||
| Task CreateResultsStepLogAsync(string planId, string jobId, Guid stepId, string file, bool finalize, | ||
| bool firstBlock, long lineCount, CancellationToken cancellationToken); | ||
|
|
||
| Task CreateResultsJobLogAsync(string planId, string jobId, string file, bool finalize, bool firstBlock, | ||
| long lineCount, CancellationToken cancellationToken); | ||
|
|
||
| Task UpdateResultsWorkflowStepsAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, | ||
| IEnumerable<TimelineRecord> records, CancellationToken cancellationToken); | ||
| } | ||
|
|
||
| public sealed class ResultServer : RunnerService, IResultsServer | ||
| { | ||
| private ResultsHttpClient _resultsClient; | ||
|
|
||
| public void InitializeResultsClient(Uri uri, string token) | ||
| { | ||
| var httpMessageHandler = HostContext.CreateHttpClientHandler(); | ||
| this._resultsClient = new ResultsHttpClient(uri, httpMessageHandler, token, disposeHandler: true); | ||
| } | ||
|
|
||
| public Task CreateResultsStepSummaryAsync(string planId, string jobId, Guid stepId, string file, | ||
| CancellationToken cancellationToken) | ||
| { | ||
| if (_resultsClient != null) | ||
| { | ||
| return _resultsClient.UploadStepSummaryAsync(planId, jobId, stepId, file, | ||
| cancellationToken: cancellationToken); | ||
| } | ||
|
|
||
| throw new InvalidOperationException("Results client is not initialized."); | ||
| } | ||
|
|
||
| public Task CreateResultsStepLogAsync(string planId, string jobId, Guid stepId, string file, bool finalize, | ||
| bool firstBlock, long lineCount, CancellationToken cancellationToken) | ||
| { | ||
| if (_resultsClient != null) | ||
| { | ||
| return _resultsClient.UploadResultsStepLogAsync(planId, jobId, stepId, file, finalize, firstBlock, | ||
| lineCount, cancellationToken: cancellationToken); | ||
| } | ||
|
|
||
| throw new InvalidOperationException("Results client is not initialized."); | ||
| } | ||
|
|
||
| public Task CreateResultsJobLogAsync(string planId, string jobId, string file, bool finalize, bool firstBlock, | ||
| long lineCount, CancellationToken cancellationToken) | ||
| { | ||
| if (_resultsClient != null) | ||
| { | ||
| return _resultsClient.UploadResultsJobLogAsync(planId, jobId, file, finalize, firstBlock, lineCount, | ||
| cancellationToken: cancellationToken); | ||
| } | ||
|
|
||
| throw new InvalidOperationException("Results client is not initialized."); | ||
| } | ||
|
|
||
| public Task UpdateResultsWorkflowStepsAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, | ||
| IEnumerable<TimelineRecord> records, CancellationToken cancellationToken) | ||
| { | ||
| if (_resultsClient != null) | ||
| { | ||
| try | ||
| { | ||
| var timelineRecords = records.ToList(); | ||
| return _resultsClient.UpdateWorkflowStepsAsync(planId, new List<TimelineRecord>(timelineRecords), | ||
| cancellationToken: cancellationToken); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| // Log error, but continue as this call is best-effort | ||
| Trace.Info($"Failed to update steps status due to {ex.GetType().Name}"); | ||
| Trace.Error(ex); | ||
| } | ||
| } | ||
|
|
||
| throw new InvalidOperationException("Results client is not initialized."); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.