Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 6 additions & 4 deletions pkg/controllers/projectquota/projectquota_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package projectquota

import (
"context"
"errors"
"fmt"
"sort"
"strings"
Expand Down Expand Up @@ -373,17 +374,17 @@ func (r *ProjectQuotaReconciler) SetupWithManager(mgr ctrl.Manager) (*ProjectQuo
return r, nil
}

func (r *ProjectQuotaReconciler) StartWatcher(rid kmapi.ResourceID) {
func (r *ProjectQuotaReconciler) StartWatcher(rid kmapi.ResourceID) error {
r.mu.Lock()
defer r.mu.Unlock()

if r.ctrl == nil {
klog.Fatalln("ProjectQuota reconciler is not setup yet!")
return errors.New("ProjectQuota reconciler is not setup yet")
}

gvk := rid.GroupVersionKind()
if gvk.Kind == "" {
klog.Fatalln("can't start ProjectQuota reconciler for unknown Kind!")
return fmt.Errorf("can't start ProjectQuota reconciler for unknown Kind of resource %s", rid.GroupResource())
}

if api.IsRegistered(gvk) && !r.regTypes[gvk] {
Expand All @@ -396,10 +397,11 @@ func (r *ProjectQuotaReconciler) StartWatcher(rid kmapi.ResourceID) {
handler.EnqueueRequestsFromMapFunc(ProjectQuotaForObjects(r.Client))),
)
if err != nil {
klog.Fatalln(err)
return fmt.Errorf("failed to start ProjectQuota watcher for %s: %w", gvk, err)
}
r.regTypes[gvk] = true
}
return nil
}

// Obj -> ProjectQuota
Expand Down
4 changes: 3 additions & 1 deletion pkg/graph/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ func PollNewResourceTypes(cfg *restclient.Config, pqr *projectquotacontroller.Pr
resourceTracker[gvk] = rid
resourceChannel <- rid
if pqr != nil {
pqr.StartWatcher(rid)
if err := pqr.StartWatcher(rid); err != nil {
klog.ErrorS(err, "failed to start ProjectQuota watcher", "gvk", gvk)
}
}
}
}
Expand Down
Loading