-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Support refresh runner configs with pipelines service. #3706
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -343,6 +343,12 @@ public string GetConfigFile(WellKnownConfigFile configFile) | |
".runner"); | ||
break; | ||
|
||
case WellKnownConfigFile.MigratedRunner: | ||
path = Path.Combine( | ||
GetDirectory(WellKnownDirectory.Root), | ||
".runner_migrated"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we are going to reuse There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we already delete the |
||
break; | ||
|
||
case WellKnownConfigFile.Credentials: | ||
path = Path.Combine( | ||
GetDirectory(WellKnownDirectory.Root), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
using GitHub.DistributedTask.WebApi; | ||
using System; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using GitHub.Services.WebApi; | ||
using GitHub.Services.Common; | ||
using GitHub.DistributedTask.WebApi; | ||
using GitHub.Runner.Sdk; | ||
using GitHub.Services.Common; | ||
using GitHub.Services.WebApi; | ||
|
||
namespace GitHub.Runner.Common | ||
{ | ||
|
@@ -50,7 +50,10 @@ public interface IRunnerServer : IRunnerService | |
Task<PackageMetadata> GetPackageAsync(string packageType, string platform, string version, bool includeToken, CancellationToken cancellationToken); | ||
|
||
// agent update | ||
Task<TaskAgent> UpdateAgentUpdateStateAsync(int agentPoolId, ulong agentId, string currentState, string trace); | ||
Task<TaskAgent> UpdateAgentUpdateStateAsync(int agentPoolId, ulong agentId, string currentState, string trace, CancellationToken cancellationToken = default); | ||
|
||
// runner config refresh | ||
Task<string> RefreshRunnerConfigAsync(int agentId, string configType, string encodedRunnerConfig, CancellationToken cancellationToken); | ||
} | ||
|
||
public sealed class RunnerServer : RunnerService, IRunnerServer | ||
|
@@ -315,10 +318,17 @@ public Task<PackageMetadata> GetPackageAsync(string packageType, string platform | |
return _genericTaskAgentClient.GetPackageAsync(packageType, platform, version, includeToken, cancellationToken: cancellationToken); | ||
} | ||
|
||
public Task<TaskAgent> UpdateAgentUpdateStateAsync(int agentPoolId, ulong agentId, string currentState, string trace) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. only add cancellation token |
||
public Task<TaskAgent> UpdateAgentUpdateStateAsync(int agentPoolId, ulong agentId, string currentState, string trace, CancellationToken cancellationToken = default) | ||
{ | ||
CheckConnection(RunnerConnectionType.Generic); | ||
return _genericTaskAgentClient.UpdateAgentUpdateStateAsync(agentPoolId, agentId, currentState, trace, cancellationToken: cancellationToken); | ||
} | ||
|
||
// runner config refresh | ||
public Task<string> RefreshRunnerConfigAsync(int agentId, string configType, string encodedRunnerConfig, CancellationToken cancellationToken) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. new endpoint added by https://github.com/github/actions-dotnet/pull/18725 |
||
{ | ||
CheckConnection(RunnerConnectionType.Generic); | ||
return _genericTaskAgentClient.UpdateAgentUpdateStateAsync(agentPoolId, agentId, currentState, trace); | ||
return _genericTaskAgentClient.RefreshRunnerConfigAsync(agentId, configType, encodedRunnerConfig, cancellationToken: cancellationToken); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -635,6 +635,17 @@ ex is TaskOrchestrationJobAlreadyAcquiredException || // HTTP status 409 | |
Trace.Info("Received ForceTokenRefreshMessage"); | ||
await _listener.RefreshListenerTokenAsync(messageQueueLoopTokenSource.Token); | ||
} | ||
else if (string.Equals(message.MessageType, RunnerRefreshConfigMessage.MessageType)) | ||
{ | ||
var runnerRefreshConfigMessage = JsonUtility.FromString<RunnerRefreshConfigMessage>(message.Body); | ||
Trace.Info($"Received RunnerRefreshConfigMessage for '{runnerRefreshConfigMessage.ConfigType}' config file"); | ||
var configUpdater = HostContext.GetService<IRunnerConfigUpdater>(); | ||
await configUpdater.UpdateRunnerConfigAsync( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
runnerQualifiedId: runnerRefreshConfigMessage.RunnerQualifiedId, | ||
configType: runnerRefreshConfigMessage.ConfigType, | ||
serviceType: runnerRefreshConfigMessage.ServiceType, | ||
configRefreshUrl: runnerRefreshConfigMessage.ConfigRefreshUrl); | ||
} | ||
else | ||
{ | ||
Trace.Error($"Received message {message.MessageId} with unsupported message type {message.MessageType}."); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is basic add things back from https://github.com/actions/runner/pull/513/files#diff-8ef9a7b7967d070375a6e4773f2bbeb1ae60e986bff48a4171256ae1b3869872
and introduce migrated config file (.runner) in addition to the migrated credentials file (.credentials).