From eda3ecf987551f6ac7445cdf6402d7feceb2e30b Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sat, 14 Mar 2020 11:46:20 -0700 Subject: [PATCH] Fix counts --- pkg/clustercache/controller.go | 2 +- pkg/server/resources/counts/counts.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/clustercache/controller.go b/pkg/clustercache/controller.go index 0e25abf..bfac848 100644 --- a/pkg/clustercache/controller.go +++ b/pkg/clustercache/controller.go @@ -228,7 +228,7 @@ func (h *clusterCache) start() { key := toKey(event.obj) if event.oldObj != nil { - _, err := callAll(h.addHandlers.List(), event.gvr, key, event.obj, event.oldObj) + _, err := callAll(h.changeHandlers.List(), event.gvr, key, event.obj, event.oldObj) if err != nil { logrus.Errorf("failed to handle add event: %v", err) } diff --git a/pkg/server/resources/counts/counts.go b/pkg/server/resources/counts/counts.go index 815e91f..1de7d87 100644 --- a/pkg/server/resources/counts/counts.go +++ b/pkg/server/resources/counts/counts.go @@ -145,6 +145,7 @@ func (s *Store) Watch(apiOp *types.APIRequest, schema *types.APISchema, w types. return nil } itemCount = removeCounts(itemCount, namespace, oldSummary) + itemCount = addCounts(itemCount, namespace, summary) } else { return nil } @@ -242,7 +243,7 @@ func getInfo(obj interface{}) (name string, namespace string, revision int, summ func removeCounts(itemCount ItemCount, ns string, summary summary.Summary) ItemCount { itemCount.Summary = removeSummary(itemCount.Summary, summary) - if ns == "" { + if ns != "" { itemCount.Namespaces[ns] = removeSummary(itemCount.Namespaces[ns], summary) } return itemCount @@ -250,7 +251,7 @@ func removeCounts(itemCount ItemCount, ns string, summary summary.Summary) ItemC func addCounts(itemCount ItemCount, ns string, summary summary.Summary) ItemCount { itemCount.Summary = addSummary(itemCount.Summary, summary) - if ns == "" { + if ns != "" { itemCount.Namespaces[ns] = addSummary(itemCount.Namespaces[ns], summary) } return itemCount