From 3a5ab37153670825b1de3ab2b4dd6689b0c8480e Mon Sep 17 00:00:00 2001 From: eric sciple Date: Tue, 11 May 2021 09:19:23 -0500 Subject: [PATCH] Handle job not found when ensuring previous dispatch finished (#1083) --- src/Runner.Listener/JobDispatcher.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Runner.Listener/JobDispatcher.cs b/src/Runner.Listener/JobDispatcher.cs index 45f509e85..f019032ab 100644 --- a/src/Runner.Listener/JobDispatcher.cs +++ b/src/Runner.Listener/JobDispatcher.cs @@ -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.