Skip to content
This repository was archived by the owner on Feb 22, 2022. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions pkg/reconciler/knativeeventing/knativeeventing.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ import (
)

var (
platform common.Platforms
platform common.Platforms
role mf.Predicate = mf.Any(mf.ByKind("ClusterRole"), mf.ByKind("Role"))
rolebinding mf.Predicate = mf.Any(mf.ByKind("ClusterRoleBinding"), mf.ByKind("RoleBinding"))
)

// Reconciler implements controller.Reconciler for Knativeeventing resources.
Expand Down Expand Up @@ -71,7 +73,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, key string) error {
if apierrs.IsNotFound(err) {
// The resource was deleted
r.eventings.Delete(key)
var RBAC = mf.Any(mf.ByKind("Role"), mf.ByKind("ClusterRole"), mf.ByKind("RoleBinding"), mf.ByKind("ClusterRoleBinding"))
var RBAC = mf.Any(role, rolebinding)

if r.eventings.Len() == 0 {
if err := r.config.Filter(mf.NoCRDs, mf.None(RBAC)).Delete(); err != nil {
Expand Down Expand Up @@ -163,6 +165,17 @@ func (r *Reconciler) transform(instance *eventingv1alpha1.KnativeEventing) (mf.M
func (r *Reconciler) install(manifest *mf.Manifest, ke *eventingv1alpha1.KnativeEventing) error {
r.Logger.Debug("Installing manifest")
defer r.updateStatus(ke)
// The Operator needs a higher level of permissions if it 'bind's non-existent roles.
// To avoid this, we strictly order the manifest application as (Cluster)Roles, then
// (Cluster)RoleBindings, then the rest of the manifest.
if err := manifest.Filter(role).Apply(); err != nil {
ke.Status.MarkEventingFailed("Manifest Installation", err.Error())
return err
}
if err := manifest.Filter(rolebinding).Apply(); err != nil {
ke.Status.MarkEventingFailed("Manifest Installation", err.Error())
return err
}
if err := manifest.Apply(); err != nil {
ke.Status.MarkEventingFailed("Manifest Installation", err.Error())
return err
Expand Down