@@ -84,19 +84,23 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
8484 // check for culling interval
8585 if ( DateTime . UtcNow - crudeTimer > TimeSpan . FromMinutes ( cullMinutes ) )
8686 {
87-
8887 _logger . LogInformation ( "Cleaning runners..." ) ;
8988
89+ var checkInId = SentrySdk . CaptureCheckIn ( "CheckForStuckRunners" , CheckInStatus . InProgress ) ;
9090 try
9191 {
9292 await CheckForStuckRunners ( targetConfig ) ;
93+ SentrySdk . CaptureCheckIn ( "CheckForStuckRunners" , CheckInStatus . Ok , checkInId ) ;
9394 }
9495 catch ( Exception ex )
9596 {
9697 _logger . LogError ( $ "Unable to check for stuck runners: { ex . GetFullExceptionDetails ( ) } ") ;
98+ SentrySdk . CaptureCheckIn ( "CheckForStuckRunners" , CheckInStatus . Error , checkInId ) ;
99+ SentrySdk . CaptureException ( ex ) ;
97100 }
98101
99102 await CleanUpRunners ( targetConfig ) ;
103+
100104 await StartPoolRunners ( targetConfig ) ;
101105 await CheckForStuckJobs ( targetConfig ) ;
102106
@@ -577,6 +581,11 @@ private async Task CleanUpRunners(List<GithubTargetConfiguration> targetConfigs)
577581 List < CspServer > remainingServers = await cc . GetAllServersFromCsp ( ) ;
578582 foreach ( CspServer cspServer in remainingServers )
579583 {
584+
585+ SentrySdk . AddBreadcrumb ( "Checking server for removal." , category : "Cleanup" , data : new Dictionary < string , string >
586+ {
587+ { "server" , cspServer . Name }
588+ } ) ;
580589 if ( registeredServerNames . Contains ( cspServer . Name ) )
581590 {
582591 // If we know the server in github, skip
@@ -593,13 +602,23 @@ private async Task CleanUpRunners(List<GithubTargetConfiguration> targetConfigs)
593602 var cspRunnerDb = await db . Runners . Include ( x => x . Job ) . FirstOrDefaultAsync ( x => x . Hostname == cspServer . Name ) ;
594603 if ( cspRunnerDb != null )
595604 {
596- // query github for job
597- var runnerToken = Program . Config . TargetConfigs . FirstOrDefault ( x => x . Name == cspRunnerDb . Job . Owner ) . GitHubToken ;
598- var githubJob = await GitHubApi . GetJobInfoForOrg ( cspRunnerDb . Job . GithubJobId , cspRunnerDb . Job . Repository , runnerToken ) ;
599- if ( githubJob is { Status : "running" } )
605+ try
600606 {
601- _logger . LogWarning ( $ "Got a runner ({ cspServer . Name } ) not in GitHub anymore but still processing. Indicates a >24h job.") ;
602- continue ;
607+ // query github for job
608+ var runnerToken = Program . Config . TargetConfigs . FirstOrDefault ( x => x . Name == cspRunnerDb . Job . Owner ) . GitHubToken ;
609+ var githubJob = await GitHubApi . GetJobInfoForOrg ( cspRunnerDb . Job . GithubJobId , cspRunnerDb . Job . Repository , runnerToken ) ;
610+ if ( githubJob is { Status : "running" } )
611+ {
612+ _logger . LogWarning ( $ "Got a runner ({ cspServer . Name } ) not in GitHub anymore but still processing. Indicates a >24h job.") ;
613+ continue ;
614+ }
615+ }
616+ catch ( Exception ex )
617+ {
618+ SentrySdk . CaptureException ( ex , scope =>
619+ {
620+ scope . Level = SentryLevel . Warning ;
621+ } ) ;
603622 }
604623
605624 }
0 commit comments