From 8ec196b782b657389a1cc27313678b8c5cd1098c Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Thu, 15 Oct 2020 15:17:50 -0700 Subject: [PATCH] Enqueue tenant only if RVs are different - Remove superfluous tick.Stop call --- pkg/controller/cluster/csr.go | 1 - pkg/controller/cluster/main-controller.go | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/controller/cluster/csr.go b/pkg/controller/cluster/csr.go index 687f19f0eae..c0e48946464 100644 --- a/pkg/controller/cluster/csr.go +++ b/pkg/controller/cluster/csr.go @@ -221,7 +221,6 @@ func (c *Controller) fetchCertificate(ctx context.Context, csrName string) ([]by defer tick.Stop() timeout := time.NewTimer(miniov1.DefaultQueryTimeout) - defer tick.Stop() ch := make(chan os.Signal, 1) // should be always un-buffered SA1017 signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM) diff --git a/pkg/controller/cluster/main-controller.go b/pkg/controller/cluster/main-controller.go index 675bb0021d3..37a76c01fa0 100644 --- a/pkg/controller/cluster/main-controller.go +++ b/pkg/controller/cluster/main-controller.go @@ -238,7 +238,13 @@ func NewController( tenantInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ AddFunc: controller.enqueueTenant, UpdateFunc: func(old, new interface{}) { - // TODO: compare old vs new and don't enqueue if they are identical + oldTenant := old.(*miniov1.Tenant) + newTenant := new.(*miniov1.Tenant) + if newTenant.ResourceVersion == oldTenant.ResourceVersion { + // Periodic resync will send update events for all known Tenants. + // Two different versions of the same Tenant will always have different RVs. + return + } controller.enqueueTenant(new) }, })