From ee12452c8a70b03597c6597f1de6d6d3a584c683 Mon Sep 17 00:00:00 2001 From: Benjamin Pineau Date: Thu, 19 Apr 2018 11:35:07 +0200 Subject: [PATCH] Increase resync interval Due to the simplicity of our objects lifecycle (basicaly, files on disk), we have very little chances of missing events, so we shouldn't obsess on resyncing too frequently. This caused pointless burden on the api-server. --- cmd/execute.go | 2 +- pkg/controller/controller.go | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/execute.go b/cmd/execute.go index 0e9c137..a92162f 100644 --- a/cmd/execute.go +++ b/cmd/execute.go @@ -137,7 +137,7 @@ func init() { RootCmd.PersistentFlags().IntVarP(&healthP, "healthcheck-port", "p", 0, "Port for answering healthchecks on /health url") bindPFlag("healthcheck-port", "healthcheck-port") - RootCmd.PersistentFlags().IntVarP(&resync, "resync-interval", "i", 300, "Resync interval in seconds (0 to disable)") + RootCmd.PersistentFlags().IntVarP(&resync, "resync-interval", "i", 900, "Full resync interval in seconds (0 to disable)") bindPFlag("resync-interval", "resync-interval") } diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 48969e2..220b384 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -27,7 +27,8 @@ import ( var ( maxProcessRetry = 6 - canaryKey = "$katafygio-canary" + canaryKey = "$katafygio canary$" + unexported = []string{"selfLink", "uid", "resourceVersion", "generation"} ) // Interface describe a standard kubernetes controller @@ -67,7 +68,7 @@ func New(client cache.ListerWatcher, notifier event.Notifier, name string, confi informer := cache.NewSharedIndexInformer( lw, &unstructured.Unstructured{}, - config.ResyncIntv, + config.ResyncIntv*time.Second, cache.Indexers{}, ) @@ -193,12 +194,11 @@ func (c *Controller) processItem(key string) error { // clear irrelevant attributes uc := obj.UnstructuredContent() - md := uc["metadata"].(map[string]interface{}) delete(uc, "status") - delete(md, "selfLink") - delete(md, "uid") - delete(md, "resourceVersion") - delete(md, "generation") + md := uc["metadata"].(map[string]interface{}) + for _, attr := range unexported { + delete(md, attr) + } c.config.Logger.Debugf("Found %s/%s [%s]", obj.GetAPIVersion(), obj.GetKind(), key)