mirror of
https://github.com/actions/runner.git
synced 2025-12-10 12:36:23 +00:00
Exit hosted runner cleanly during deprovisioning. (#3755)
This commit is contained in:
@@ -93,7 +93,7 @@ namespace GitHub.Runner.Common
|
||||
|
||||
public bool ShouldRetryException(Exception ex)
|
||||
{
|
||||
if (ex is AccessDeniedException || ex is RunnerNotFoundException)
|
||||
if (ex is AccessDeniedException || ex is RunnerNotFoundException || ex is HostedRunnerDeprovisionedException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -249,6 +249,11 @@ namespace GitHub.Runner.Listener
|
||||
Trace.Info("Runner OAuth token has been revoked. Unable to pull message.");
|
||||
throw;
|
||||
}
|
||||
catch (HostedRunnerDeprovisionedException)
|
||||
{
|
||||
Trace.Info("Hosted runner has been deprovisioned.");
|
||||
throw;
|
||||
}
|
||||
catch (AccessDeniedException e) when (e.ErrorCode == 1)
|
||||
{
|
||||
throw;
|
||||
|
||||
@@ -304,6 +304,11 @@ namespace GitHub.Runner.Listener
|
||||
_accessTokenRevoked = true;
|
||||
throw;
|
||||
}
|
||||
catch (HostedRunnerDeprovisionedException)
|
||||
{
|
||||
Trace.Info("Hosted runner has been deprovisioned.");
|
||||
throw;
|
||||
}
|
||||
catch (AccessDeniedException e) when (e.ErrorCode == 1)
|
||||
{
|
||||
throw;
|
||||
|
||||
@@ -697,6 +697,10 @@ namespace GitHub.Runner.Listener
|
||||
{
|
||||
Trace.Info("Runner OAuth token has been revoked. Shutting down.");
|
||||
}
|
||||
catch (HostedRunnerDeprovisionedException)
|
||||
{
|
||||
Trace.Info("Hosted runner has been deprovisioned. Shutting down.");
|
||||
}
|
||||
|
||||
return Constants.Runner.ReturnCode.Success;
|
||||
}
|
||||
|
||||
@@ -7,5 +7,6 @@ namespace GitHub.Actions.RunService.WebApi
|
||||
{
|
||||
public const string RunnerNotFound = "RunnerNotFound";
|
||||
public const string RunnerVersionTooOld = "RunnerVersionTooOld";
|
||||
public const string HostedRunnerDeprovisioned = "HostedRunnerDeprovisioned";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,8 @@ namespace GitHub.Actions.RunService.WebApi
|
||||
{
|
||||
ErrorCode = 1
|
||||
};
|
||||
case BrokerErrorKind.HostedRunnerDeprovisioned:
|
||||
throw new HostedRunnerDeprovisionedException(brokerError.Message);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
|
||||
namespace GitHub.Services.WebApi
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class HostedRunnerDeprovisionedException : Exception
|
||||
{
|
||||
public HostedRunnerDeprovisionedException()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public HostedRunnerDeprovisionedException(String message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public HostedRunnerDeprovisionedException(String message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user