Skip to content

No need to requeue in the broker controller reconcile loop #588

Open
@jxs1211

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

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions