-
Notifications
You must be signed in to change notification settings - Fork 8
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
Multi namespaces cache #62
base: master
Are you sure you want to change the base?
Conversation
for _, rule := range s.Spec.Rules { | ||
for _, match := range rule.Matches { | ||
if len(match.Namespaces) == 0 { | ||
return namespaces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Why are we returning namespaces
here (I believe it is always empty if we reach this line)? Don't we need to check the next rule in the outermost for loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it returns there, because if there is a match without namespace filtering that means actually it cares about resources from every namespace
// GetRelatedNamespaces gathers namespaces from rule matchers | ||
// it returns an empty list if any of the matchers is without namespace filter | ||
// since it means every namespace is related | ||
func (s *ResourceSyncRule) GetRelatedNamespaces() []string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be great if we can add an unit test for this function
for _, rule := range s.Spec.Rules { | ||
for _, match := range rule.Matches { | ||
if len(match.Namespaces) == 0 { | ||
return namespaces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it returns there, because if there is a match without namespace filtering that means actually it cares about resources from every namespace
@@ -66,9 +67,10 @@ func WithRequiredClusterFeatures(features ...ClusterFeatureRequirement) ManagedC | |||
} | |||
} | |||
|
|||
func NewManagedController(name string, r ManagedReconciler, l logr.Logger, options ...ManagedControllerOption) ManagedController { | |||
func NewManagedController(name string, relatedNamespaces []string, r ManagedReconciler, l logr.Logger, options ...ManagedControllerOption) ManagedController { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create and use a new option here to set the related namespaces
What's in this PR?
Contains the changes required to limit namespace cache based on ResourceSyncRule
rules.match.namespaces
rules.match.namespaces
Why?
In larger cluster with namespaces more than 30-40, it was observed that CR-controller watches/caches all the namespaces into the mem, which caused frequent OOMKilled issue while attaching peer clusters.
This PR allows users to select namespaces to cache for their RSR, there-by reducing memory usage.
Checklist