Skip to content

Commit 94a6f3c

Browse files
authored
Ensure ephemeral runner is deleted from the service on exit != 0 (#4260)
1 parent e3ed1ba commit 94a6f3c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

controllers/actions.github.com/ephemeralrunner_controller.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,19 @@ func (r *EphemeralRunnerReconciler) Reconcile(ctx context.Context, req ctrl.Requ
336336
log.Error(err, "Failed to delete the ephemeral runner that has a job assigned but the pod has failed")
337337
return ctrl.Result{}, err
338338
}
339+
340+
log.Info("Deleted the ephemeral runner that has a job assigned but the pod has failed")
341+
log.Info("Trying to remove the runner from the service")
342+
actionsClient, err := r.GetActionsService(ctx, ephemeralRunner)
343+
if err != nil {
344+
log.Error(err, "Failed to get actions client for removing the runner from the service")
345+
return ctrl.Result{}, nil
346+
}
347+
if err := actionsClient.RemoveRunner(ctx, int64(ephemeralRunner.Status.RunnerId)); err != nil {
348+
log.Error(err, "Failed to remove the runner from the service")
349+
return ctrl.Result{}, nil
350+
}
351+
log.Info("Removed the runner from the service")
339352
return ctrl.Result{}, nil
340353
}
341354
if err := r.deletePodAsFailed(ctx, ephemeralRunner, pod, log); err != nil {

0 commit comments

Comments
 (0)