@@ -36,11 +36,14 @@ import (
3636 "sigs.k8s.io/cluster-api/util/patch"
3737 "sigs.k8s.io/cluster-api/util/predicates"
3838 ctrl "sigs.k8s.io/controller-runtime"
39+ ctrlbldr "sigs.k8s.io/controller-runtime/pkg/builder"
3940 "sigs.k8s.io/controller-runtime/pkg/client"
4041 "sigs.k8s.io/controller-runtime/pkg/controller"
4142 ctrlutil "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
43+ "sigs.k8s.io/controller-runtime/pkg/event"
4244 "sigs.k8s.io/controller-runtime/pkg/handler"
4345 "sigs.k8s.io/controller-runtime/pkg/manager"
46+ "sigs.k8s.io/controller-runtime/pkg/predicate"
4447 "sigs.k8s.io/controller-runtime/pkg/reconcile"
4548 "sigs.k8s.io/controller-runtime/pkg/source"
4649
@@ -133,7 +136,17 @@ func AddMachineControllerToManager(ctx *context.ControllerManagerContext, mgr ma
133136 r .networkProvider = networkProvider
134137 } else {
135138 // Watch any VSphereVM resources owned by the controlled type.
136- builder .Watches (& source.Kind {Type : & infrav1.VSphereVM {}}, & handler.EnqueueRequestForOwner {OwnerType : controlledType , IsController : false })
139+ builder .Watches (
140+ & source.Kind {Type : & infrav1.VSphereVM {}},
141+ & handler.EnqueueRequestForOwner {OwnerType : controlledType , IsController : false },
142+ ctrlbldr .WithPredicates (predicate.Funcs {
143+ // ignore creation events since this controller is responsible for
144+ // the creation of the type.
145+ CreateFunc : func (e event.CreateEvent ) bool {
146+ return false
147+ },
148+ }),
149+ )
137150 }
138151
139152 c , err := builder .Build (r )
0 commit comments