diff --git a/README.md b/README.md index bd5f2ff..a67c0cb 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ in main.go change like this ```go if err = (&controllers.MyReconciler{ - ReconcilerBase: util.NewReconcilerBase(mgr.GetClient(), mgr.GetScheme(), mgr.GetConfig(), mgr.GetEventRecorderFor("My_controller")), + ReconcilerBase: util.NewReconcilerBase(mgr.GetClient(), mgr.GetScheme(), mgr.GetConfig(), mgr.GetEventRecorderFor("My_controller"), mgr.GetAPIReader()), Log: ctrl.Log.WithName("controllers").WithName("My"), }).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "My") diff --git a/pkg/util/lockedresourcecontroller/resource-reconciler.go b/pkg/util/lockedresourcecontroller/resource-reconciler.go index 963f2f8..d777316 100644 --- a/pkg/util/lockedresourcecontroller/resource-reconciler.go +++ b/pkg/util/lockedresourcecontroller/resource-reconciler.go @@ -40,7 +40,7 @@ type LockedResourceReconciler struct { statusChange chan<- event.GenericEvent statusLock sync.Mutex parentObject client.Object - creationFailed chan event.GenericEvent + firstReconcile chan event.GenericEvent log logr.Logger } @@ -57,7 +57,7 @@ func NewLockedObjectReconciler(mgr manager.Manager, object unstructured.Unstruct statusChange: statusChange, parentObject: parentObject, statusLock: sync.Mutex{}, - creationFailed: make(chan event.GenericEvent), + firstReconcile: make(chan event.GenericEvent), status: []metav1.Condition([]metav1.Condition{{ Type: "Initializing", LastTransitionTime: metav1.Now(), @@ -67,16 +67,11 @@ func NewLockedObjectReconciler(mgr manager.Manager, object unstructured.Unstruct }}), } - err := reconciler.CreateOrUpdateResource(context.TODO(), nil, "", object.DeepCopy()) - if err != nil { - reconciler.log.Error(err, "unable to create or update", "resource", object) - reconciler.manageErrorNoInstance(err) - go func() { - reconciler.creationFailed <- event.GenericEvent{ - Object: &object, - } - }() - } + go func() { + reconciler.firstReconcile <- event.GenericEvent{ + Object: &object, + } + }() controller, err := controller.New("controller_locked_object_"+apis.GetKeyLong(&object), mgr, controller.Options{Reconciler: reconciler}) if err != nil { @@ -100,7 +95,7 @@ func NewLockedObjectReconciler(mgr manager.Manager, object unstructured.Unstruct } err = controller.Watch( - &source.Channel{Source: reconciler.creationFailed}, + &source.Channel{Source: reconciler.firstReconcile}, &handler.EnqueueRequestForObject{}, ) if err != nil {