Handle job not found when ensuring previous dispatch finished (#1083)

This commit is contained in:
eric sciple
2021-05-11 09:19:23 -05:00
committed by GitHub
parent 419ed24c1e
commit 3a5ab37153

View File

@@ -240,6 +240,15 @@ namespace GitHub.Runner.Listener
{
request = await runnerServer.GetAgentRequestAsync(_poolId, jobDispatch.RequestId, CancellationToken.None);
}
catch (TaskAgentJobNotFoundException ex)
{
Trace.Error($"Catch job-not-found exception while checking jobrequest {jobDispatch.JobId} status. Cancel running worker right away.");
Trace.Error(ex);
jobDispatch.WorkerCancellationTokenSource.Cancel();
// make sure worker process exit before we return, otherwise we might leave orphan worker process behind.
await jobDispatch.WorkerDispatch;
return;
}
catch (Exception ex)
{
// we can't even query for the jobrequest from server, something totally busted, stop runner/worker.