Skip to content

Commit ee12452

Browse files
committed
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.
1 parent 4afbd65 commit ee12452

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

cmd/execute.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func init() {
137137
RootCmd.PersistentFlags().IntVarP(&healthP, "healthcheck-port", "p", 0, "Port for answering healthchecks on /health url")
138138
bindPFlag("healthcheck-port", "healthcheck-port")
139139

140-
RootCmd.PersistentFlags().IntVarP(&resync, "resync-interval", "i", 300, "Resync interval in seconds (0 to disable)")
140+
RootCmd.PersistentFlags().IntVarP(&resync, "resync-interval", "i", 900, "Full resync interval in seconds (0 to disable)")
141141
bindPFlag("resync-interval", "resync-interval")
142142
}
143143

pkg/controller/controller.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ import (
2727

2828
var (
2929
maxProcessRetry = 6
30-
canaryKey = "$katafygio-canary"
30+
canaryKey = "$katafygio canary$"
31+
unexported = []string{"selfLink", "uid", "resourceVersion", "generation"}
3132
)
3233

3334
// Interface describe a standard kubernetes controller
@@ -67,7 +68,7 @@ func New(client cache.ListerWatcher, notifier event.Notifier, name string, confi
6768
informer := cache.NewSharedIndexInformer(
6869
lw,
6970
&unstructured.Unstructured{},
70-
config.ResyncIntv,
71+
config.ResyncIntv*time.Second,
7172
cache.Indexers{},
7273
)
7374

@@ -193,12 +194,11 @@ func (c *Controller) processItem(key string) error {
193194

194195
// clear irrelevant attributes
195196
uc := obj.UnstructuredContent()
196-
md := uc["metadata"].(map[string]interface{})
197197
delete(uc, "status")
198-
delete(md, "selfLink")
199-
delete(md, "uid")
200-
delete(md, "resourceVersion")
201-
delete(md, "generation")
198+
md := uc["metadata"].(map[string]interface{})
199+
for _, attr := range unexported {
200+
delete(md, attr)
201+
}
202202

203203
c.config.Logger.Debugf("Found %s/%s [%s]", obj.GetAPIVersion(), obj.GetKind(), key)
204204

0 commit comments

Comments
 (0)