LeaderAwareFuncs in genreconciler do not respect classValue
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?
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.
/remove-lifecycle stale
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.