@@ -293,28 +293,10 @@ func (r *EphemeralRunnerReconciler) Reconcile(ctx context.Context, req ctrl.Requ
293
293
}
294
294
return ctrl.Result {}, nil
295
295
296
- default :
297
- // pod succeeded. We double-check with the service if the runner exists.
298
- // The reason is that image can potentially finish with status 0, but not pick up the job.
299
- existsInService , err := r .runnerRegisteredWithService (ctx , ephemeralRunner .DeepCopy (), log )
300
- if err != nil {
301
- log .Error (err , "Failed to check if runner is registered with the service" )
302
- return ctrl.Result {}, err
303
- }
304
- if ! existsInService {
305
- // the runner does not exist in the service, so it must be done
306
- log .Info ("Ephemeral runner has finished since it does not exist in the service anymore" )
307
- if err := r .markAsFinished (ctx , ephemeralRunner , log ); err != nil {
308
- log .Error (err , "Failed to mark ephemeral runner as finished" )
309
- return ctrl.Result {}, err
310
- }
311
- return ctrl.Result {}, nil
312
- }
313
-
314
- // The runner still exists. This can happen if the pod exited with 0 but fails to start
315
- log .Info ("Ephemeral runner pod has finished, but the runner still exists in the service. Deleting the pod to restart it." )
316
- if err := r .deletePodAsFailed (ctx , ephemeralRunner , pod , log ); err != nil {
317
- log .Error (err , "failed to delete a pod that still exists in the service" )
296
+ default : // succeeded
297
+ log .Info ("Ephemeral runner has finished successfully" )
298
+ if err := r .markAsFinished (ctx , ephemeralRunner , log ); err != nil {
299
+ log .Error (err , "Failed to mark ephemeral runner as finished" )
318
300
return ctrl.Result {}, err
319
301
}
320
302
return ctrl.Result {}, nil
@@ -752,35 +734,6 @@ func (r *EphemeralRunnerReconciler) updateRunStatusFromPod(ctx context.Context,
752
734
return nil
753
735
}
754
736
755
- // runnerRegisteredWithService checks if the runner is still registered with the service
756
- // Returns found=false and err=nil if ephemeral runner does not exist in GitHub service and should be deleted
757
- func (r EphemeralRunnerReconciler ) runnerRegisteredWithService (ctx context.Context , runner * v1alpha1.EphemeralRunner , log logr.Logger ) (found bool , err error ) {
758
- actionsClient , err := r .GetActionsService (ctx , runner )
759
- if err != nil {
760
- return false , fmt .Errorf ("failed to get Actions client for ScaleSet: %w" , err )
761
- }
762
-
763
- log .Info ("Checking if runner exists in GitHub service" , "runnerId" , runner .Status .RunnerId )
764
- _ , err = actionsClient .GetRunner (ctx , int64 (runner .Status .RunnerId ))
765
- if err != nil {
766
- actionsError := & actions.ActionsError {}
767
- if ! errors .As (err , & actionsError ) {
768
- return false , err
769
- }
770
-
771
- if actionsError .StatusCode != http .StatusNotFound ||
772
- ! actionsError .IsException ("AgentNotFoundException" ) {
773
- return false , fmt .Errorf ("failed to check if runner exists in GitHub service: %w" , err )
774
- }
775
-
776
- log .Info ("Runner does not exist in GitHub service" , "runnerId" , runner .Status .RunnerId )
777
- return false , nil
778
- }
779
-
780
- log .Info ("Runner exists in GitHub service" , "runnerId" , runner .Status .RunnerId )
781
- return true , nil
782
- }
783
-
784
737
func (r * EphemeralRunnerReconciler ) deleteRunnerFromService (ctx context.Context , ephemeralRunner * v1alpha1.EphemeralRunner , log logr.Logger ) error {
785
738
client , err := r .GetActionsService (ctx , ephemeralRunner )
786
739
if err != nil {
0 commit comments