-
Notifications
You must be signed in to change notification settings - Fork 245
Implementation of Namespace Filtering with Cache Optimization for KAgent Controller #299
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
Conversation
b9862f0
to
8a4f6bc
Compare
db1ba6f
to
da42a30
Compare
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.
Looks good overall, just some questions
# -- Namespaces the controller should watch. | ||
# If empty, the controller will watch all namespaces (subject to RBAC permissions). | ||
# @default -- [] (watches all namespaces) | ||
watchNamespaces: [] |
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.
At a high level why would these ever need to be different?
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.
for example:
caching on [ns1,ns2,ns3]
filtering on:
- agents to the [ns1, ns2, ns3]
- tools to the [ns1, ns2]
just for future improvements.
one for cache optimization (for bigger clusters)
other one is recommended for security layer and more specific filtering
https://sdk.operatorframework.io/docs/building-operators/golang/operator-scope/#watching-resources-in-a-set-of-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.
After deeper research i've decided to delete predicates and all surrounding logic.
Only namespace watch will persist for now.
The additional layer of predicates may be helpful (but not necessarily) during the RBAC module implementation. For now it only makes a noise and complicates the codebase
f1f6683
to
a042b8c
Compare
a042b8c
to
60de072
Compare
helm/kagent/templates/_helpers.tpl
Outdated
{{- $_ := set $nsSet .Release.Namespace "" }} |
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.
So I think there's actually a bug here. In the controller, the only way to watch all namespaces is by making sure this list is empty, but this function ensures that there's always at least one value in the list, aka the release namespace.
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.
You're right!
I've forgot to commit change for it 😫
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.
I agree that the better solution overall is to ONLY watch the release namespace by default, but I also don't want to break existing users. Ideally in the future we could offer an option where the user can use namespace scoped RBAC instead of cluster scoped, but that's definitely out of scope for this PR.
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.
solved!
Thanks a lot for this finding!
…clude release namespace automatically
5aed6fd
to
c38f4c4
Compare
@EItanya WAIT! |
Sorry for the alert. After merging this PR, I’ll start working on multi-namespace CR handling. It’ll require changes to the data models and updates across all layers of the system (app/controller/UI). |
Would you mind creating a quick design in the issue so we're all on the same page? |
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.
LGTM
} | ||
|
||
return validNamespaces | ||
} |
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.
I'm going to approve, but in a follow-up please move these functions and tests into a different package.
/resolves #298