Filter ClusterRole and ClusterRoleBindings on our labels#817
Filter ClusterRole and ClusterRoleBindings on our labels#817runcom wants to merge 3 commits intoopenshift:masterfrom
Conversation
ClusterRole(s) and ClusterRoleBinding(s) aren't namespaced anyway, see https://kubernetes.io/docs/reference/access-authn-authz/rbac/#role-and-clusterrole Signed-off-by: Antonio Murdaca <runcom@linux.com>
Since ClusterRole and ClusterRoleBindings aren't namespaced, we're triggering a resync for every ClusterRole/Binding that don't pertain us. Use a custom filtered informers for objects with specific MCO labels. Signed-off-by: Antonio Murdaca <runcom@linux.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: runcom The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
| } | ||
| opts.LabelSelector = labels.Merge(ls, map[string]string{"mco-built-in/cluster-role": "", "mco-built-in/cluster-role-binding": ""}).String() | ||
| } | ||
| clusterRoleAndBindingsInformer := informers.NewFilteredSharedInformerFactory(kubeClient, resyncPeriod()(), targetNamespace, filterClusterRoleAndClusterRoleBindings) |
There was a problem hiding this comment.
I might just name this mcoBuiltInInformer and we keep adding labels to the map above when we need specific objects
|
/hold cause testing and fixing and all 🎉 |
| name: machine-config-controller | ||
| namespace: {{.TargetNamespace}} | ||
| labels: | ||
| "mco-built-in/cluster-role": "" |
There was a problem hiding this comment.
this must be in the form <component>.openshift.io/<functionality> (mco.openshift.io/something-something)
There was a problem hiding this comment.
A lot of other operators are going to be installing roles too right? I wonder if we should have a standard annotation for this like openshift.io/operator-managed: ""?
There was a problem hiding this comment.
we could yeah, Maceij suggested the above as a common standard pattern to use for labels but I'm open to a more generalized way as well
There was a problem hiding this comment.
I think we can agree on mco.openshift.io/managed?
There was a problem hiding this comment.
I think we can agree on
mco.openshift.io/managed?
I like this label. Much clearer than the previous label.
Anyone have any opposing thoughts?
There was a problem hiding this comment.
I think most operators have the CVO create the resources for their operators (CRDs, RBAC, namespaces, etc) directly and doesn't need any sort of label for filtering or ownership designations. Is there a reason the MCO is different and has to do it itself rather than using the CVO?
There was a problem hiding this comment.
I did a quick git log install/ which turned up:
commit 3792c944f2ced1be4fe8c2758f390d097a0b7927
Author: Abhinav Dahiya <abhinav.dahiya@redhat.com>
AuthorDate: Tue Aug 7 12:42:10 2018 -0700
Commit: Abhinav Dahiya <abhinav.dahiya@redhat.com>
CommitDate: Mon Aug 13 11:32:07 2018 -0700
*: add operator sync and manifests
manifests/ -> are all the object that operator continuously manages.
install/ -> are all the objects that need to be installed but not
maned by the operator.
Which...hmm, is some sort of hint? I think part of the idea is that we may need to specially handle upgrades for some of our objects?
I am pretty sure there's a real reason for this but it's escaping me at the moment...
There was a problem hiding this comment.
I think part of the idea is that we may need to specially handle upgrades for some of our objects?
Yes, CVO is designed to create and manage objects that are required for the operator to run correctly and not any of it's operands. So it made most sense to control objects so that MCO can at late stage perform migrations for these objects during upgrade...
There was a problem hiding this comment.
Based on this I'd personally lean towards a generic openshift.io/operator-managed: "" and try to propagate that to other codebases as well?
There was a problem hiding this comment.
Alrighty, I like it and it makes total sense, let's go for it, I'll change this and Steve can change the other PR accordingly
| } | ||
| opts.LabelSelector = labels.Merge(ls, map[string]string{"mco-built-in/cluster-role": "", "mco-built-in/cluster-role-binding": ""}).String() | ||
| } | ||
| clusterRoleAndBindingsInformer := informers.NewFilteredSharedInformerFactory(kubeClient, resyncPeriod()(), targetNamespace, filterClusterRoleAndClusterRoleBindings) |
There was a problem hiding this comment.
NewSharedInformerFactoryWithOptions instead of NewFilteredSharedInformerFactory
|
LGTM pending resolution of the label. |
|
/skip |
|
@runcom: PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
@runcom: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
|
In an effort to clean up the MCO repo, closing old open PRs with no recent activity. Feel free to reopen. |
This is a subset of #815 and #813 for ClusterRole and ClusterRoleBindings
manifests: remove namespace from ClusterRole/ClusterRoleBinding …
ClusterRole(s) and ClusterRoleBinding(s) aren't namespaced anyway, see
https://kubernetes.io/docs/reference/access-authn-authz/rbac/#role-and-clusterrole
Signed-off-by: Antonio Murdaca runcom@linux.com
pkg/operator: use filters for ClusterRole/Bindings informers …
Since ClusterRole and ClusterRoleBindings aren't namespaced, we're
triggering a resync for every ClusterRole/Binding that don't pertain us.
Use a custom filtered informers for objects with specific MCO labels.
Signed-off-by: Antonio Murdaca runcom@linux.com