mirror of
https://github.com/actions/runner.git
synced 2025-12-10 04:06:57 +00:00
Handle runner not found (#3536)
This commit is contained in:
@@ -7,6 +7,7 @@ using GitHub.DistributedTask.Pipelines;
|
||||
using GitHub.DistributedTask.WebApi;
|
||||
using GitHub.Runner.Sdk;
|
||||
using GitHub.Services.Common;
|
||||
using GitHub.Services.WebApi;
|
||||
using Sdk.RSWebApi.Contracts;
|
||||
using Sdk.WebApi.WebApi.RawClient;
|
||||
|
||||
@@ -92,7 +93,7 @@ namespace GitHub.Runner.Common
|
||||
|
||||
public bool ShouldRetryException(Exception ex)
|
||||
{
|
||||
if (ex is AccessDeniedException ade)
|
||||
if (ex is AccessDeniedException || ex is RunnerNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -11,9 +11,10 @@ using GitHub.DistributedTask.WebApi;
|
||||
using GitHub.Runner.Common;
|
||||
using GitHub.Runner.Listener.Configuration;
|
||||
using GitHub.Runner.Sdk;
|
||||
using GitHub.Services.Common;
|
||||
using GitHub.Runner.Common.Util;
|
||||
using GitHub.Services.Common;
|
||||
using GitHub.Services.OAuth;
|
||||
using GitHub.Services.WebApi;
|
||||
|
||||
namespace GitHub.Runner.Listener
|
||||
{
|
||||
@@ -241,6 +242,10 @@ namespace GitHub.Runner.Listener
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (RunnerNotFoundException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.Error("Catch exception during get next message.");
|
||||
@@ -324,6 +329,7 @@ namespace GitHub.Runner.Listener
|
||||
ex is TaskAgentPoolNotFoundException ||
|
||||
ex is TaskAgentSessionExpiredException ||
|
||||
ex is AccessDeniedException ||
|
||||
ex is RunnerNotFoundException ||
|
||||
ex is VssUnauthorizedException)
|
||||
{
|
||||
Trace.Info($"Non-retriable exception: {ex.Message}");
|
||||
|
||||
@@ -308,6 +308,10 @@ namespace GitHub.Runner.Listener
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (RunnerNotFoundException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Trace.Error("Catch exception during get next message.");
|
||||
@@ -457,6 +461,7 @@ namespace GitHub.Runner.Listener
|
||||
ex is TaskAgentPoolNotFoundException ||
|
||||
ex is TaskAgentSessionExpiredException ||
|
||||
ex is AccessDeniedException ||
|
||||
ex is RunnerNotFoundException ||
|
||||
ex is VssUnauthorizedException)
|
||||
{
|
||||
Trace.Info($"Non-retriable exception: {ex.Message}");
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using GitHub.DistributedTask.WebApi;
|
||||
using GitHub.Services.WebApi;
|
||||
|
||||
namespace GitHub.Runner.Listener
|
||||
{
|
||||
@@ -144,6 +145,12 @@ namespace GitHub.Runner.Listener
|
||||
trace.Error(e);
|
||||
return Constants.Runner.ReturnCode.TerminatedError;
|
||||
}
|
||||
catch (RunnerNotFoundException e)
|
||||
{
|
||||
terminal.WriteError($"An error occurred: {e.Message}");
|
||||
trace.Error(e);
|
||||
return Constants.Runner.ReturnCode.TerminatedError;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
terminal.WriteError($"An error occurred: {e.Message}");
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace GitHub.Actions.RunService.WebApi
|
||||
[DataContract]
|
||||
public class BrokerErrorKind
|
||||
{
|
||||
public const string RunnerNotFound = "RunnerNotFound";
|
||||
public const string RunnerVersionTooOld = "RunnerVersionTooOld";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,8 @@ namespace GitHub.Actions.RunService.WebApi
|
||||
{
|
||||
switch (brokerError.ErrorKind)
|
||||
{
|
||||
case BrokerErrorKind.RunnerNotFound:
|
||||
throw new RunnerNotFoundException(brokerError.Message);
|
||||
case BrokerErrorKind.RunnerVersionTooOld:
|
||||
throw new AccessDeniedException(brokerError.Message)
|
||||
{
|
||||
|
||||
26
src/Sdk/WebApi/WebApi/Exceptions/RunnerNotFoundException.cs
Normal file
26
src/Sdk/WebApi/WebApi/Exceptions/RunnerNotFoundException.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using GitHub.Services.Common;
|
||||
using GitHub.Services.WebApi;
|
||||
|
||||
namespace GitHub.Services.WebApi
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class RunnerNotFoundException : Exception
|
||||
{
|
||||
public RunnerNotFoundException()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public RunnerNotFoundException(String message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public RunnerNotFoundException(String message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user