Skip to content

Enhance the filtered cache mechanism #1715

Closed
@chrispatmore

Description

@chrispatmore

I have been playing around with the filtered caching mechanism added in controller-runtime v0.9.0, and have found that it is not quite sufficient for all of my use cases.

It works great if I am trying to filter down the resources with one rule, i.e. only show me configmaps where the label foo has value bar

selectors := cache.SelectorsByObject{
    &corev1.Pod{}:                   {
        Label: labels.SelectorFromSet(labels.Set{
            "app.kubernetes.io/managed-by": "my-operator",
        })
    }
}

However as far as I can tell it is not possible to create selectors with any form of logical OR.

I cannot say for example, find any configmaps where label foo has value bar OR label x has value y OR metadata.name has value my-configmap

This means that I cannot access any configmap that does not meet my one allowed rule, and therefore my only option if I need to do that is have no cache rule for configmaps, which defeats the point of having it.

It would be ideal if some form of OR functionality could be added, for example by changing the mapping of a selector from
map[client.Object]internal.Selector to map[client.Object][]internal.Selector
where each item in the array is applied as an OR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions