Skip to content

Commit

Permalink
Don't enqueue namespace change if agent bundle already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Sep 24, 2020
1 parent 129eb5f commit 142a60e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/controllers/manageagent/manageagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type handler struct {
apply apply.Apply
systemNamespace string
clusterCache fleetcontrollers.ClusterCache
bundleCache fleetcontrollers.BundleCache
}

func Register(ctx context.Context,
Expand All @@ -37,6 +38,7 @@ func Register(ctx context.Context,
h := handler{
systemNamespace: systemNamespace,
clusterCache: clusters.Cache(),
bundleCache: bundle.Cache(),
apply: apply.
WithSetID("fleet-manage-agent").
WithCacheTypes(bundle),
Expand All @@ -48,7 +50,9 @@ func Register(ctx context.Context,

func (h *handler) resolveNS(namespace, name string, obj runtime.Object) ([]relatedresource.Key, error) {
if _, ok := obj.(*fleet.Cluster); ok {
return []relatedresource.Key{{Name: namespace}}, nil
if _, err := h.bundleCache.Get(namespace, agentBundleName); err != nil {
return []relatedresource.Key{{Name: namespace}}, nil
}
}
return nil, nil
}
Expand Down

0 comments on commit 142a60e

Please sign in to comment.