Skip to content

LeaderAwareFuncs in genreconciler do not respect classValue #2526

Open

Description

@n3wscott

On leader promotion, the controller will enqueue all known instances of Kind without filtering on the provided classValue.

		LeaderAwareFuncs: reconciler.LeaderAwareFuncs{
			PromoteFunc: func(bkt reconciler.Bucket, enq func(reconciler.Bucket, types.NamespacedName)) error {
				all, err := lister.List(labels.Everything())
				if err != nil {
					return err
				}
				for _, elt := range all {
					if promoteFilterFunc != nil {
						if ok := promoteFilterFunc(elt); !ok {
							continue
						}
					}
					enq(bkt, types.NamespacedName{
						Namespace: elt.GetNamespace(),
						Name:      elt.GetName(),
					})
				}
				return nil
			},
		},

It is only in Reconcile(key) that the Kind is filtered and prevented from calling down into ReconcileKind

	if classValue, found := original.GetAnnotations()[ClassAnnotationKey]; !found || classValue != r.classValue {
		logger.Debugw("Skip reconciling resource, class annotation value does not match reconciler instance value.",
			zap.String("classKey", ClassAnnotationKey),
			zap.String("issue", classValue+"!="+r.classValue))
		return nil
	}

The side effect here is every Kind is enqueued and then noop'ed from the queue. Not a huge issue, but for a cluster with many instances of several kinds, it will be extra work each reconciler does not need to do.

Possible Solution

Perhaps we generate a default filter function that can be overloaded if one is provided when we generate a reconciler with a classValue?

Activity

  1. added
    kind/bugCategorizes issue or PR as related to a bug.
    on Jun 1, 2022
  2. github-actions commented on Aug 31, 2022

    @github-actions
    Contributor

    This issue is stale because it has been open for 90 days with no
    activity. It will automatically close after 30 more days of
    inactivity. Reopen the issue with /reopen. Mark the issue as
    fresh by adding the comment /remove-lifecycle stale.

  3. added
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Aug 31, 2022
  4. psschwei commented on Aug 31, 2022

    @psschwei
    Member

    /remove-lifecycle stale

  5. removed
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Aug 31, 2022
  6. github-actions commented on Nov 30, 2022

    @github-actions
    Contributor

    This issue is stale because it has been open for 90 days with no
    activity. It will automatically close after 30 more days of
    inactivity. Reopen the issue with /reopen. Mark the issue as
    fresh by adding the comment /remove-lifecycle stale.

  7. added
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Nov 30, 2022
  8. added
    lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.
    and removed
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions