Skip to content

Commit

Permalink
fix(ingress): Add generation and annotation predicates
Browse files Browse the repository at this point in the history
This fixes "object has been modified" warnings
  • Loading branch information
gabe565 committed Apr 17, 2024
1 parent b65670f commit d9d57eb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/controller/ingress_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ import (
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/runtime"
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/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
)

const AnnotationPrefix = "uptime-robot.clevyr.com/"
Expand Down Expand Up @@ -148,7 +150,9 @@ func (r *IngressReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
// SetupWithManager sets up the controller with the Manager.
func (r *IngressReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&networkingv1.Ingress{}).
For(&networkingv1.Ingress{}, builder.WithPredicates(
predicate.Or(predicate.GenerationChangedPredicate{}, predicate.AnnotationChangedPredicate{}),
)).
Complete(r)
}

Expand Down

0 comments on commit d9d57eb

Please sign in to comment.