Skip to content
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

Change RunnerId/AgentId from int32 to uint64 #2661

Merged
merged 2 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Runner.Common/ConfigurationStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public sealed class RunnerSettings
private bool? _isHostedServer;

[DataMember(EmitDefaultValue = false)]
public int AgentId { get; set; }
public ulong AgentId { get; set; }

[DataMember(EmitDefaultValue = false)]
public string AgentName { get; set; }
Expand Down
12 changes: 6 additions & 6 deletions src/Runner.Common/RunnerServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public interface IRunnerServer : IRunnerService

// Configuration
Task<TaskAgent> AddAgentAsync(Int32 agentPoolId, TaskAgent agent);
Task DeleteAgentAsync(int agentPoolId, int agentId);
Task DeleteAgentAsync(int agentId);
Task DeleteAgentAsync(int agentPoolId, ulong agentId);
Task DeleteAgentAsync(ulong agentId);
Task<List<TaskAgentPool>> GetAgentPoolsAsync(string agentPoolName = null, TaskAgentPoolType poolType = TaskAgentPoolType.Automation);
Task<List<TaskAgent>> GetAgentsAsync(int agentPoolId, string agentName = null);
Task<List<TaskAgent>> GetAgentsAsync(string agentName);
Expand All @@ -50,7 +50,7 @@ public interface IRunnerServer : IRunnerService
Task<PackageMetadata> GetPackageAsync(string packageType, string platform, string version, bool includeToken, CancellationToken cancellationToken);

// agent update
Task<TaskAgent> UpdateAgentUpdateStateAsync(int agentPoolId, int agentId, string currentState, string trace);
Task<TaskAgent> UpdateAgentUpdateStateAsync(int agentPoolId, ulong agentId, string currentState, string trace);
}

public sealed class RunnerServer : RunnerService, IRunnerServer
Expand Down Expand Up @@ -239,13 +239,13 @@ public Task<TaskAgent> ReplaceAgentAsync(int agentPoolId, TaskAgent agent)
return _genericTaskAgentClient.ReplaceAgentAsync(agentPoolId, agent);
}

public Task DeleteAgentAsync(int agentPoolId, int agentId)
public Task DeleteAgentAsync(int agentPoolId, ulong agentId)
{
CheckConnection(RunnerConnectionType.Generic);
return _genericTaskAgentClient.DeleteAgentAsync(agentPoolId, agentId);
}

public Task DeleteAgentAsync(int agentId)
public Task DeleteAgentAsync(ulong agentId)
{
return DeleteAgentAsync(0, agentId); // agentPool is ignored server side
}
Expand Down Expand Up @@ -315,7 +315,7 @@ public Task<PackageMetadata> GetPackageAsync(string packageType, string platform
return _genericTaskAgentClient.GetPackageAsync(packageType, platform, version, includeToken, cancellationToken: cancellationToken);
}

public Task<TaskAgent> UpdateAgentUpdateStateAsync(int agentPoolId, int agentId, string currentState, string trace)
public Task<TaskAgent> UpdateAgentUpdateStateAsync(int agentPoolId, ulong agentId, string currentState, string trace)
{
CheckConnection(RunnerConnectionType.Generic);
return _genericTaskAgentClient.UpdateAgentUpdateStateAsync(agentPoolId, agentId, currentState, trace);
Expand Down
2 changes: 1 addition & 1 deletion src/Runner.Listener/SelfUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class SelfUpdater : RunnerService, ISelfUpdater
private ITerminal _terminal;
private IRunnerServer _runnerServer;
private int _poolId;
private int _agentId;
private ulong _agentId;
private readonly ConcurrentQueue<string> _updateTrace = new();
private Task _cloneAndCalculateContentHashTask;
private string _dotnetRuntimeCloneDirectory;
Expand Down
2 changes: 1 addition & 1 deletion src/Runner.Worker/DiagnosticLogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void UploadDiagnosticLogs(IExecutionContext executionContext,
// \_layout\_work\_temp\[jobname-support]\files\environment.txt
var configurationStore = HostContext.GetService<IConfigurationStore>();
RunnerSettings settings = configurationStore.GetSettings();
int runnerId = settings.AgentId;
ulong runnerId = settings.AgentId;
string runnerName = settings.AgentName;
int poolId = settings.PoolId;

Expand Down
6 changes: 3 additions & 3 deletions src/Sdk/DTGenerated/Generated/TaskAgentHttpClientBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public virtual Task<TaskAgent> AddAgentAsync(
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
public virtual async Task DeleteAgentAsync(
int poolId,
int agentId,
ulong agentId,
object userState = null,
CancellationToken cancellationToken = default)
{
Expand Down Expand Up @@ -243,7 +243,7 @@ public virtual Task<List<TaskAgent>> GetAgentsAsync(
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
public virtual Task<TaskAgent> ReplaceAgentAsync(
int poolId,
int agentId,
ulong agentId,
TaskAgent agent,
object userState = null,
CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -786,7 +786,7 @@ public virtual async Task DeleteAgentSessionAsync(
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual Task<TaskAgent> UpdateAgentUpdateStateAsync(
int poolId,
int agentId,
ulong agentId,
string currentState,
string updateTrace,
object userState = null,
Expand Down
4 changes: 2 additions & 2 deletions src/Sdk/DTWebApi/WebApi/AgentRefreshMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal AgentRefreshMessage()
}

public AgentRefreshMessage(
Int32 agentId,
ulong agentId,
String targetVersion,
TimeSpan? timeout = null)
{
Expand All @@ -26,7 +26,7 @@ public AgentRefreshMessage(
}

[DataMember]
public Int32 AgentId
public ulong AgentId
{
get;
private set;
Expand Down
4 changes: 2 additions & 2 deletions src/Sdk/DTWebApi/WebApi/DiagnosticLogMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace GitHub.DistributedTask.WebApi
[DataContract]
public sealed class DiagnosticLogMetadata
{
public DiagnosticLogMetadata(string agentName, int agentId, int poolId, string phaseName, string fileName, string phaseResult)
public DiagnosticLogMetadata(string agentName, ulong agentId, int poolId, string phaseName, string fileName, string phaseResult)
{
AgentName = agentName;
AgentId = agentId;
Expand All @@ -19,7 +19,7 @@ public DiagnosticLogMetadata(string agentName, int agentId, int poolId, string p
public string AgentName { get; set; }

[DataMember]
public int AgentId { get; set; }
public ulong AgentId { get; set; }

[DataMember]
public int PoolId { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/Sdk/DTWebApi/WebApi/Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public string Name
}

[JsonProperty("id")]
public Int32 Id
public ulong Id
{
get;
internal set;
Expand Down
4 changes: 2 additions & 2 deletions src/Sdk/DTWebApi/WebApi/RunnerRefreshMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal RunnerRefreshMessage()
}

public RunnerRefreshMessage(
Int32 runnerId,
ulong runnerId,
String targetVersion,
int? timeoutInSeconds = null)
{
Expand All @@ -26,7 +26,7 @@ public RunnerRefreshMessage(
}

[DataMember]
public Int32 RunnerId
public ulong RunnerId
{
get;
private set;
Expand Down
2 changes: 1 addition & 1 deletion src/Sdk/DTWebApi/WebApi/TaskAgentReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected TaskAgentReference(TaskAgentReference referenceToBeCloned)
/// Identifier of the agent.
/// </summary>
[DataMember]
public Int32 Id
public ulong Id
{
get;
set;
Expand Down
5 changes: 5 additions & 0 deletions src/Sdk/WebApi/WebApi/BrokerHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ public async Task<TaskAgentMessage> GetRunnerMessageAsync(
return result.Value;
}

if (result.StatusCode == HttpStatusCode.Forbidden)
{
throw new AccessDeniedException(result.Error);
}

throw new Exception($"Failed to get job message: {result.Error}");
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/Test/L0/Listener/SelfUpdaterL0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public async void TestSelfUpdateAsync()
updater.Initialize(hc);

_runnerServer.Setup(x => x.UpdateAgentUpdateStateAsync(1, 1, It.IsAny<string>(), It.IsAny<string>()))
.Callback((int p, int a, string s, string t) =>
.Callback((int p, ulong a, string s, string t) =>
{
hc.GetTrace().Info(t);
})
Expand Down Expand Up @@ -180,7 +180,7 @@ public async void TestSelfUpdateAsync_NoUpdateOnOldVersion()
.Returns(Task.FromResult(new PackageMetadata() { Platform = BuildConstants.RunnerPackage.PackageName, Version = new PackageVersion("2.200.0"), DownloadUrl = _packageUrl }));

_runnerServer.Setup(x => x.UpdateAgentUpdateStateAsync(1, 1, It.IsAny<string>(), It.IsAny<string>()))
.Callback((int p, int a, string s, string t) =>
.Callback((int p, ulong a, string s, string t) =>
{
hc.GetTrace().Info(t);
})
Expand Down Expand Up @@ -234,7 +234,7 @@ public async void TestSelfUpdateAsync_DownloadRetry()
updater.Initialize(hc);

_runnerServer.Setup(x => x.UpdateAgentUpdateStateAsync(1, 1, It.IsAny<string>(), It.IsAny<string>()))
.Callback((int p, int a, string s, string t) =>
.Callback((int p, ulong a, string s, string t) =>
{
hc.GetTrace().Info(t);
})
Expand Down Expand Up @@ -289,7 +289,7 @@ public async void TestSelfUpdateAsync_ValidateHash()
updater.Initialize(hc);

_runnerServer.Setup(x => x.UpdateAgentUpdateStateAsync(1, 1, It.IsAny<string>(), It.IsAny<string>()))
.Callback((int p, int a, string s, string t) =>
.Callback((int p, ulong a, string s, string t) =>
{
hc.GetTrace().Info(t);
})
Expand Down Expand Up @@ -344,7 +344,7 @@ public async void TestSelfUpdateAsync_CloneHash_RuntimeAndExternals()
.Returns(Task.FromResult(new PackageMetadata() { Platform = BuildConstants.RunnerPackage.PackageName, Version = new PackageVersion("2.999.0"), DownloadUrl = _packageUrl, TrimmedPackages = new List<TrimmedPackageMetadata>() { new TrimmedPackageMetadata() } }));

_runnerServer.Setup(x => x.UpdateAgentUpdateStateAsync(1, 1, It.IsAny<string>(), It.IsAny<string>()))
.Callback((int p, int a, string s, string t) =>
.Callback((int p, ulong a, string s, string t) =>
{
hc.GetTrace().Info(t);
})
Expand Down Expand Up @@ -416,7 +416,7 @@ public async void TestSelfUpdateAsync_Cancel_CloneHashTask_WhenNotNeeded()
updater.Initialize(hc);

_runnerServer.Setup(x => x.UpdateAgentUpdateStateAsync(1, 1, It.IsAny<string>(), It.IsAny<string>()))
.Callback((int p, int a, string s, string t) =>
.Callback((int p, ulong a, string s, string t) =>
{
hc.GetTrace().Info(t);
})
Expand Down Expand Up @@ -490,7 +490,7 @@ public async void TestSelfUpdateAsync_UseExternalsTrimmedPackage()
.Returns(Task.FromResult(new PackageMetadata() { Platform = BuildConstants.RunnerPackage.PackageName, Version = new PackageVersion("2.999.0"), DownloadUrl = _packageUrl, TrimmedPackages = trim }));

_runnerServer.Setup(x => x.UpdateAgentUpdateStateAsync(1, 1, It.IsAny<string>(), It.IsAny<string>()))
.Callback((int p, int a, string s, string t) =>
.Callback((int p, ulong a, string s, string t) =>
{
hc.GetTrace().Info(t);
})
Expand Down Expand Up @@ -579,7 +579,7 @@ public async void TestSelfUpdateAsync_UseExternalsRuntimeTrimmedPackage()
.Returns(Task.FromResult(new PackageMetadata() { Platform = BuildConstants.RunnerPackage.PackageName, Version = new PackageVersion("2.999.0"), DownloadUrl = _packageUrl, TrimmedPackages = trim }));

_runnerServer.Setup(x => x.UpdateAgentUpdateStateAsync(1, 1, It.IsAny<string>(), It.IsAny<string>()))
.Callback((int p, int a, string s, string t) =>
.Callback((int p, ulong a, string s, string t) =>
{
hc.GetTrace().Info(t);
})
Expand Down Expand Up @@ -681,7 +681,7 @@ public async void TestSelfUpdateAsync_NotUseExternalsRuntimeTrimmedPackageOnHash


_runnerServer.Setup(x => x.UpdateAgentUpdateStateAsync(1, 1, It.IsAny<string>(), It.IsAny<string>()))
.Callback((int p, int a, string s, string t) =>
.Callback((int p, ulong a, string s, string t) =>
{
hc.GetTrace().Info(t);
})
Expand Down Expand Up @@ -758,7 +758,7 @@ public async void TestSelfUpdateAsync_FallbackToFullPackage()
.Returns(Task.FromResult(new PackageMetadata() { Platform = BuildConstants.RunnerPackage.PackageName, Version = new PackageVersion("2.999.0"), DownloadUrl = _packageUrl, TrimmedPackages = trim }));

_runnerServer.Setup(x => x.UpdateAgentUpdateStateAsync(1, 1, It.IsAny<string>(), It.IsAny<string>()))
.Callback((int p, int a, string s, string t) =>
.Callback((int p, ulong a, string s, string t) =>
{
hc.GetTrace().Info(t);
})
Expand Down