Skip to content

Commit

Permalink
Unregister evicted pods (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkarlsen authored Jun 12, 2021
1 parent 11144ca commit 6eec58a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion controllers/githubactionrunner_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func (r *GithubActionRunnerReconciler) unregisterRunner(ctx context.Context, cr

// handleFinalization will remove runner from github based on presence of finalizer
func (r *GithubActionRunnerReconciler) handleFinalization(ctx context.Context, cr *garov1alpha1.GithubActionRunner, list podRunnerPairList) error {
for _, item := range list.getPodsBeingDeleted() {
for _, item := range list.getPodsBeingDeletedOrEvicted() {
// TODO - cause of failure should be checked more closely, if it does not exist we can ignore it. If it is a comms error we should stick around
if err := r.unregisterRunner(ctx, cr, item); err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions controllers/podrunner_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ func (r podRunnerPairList) getIdles(sortOrder v1alpha1.SortOrder, minTTL time.Du
return idles
}

func (r podRunnerPairList) getPodsBeingDeleted() []podRunnerPair {
func (r podRunnerPairList) getPodsBeingDeletedOrEvicted() []podRunnerPair {
return funk.Filter(r.pairs, func(pair podRunnerPair) bool {
return util.IsBeingDeleted(&pair.pod)
return util.IsBeingDeleted(&pair.pod) || isEvicted(&pair.pod)
}).([]podRunnerPair)
}
10 changes: 10 additions & 0 deletions controllers/podutil.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package controllers

import (
v1 "k8s.io/api/core/v1"
"strings"
)

func isEvicted(pod *v1.Pod) bool {
return strings.Contains(pod.Status.Reason, "Evicted")
}

0 comments on commit 6eec58a

Please sign in to comment.