Skip to content

Commit 17bdb56

Browse files
TingluoHuangAdamOlech
authored andcommitted
Change RunnerId/AgentId from int32 to uint64 (actions#2661)
* RunnerId int -> ulong
1 parent dce86ab commit 17bdb56

File tree

11 files changed

+29
-18
lines changed

11 files changed

+29
-18
lines changed

src/Runner.Common/ConfigurationStore.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public sealed class RunnerSettings
2020
private bool? _isHostedServer;
2121

2222
[DataMember(EmitDefaultValue = false)]
23-
public int AgentId { get; set; }
23+
public ulong AgentId { get; set; }
2424

2525
[DataMember(EmitDefaultValue = false)]
2626
public string AgentName { get; set; }

src/Runner.Common/RunnerServer.cs

+10-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public interface IRunnerServer : IRunnerService
2727

2828
// Configuration
2929
Task<TaskAgent> AddAgentAsync(Int32 agentPoolId, TaskAgent agent);
30-
Task DeleteAgentAsync(int agentPoolId, int agentId);
30+
Task DeleteAgentAsync(int agentPoolId, ulong agentId);
31+
Task DeleteAgentAsync(ulong agentId);
3132
Task<List<TaskAgentPool>> GetAgentPoolsAsync(string agentPoolName = null, TaskAgentPoolType poolType = TaskAgentPoolType.Automation);
3233
Task<List<TaskAgent>> GetAgentsAsync(int agentPoolId, string agentName = null);
3334
Task<TaskAgent> ReplaceAgentAsync(int agentPoolId, TaskAgent agent);
@@ -48,7 +49,7 @@ public interface IRunnerServer : IRunnerService
4849
Task<PackageMetadata> GetPackageAsync(string packageType, string platform, string version, CancellationToken cancellationToken);
4950

5051
// agent update
51-
Task<TaskAgent> UpdateAgentUpdateStateAsync(int agentPoolId, int agentId, string currentState);
52+
Task<TaskAgent> UpdateAgentUpdateStateAsync(int agentPoolId, ulong agentId, string currentState);
5253
}
5354

5455
public sealed class RunnerServer : RunnerService, IRunnerServer
@@ -232,12 +233,17 @@ public Task<TaskAgent> ReplaceAgentAsync(int agentPoolId, TaskAgent agent)
232233
return _genericTaskAgentClient.ReplaceAgentAsync(agentPoolId, agent);
233234
}
234235

235-
public Task DeleteAgentAsync(int agentPoolId, int agentId)
236+
public Task DeleteAgentAsync(int agentPoolId, ulong agentId)
236237
{
237238
CheckConnection(RunnerConnectionType.Generic);
238239
return _genericTaskAgentClient.DeleteAgentAsync(agentPoolId, agentId);
239240
}
240241

242+
public Task DeleteAgentAsync(ulong agentId)
243+
{
244+
return DeleteAgentAsync(0, agentId); // agentPool is ignored server side
245+
}
246+
241247
//-----------------------------------------------------------------
242248
// MessageQueue
243249
//-----------------------------------------------------------------
@@ -303,7 +309,7 @@ public Task<PackageMetadata> GetPackageAsync(string packageType, string platform
303309
return _genericTaskAgentClient.GetPackageAsync(packageType, platform, version, cancellationToken: cancellationToken);
304310
}
305311

306-
public Task<TaskAgent> UpdateAgentUpdateStateAsync(int agentPoolId, int agentId, string currentState)
312+
public Task<TaskAgent> UpdateAgentUpdateStateAsync(int agentPoolId, ulong agentId, string currentState)
307313
{
308314
CheckConnection(RunnerConnectionType.Generic);
309315
return _genericTaskAgentClient.UpdateAgentUpdateStateAsync(agentPoolId, agentId, currentState);

src/Runner.Listener/SelfUpdater.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class SelfUpdater : RunnerService, ISelfUpdater
3030
private ITerminal _terminal;
3131
private IRunnerServer _runnerServer;
3232
private int _poolId;
33-
private int _agentId;
33+
private ulong _agentId;
3434

3535
public bool Busy { get; private set; }
3636

src/Runner.Worker/DiagnosticLogManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void UploadDiagnosticLogs(IExecutionContext executionContext,
5656
// \_layout\_work\_temp\[jobname-support]\files\environment.txt
5757
var configurationStore = HostContext.GetService<IConfigurationStore>();
5858
RunnerSettings settings = configurationStore.GetSettings();
59-
int runnerId = settings.AgentId;
59+
ulong runnerId = settings.AgentId;
6060
string runnerName = settings.AgentName;
6161
int poolId = settings.PoolId;
6262

src/Sdk/DTGenerated/Generated/TaskAgentHttpClientBase.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public virtual Task<TaskAgent> AddAgentAsync(
9797
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
9898
public virtual async Task DeleteAgentAsync(
9999
int poolId,
100-
int agentId,
100+
ulong agentId,
101101
object userState = null,
102102
CancellationToken cancellationToken = default)
103103
{
@@ -243,7 +243,7 @@ public virtual Task<List<TaskAgent>> GetAgentsAsync(
243243
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
244244
public virtual Task<TaskAgent> ReplaceAgentAsync(
245245
int poolId,
246-
int agentId,
246+
ulong agentId,
247247
TaskAgent agent,
248248
object userState = null,
249249
CancellationToken cancellationToken = default)
@@ -788,7 +788,7 @@ public virtual async Task DeleteAgentSessionAsync(
788788
[EditorBrowsable(EditorBrowsableState.Never)]
789789
public virtual Task<TaskAgent> UpdateAgentUpdateStateAsync(
790790
int poolId,
791-
int agentId,
791+
ulong agentId,
792792
string currentState,
793793
object userState = null,
794794
CancellationToken cancellationToken = default)

src/Sdk/DTWebApi/WebApi/AgentRefreshMessage.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ internal AgentRefreshMessage()
1616
}
1717

1818
public AgentRefreshMessage(
19-
Int32 agentId,
19+
ulong agentId,
2020
String targetVersion,
2121
TimeSpan? timeout = null)
2222
{
@@ -26,7 +26,7 @@ public AgentRefreshMessage(
2626
}
2727

2828
[DataMember]
29-
public Int32 AgentId
29+
public ulong AgentId
3030
{
3131
get;
3232
private set;

src/Sdk/DTWebApi/WebApi/DiagnosticLogMetadata.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace GitHub.DistributedTask.WebApi
55
[DataContract]
66
public sealed class DiagnosticLogMetadata
77
{
8-
public DiagnosticLogMetadata(string agentName, int agentId, int poolId, string phaseName, string fileName, string phaseResult)
8+
public DiagnosticLogMetadata(string agentName, ulong agentId, int poolId, string phaseName, string fileName, string phaseResult)
99
{
1010
AgentName = agentName;
1111
AgentId = agentId;
@@ -19,7 +19,7 @@ public DiagnosticLogMetadata(string agentName, int agentId, int poolId, string p
1919
public string AgentName { get; set; }
2020

2121
[DataMember]
22-
public int AgentId { get; set; }
22+
public ulong AgentId { get; set; }
2323

2424
[DataMember]
2525
public int PoolId { get; set; }

src/Sdk/DTWebApi/WebApi/Runner.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public string Name
4747
}
4848

4949
[JsonProperty("id")]
50-
public Int32 Id
50+
public ulong Id
5151
{
5252
get;
5353
internal set;

src/Sdk/DTWebApi/WebApi/RunnerRefreshMessage.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ internal RunnerRefreshMessage()
1616
}
1717

1818
public RunnerRefreshMessage(
19-
Int32 runnerId,
19+
ulong runnerId,
2020
String targetVersion,
2121
int? timeoutInSeconds = null)
2222
{
@@ -26,7 +26,7 @@ public RunnerRefreshMessage(
2626
}
2727

2828
[DataMember]
29-
public Int32 RunnerId
29+
public ulong RunnerId
3030
{
3131
get;
3232
private set;

src/Sdk/DTWebApi/WebApi/TaskAgentReference.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected TaskAgentReference(TaskAgentReference referenceToBeCloned)
3636
/// Identifier of the agent.
3737
/// </summary>
3838
[DataMember]
39-
public Int32 Id
39+
public ulong Id
4040
{
4141
get;
4242
set;

src/Sdk/WebApi/WebApi/BrokerHttpClient.cs

+5
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ public async Task<TaskAgentMessage> GetRunnerMessageAsync(
110110
return result.Value;
111111
}
112112

113+
if (result.StatusCode == HttpStatusCode.Forbidden)
114+
{
115+
throw new AccessDeniedException(result.Error);
116+
}
117+
113118
throw new Exception($"Failed to get job message: {result.Error}");
114119
}
115120

0 commit comments

Comments
 (0)