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

Exit on deprication error #2299

Merged
merged 9 commits into from
Mar 7, 2023
8 changes: 6 additions & 2 deletions src/Runner.Listener/MessageListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public void OnJobStatus(object sender, JobStatusEventArgs e)
try
{
_getMessagesTokenSource?.Cancel();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

';.;;''

}
catch (ObjectDisposedException)
{
Trace.Info("_getMessagesTokenSource is already disposed.");
Expand Down Expand Up @@ -245,6 +245,10 @@ public async Task<TaskAgentMessage> GetNextMessageAsync(CancellationToken token)
_accessTokenRevoked = true;
throw;
}
catch (AccessDeniedException e) when (e.InnerException is InvalidTaskAgentVersionException)
{
throw;
}
catch (Exception ex)
{
Trace.Error("Catch exception during get next message.");
Expand Down Expand Up @@ -289,7 +293,7 @@ public async Task<TaskAgentMessage> GetNextMessageAsync(CancellationToken token)
await HostContext.Delay(_getNextMessageRetryInterval, token);
}
}
finally
finally
{
_getMessagesTokenSource.Dispose();
}
Expand Down
11 changes: 9 additions & 2 deletions src/Runner.Listener/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using GitHub.DistributedTask.WebApi;

namespace GitHub.Runner.Listener
{
Expand Down Expand Up @@ -58,7 +59,7 @@ private async static Task<int> MainAsync(IHostContext context, string[] args)
terminal.WriteLine("This runner version is built for Windows. Please install a correct build for your OS.");
return Constants.Runner.ReturnCode.TerminatedError;
}
#if ARM64
#if ARM64
// A little hacky, but windows gives no way to differentiate between windows 10 and 11.
// By default only 11 supports native x64 app emulation on arm, so we only want to support windows 11
// https://docs.microsoft.com/en-us/windows/arm/overview#build-windows-apps-that-run-on-arm
Expand All @@ -69,7 +70,7 @@ private async static Task<int> MainAsync(IHostContext context, string[] args)
terminal.WriteLine("Win-arm64 runners require windows 11 or later. Please upgrade your operating system.");
return Constants.Runner.ReturnCode.TerminatedError;
}
#endif
#endif
break;
default:
terminal.WriteLine($"Running the runner on this platform is not supported. The current platform is {RuntimeInformation.OSDescription} and it was built for {Constants.Runner.Platform.ToString()}.");
Expand Down Expand Up @@ -137,6 +138,12 @@ private async static Task<int> MainAsync(IHostContext context, string[] args)
}

}
catch (AccessDeniedException e) when (e.InnerException is InvalidTaskAgentVersionException)
{
terminal.WriteError($"An error occured: {e.Message}");
trace.Error(e);
return Constants.Runner.ReturnCode.TerminatedError;
}
catch (Exception e)
{
terminal.WriteError($"An error occurred: {e.Message}");
Expand Down