Repository navigation
Conversation
|
❗ By default, the pull request is configured to backport to all release branches.
|
|
/test |
|
@armru, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/20168428414 |
There was a problem hiding this comment.
Pull request overview
This PR refactors the namespace watching functionality by removing the custom pkg/multicache implementation and replacing it with controller-runtime's built-in cache.Options.DefaultNamespaces feature. This simplification leverages upstream functionality instead of maintaining custom cache delegation logic.
Key Changes
- Removed the entire custom
pkg/multicachepackage that implemented a delegating multi-namespace cache with separate internal and external caches - Introduced
getNamespacesToWatch()function that builds a namespace map for controller-runtime's built-in multi-namespace cache support - Added comprehensive unit tests for the new namespace configuration logic
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
pkg/multicache/multinamespaced_cache.go |
Removed custom cache implementation that delegated between watched namespaces and external resources |
internal/cmd/manager/controller/controller.go |
Replaced multicache usage with built-in cache options and added helper function to configure watched namespaces |
internal/cmd/manager/controller/controller_test.go |
Added comprehensive tests for namespace configuration including edge cases for whitespace and duplicate handling |
internal/cmd/manager/controller/suite_test.go |
Added Ginkgo test suite setup for controller tests |
| namespaces[namespace] = cache.Config{} | ||
| } | ||
|
|
||
| setupLog.Info("Listening for changes", "watchNamespaces", conf.WatchedNamespaces()) |
There was a problem hiding this comment.
The log message doesn't accurately reflect all namespaces being watched. The function adds the operator namespace to the map (line 492-494), but this log only shows the result of WatchedNamespaces(), which may not include the operator namespace. This could be misleading when debugging or monitoring the operator's behavior. Consider logging all keys from the namespaces map instead to show the complete set of watched namespaces.
| setupLog.Info("Listening for changes", "watchNamespaces", conf.WatchedNamespaces()) | |
| // Log all namespaces being watched, including the operator namespace | |
| watchedNamespaces := make([]string, 0, len(namespaces)) | |
| for ns := range namespaces { | |
| watchedNamespaces = append(watchedNamespaces, ns) | |
| } | |
| setupLog.Info("Listening for changes", "watchNamespaces", watchedNamespaces) |
…me DefaultNamespaces Replace the custom multinamespace watcher implementation (pkg/multicache) with the built-in cache.Options.DefaultNamespaces from controller-runtime. Signed-off-by: Armando Ruocco <[email protected]>
Guard on the parsed namespaces list instead of the raw string, so a value like ",, ," still results in a nil DefaultNamespaces map and a cluster-wide watch, matching the prior custom-multicache behavior. Controller-runtime gates namespaced vs cluster-wide scope on len(DefaultNamespaces) > 0, so seeding the map with the operator namespace before the emptiness check silently scoped the cache to just that namespace. Also log the effective watched set (including the operator namespace), sorted for deterministic output across map-iteration randomization. Assisted-by: Claude Signed-off-by: Marco Nenciarini <[email protected]>
|
/test |
|
@mnencia, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/24579181072 |
Replace the custom multinamespace watcher (pkg/multicache) with
cache.Options.DefaultNamespaces from controller-runtime. The operator
namespace is always added to the watched set so that resources shared
across tenants remain cached.
Closes #5688