Don't reconcile non-spec changes

Previously status updates, and metadata updates (labels, annotations)
would trigger unnecessary reconciles. This change makes it so that
we only trigger reconciliation on spec changes, which is equivalent
to generation changes.

Change-Id: Ifa1697b8aa403b56b74aaae9fe60cb3308b28f7c
Signed-off-by: Sean Eagan <seaneagan1@gmail.com>
This commit is contained in:
Sean Eagan
2021-01-26 10:01:48 -06:00
parent 5b2eee07ab
commit b91c38d3c9

View File

@@ -23,7 +23,9 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/predicate"
airshipv1 "sipcluster/pkg/api/v1"
airshipsvc "sipcluster/pkg/services"
@@ -91,7 +93,9 @@ func (r *SIPClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
func (r *SIPClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&airshipv1.SIPCluster{}).
For(&airshipv1.SIPCluster{}, builder.WithPredicates(
predicate.GenerationChangedPredicate{},
)).
Complete(r)
}