Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a single cache for all dynamic controllers (i.e. XRs and claims) #5651

Merged
merged 10 commits into from
May 21, 2024

Commits on May 20, 2024

  1. Move engine and GVK routed cache from c/cr

    This just moved the files, unedited, as of the below commit.
    
    crossplane/crossplane-runtime@8641eb2
    
    Signed-off-by: Nic Cope <nicc@rk0n.org>
    negz committed May 20, 2024
    Configuration menu
    Copy the full SHA
    e0bd283 View commit details
    Browse the repository at this point in the history
  2. Rename the controller package to engine, rename types to not stutter

    Signed-off-by: Nic Cope <nicc@rk0n.org>
    negz committed May 20, 2024
    Configuration menu
    Copy the full SHA
    697dc71 View commit details
    Browse the repository at this point in the history
  3. Use the c/c controller engine and GVK routed cache, not c/cr

    Signed-off-by: Nic Cope <nicc@rk0n.org>
    negz committed May 20, 2024
    Configuration menu
    Copy the full SHA
    bb6cbc8 View commit details
    Browse the repository at this point in the history
  4. Bump to latest runtime and kubernetes deps

    This bumps crossplane-runtime, controller-runtime, and k8s.io
    dependencies to latest.
    
    Per the below PR, the latest crossplane-runtime doesn't have the
    controller engine anymore. It moved into c/c.
    
    crossplane/crossplane-runtime#689
    
    Signed-off-by: Nic Cope <nicc@rk0n.org>
    negz committed May 20, 2024
    Configuration menu
    Copy the full SHA
    89ce6c7 View commit details
    Browse the repository at this point in the history
  5. Linter updates due to bumping go.mod to Go v1.22

    Updating our controller-runtime and Kubernetes dependencies bumped our
    minimum Go version to v1.22. That in turn enables some new linters,
    since we no longer need to copy range vars in Go v1.22.
    
    Signed-off-by: Nic Cope <nicc@rk0n.org>
    negz committed May 20, 2024
    Configuration menu
    Copy the full SHA
    05bd8bd View commit details
    Browse the repository at this point in the history
  6. Workaround malformed generated CRD

    Signed-off-by: Nic Cope <nicc@rk0n.org>
    negz committed May 20, 2024
    Configuration menu
    Copy the full SHA
    355ba7a View commit details
    Browse the repository at this point in the history
  7. Make CompositeReconcilerOptions a method on Reconciler

    It started as a function, but now we pass several arguments that are all
    fields of the Reconciler. It's only called once, by the Reconciler.
    Making it a method shortens the function signature, and makes it clear
    which things change on each reconcile and which are fixed.
    
    Signed-off-by: Nic Cope <nicc@rk0n.org>
    negz committed May 20, 2024
    Configuration menu
    Copy the full SHA
    5cfbd67 View commit details
    Browse the repository at this point in the history
  8. Re-enable realtime compositions E2E tests

    Signed-off-by: Nic Cope <nicc@rk0n.org>
    negz committed May 20, 2024
    Configuration menu
    Copy the full SHA
    e68021d View commit details
    Browse the repository at this point in the history
  9. Move realtime composition event handlers into their own file

    Signed-off-by: Nic Cope <nicc@rk0n.org>
    negz committed May 20, 2024
    Configuration menu
    Copy the full SHA
    b756bd1 View commit details
    Browse the repository at this point in the history
  10. Use a single cache for all dynamic controllers

    Crossplane uses a controller engine to dynamically start claim and XR
    controllers when a new XRD is installed.
    
    Before this commit, each controller gets at least one cache. This is
    because when I built this functionality, you couldn't stop a single
    informer within a cache (a cache is basically a map of informers by
    GVK).
    
    When realtime composition is enabled, there are even more caches. One
    per composed resource GVK. A GVK routed cache routes cache lookups to
    these various delegate caches.
    
    Meanwhile, controller-runtime recently made it possible to stop an
    informer within a cache. It's also been possible to remove an event
    handler from an informer for some time (since Kubernetes 1.26).
    
    kubernetes-sigs/controller-runtime#2285
    kubernetes-sigs/controller-runtime#2046
    
    This commit uses a single client, backed by a single cache, across all
    dynamic controllers (specifically the definition, offered, claim, and
    XR controllers).
    
    Compared to the current implementation, this commit:
    
    * Takes fewer global locks when realtime compositions are enabled.
      Locking is now mostly at the controller scope.
    * Works with the breaking changes to source.Source introduced in
      controller-runtime v0.18. :)
    
    I think this makes the realtime composition code a little easier to
    follow by consolodating it into the ControllerEngine, but that's
    pretty subjective.
    
    Signed-off-by: Nic Cope <nicc@rk0n.org>
    negz committed May 20, 2024
    Configuration menu
    Copy the full SHA
    5ce3edd View commit details
    Browse the repository at this point in the history