Skip to content

Commit

Permalink
Merge pull request kubeagi#744 from 0xff-dev/main
Browse files Browse the repository at this point in the history
fix: too many unexpected logs in arcadia-controller during startup
  • Loading branch information
bjwswang authored Feb 22, 2024
2 parents 303c122 + ab35f48 commit 1536dbb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 7 additions & 3 deletions controllers/base/namespace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (r *NamespaceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
return reconcile.Result{RequeueAfter: waitSmaller}, err
}
if err = r.removeRagRBAC(ctx, logger, req.Name); err != nil {
return reconcile.Result{RequeueAfter: waitSmaller}, err
return reconcile.Result{RequeueAfter: waitSmaller}, nil
}

return reconcile.Result{}, nil
Expand Down Expand Up @@ -112,7 +112,7 @@ func (r *NamespaceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (

// 2. checkout rag serviceaccount and rolebing
if err := r.ensureRagRBAC(ctx, logger, instance); err != nil {
return reconcile.Result{}, err
return reconcile.Result{RequeueAfter: waitSmaller}, nil
}
// 3. Reconcile for MinIO bucket, we will create a separate bucket for each namespace
skip, err := r.checkSkippedNamespace(ctx, instance.Name)
Expand Down Expand Up @@ -245,10 +245,14 @@ func (r *NamespaceReconciler) ensureRagRBAC(ctx context.Context, logger logr.Log
idx := sort.Search(len(crb.Subjects), func(i int) bool {
s := crb.Subjects[i]
if s.Namespace == instance.Name {
return s.Name > saName
return s.Name >= saName
}
return s.Namespace > instance.Name
})
if idx < len(crb.Subjects) && crb.Subjects[idx].Namespace == instance.Name && crb.Subjects[idx].Name == saName {
// found record
return nil
}
crb.Subjects = append(crb.Subjects[:idx], append([]v1.Subject{{
Kind: "ServiceAccount",
Name: saName,
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

batchv1 "k8s.io/api/batch/v1"
v1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
Expand Down Expand Up @@ -71,6 +72,7 @@ func init() {
utilruntime.Must(evaluationarcadiav1alpha1.AddToScheme(scheme))
utilruntime.Must(batchv1.AddToScheme(scheme))
utilruntime.Must(agentv1alpha1.AddToScheme(scheme))
utilruntime.Must(rbacv1.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
}

Expand Down

0 comments on commit 1536dbb

Please sign in to comment.