Skip to content

Commit

Permalink
Avoid excessive reconciles due to status updates (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkarlsen authored Dec 30, 2020
1 parent cad74be commit b91e518
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions controllers/githubactionrunner_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"strings"
)
Expand Down Expand Up @@ -171,6 +173,12 @@ func (r *GithubActionRunnerReconciler) SetupWithManager(mgr ctrl.Manager) error
For(&garov1alpha1.GithubActionRunner{}).
Owns(&corev1.Pod{}).
WithOptions(controller.Options{MaxConcurrentReconciles: 1}).
WithEventFilter(predicate.Funcs{
// ignore updates to status: https://stuartleeks.com/posts/kubebuilder-event-filters-part-2-update/
UpdateFunc: func(e event.UpdateEvent) bool {
return e.ObjectNew.GetGeneration() != e.ObjectOld.GetGeneration()
},
}).
Complete(r)
}

Expand Down

0 comments on commit b91e518

Please sign in to comment.