No need to requeue in the broker controller reconcile loop #588
Open
Description
Current Behavior
If the resource is created successfully, it's not necessary to requeue the request in the broker controller loop.
Expected Behavior
Continue to create objects if each object is created successfully, the reconcile loop will be more efficient.
Screenshots/Logs
func (r *BrokerReconciler) reconcileBroker(ctx context.Context, enable bool, baseResource *mesheryv1alpha1.Broker, req ctrl.Request) (ctrl.Result, error) {
objects := brokerpackage.GetObjects(baseResource)
for _, object := range objects {
object.SetNamespace(baseResource.Namespace)
err := r.Get(ctx,
types.NamespacedName{
Name: object.GetName(),
Namespace: object.GetNamespace(),
},
object,
)
if err != nil && kubeerror.IsNotFound(err) && enable {
_ = ctrl.SetControllerReference(baseResource, object, r.Scheme)
er := r.Create(ctx, object)
if er != nil {
return ctrl.Result{}, ErrCreateMeshsync(er)
}
// do not requeue here because it's not necessary
return ctrl.Result{Requeue: true}, nil
Environment
- Host OS: Mac Linux Windows
- Platform: Docker or Kubernetes
Contributor Guides and Resources
- 🛠 Meshery Build & Release Strategy
- 📚 Instructions for contributing to documentation
- 🎨 Wireframes and designs for Meshery UI in Figma (open invite)
- 🙋🏾🙋🏼 Questions: Discussion Forum and Community Slack