1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-16 07:09:44 +00:00

Refactor set of cluster scoped handlers

Problem: Cluster scoped gc was taking significantly longer to complete
than before 7387aa5. This was due to a large number of list calls and
the time needed to iterate over them.

Solution: Instead of requesting every type than Rancher uses, a
seperate map appended to when a cluster scoped handler
is created. The full map of all GroupVersionResources is kept as a
fallback for the use case where user controllers may exist on another
host other than the current leader.
This commit is contained in:
dax
2019-05-28 10:25:48 -07:00
committed by Craig Jellick
parent ea122abac5
commit f5744043a6
2 changed files with 24 additions and 0 deletions

View File

@@ -157,6 +157,7 @@ func (c *{{.schema.ID}}Controller) AddHandler(ctx context.Context, name string,
}
func (c *{{.schema.ID}}Controller) AddClusterScopedHandler(ctx context.Context, name, cluster string, handler {{.schema.CodeName}}HandlerFunc) {
resource.PutClusterScoped({{.schema.CodeName}}GroupVersionResource)
c.GenericController.AddHandler(ctx, name, func(key string, obj interface{}) (interface{}, error) {
if obj == nil {
return handler(key, nil)