File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 33package main
44
55import (
6+ "math/rand"
67 "time"
78
89 "github.com/Azure/azure-container-networking/log"
@@ -14,7 +15,10 @@ import (
1415 "k8s.io/client-go/rest"
1516)
1617
17- const waitForTelemetryInSeconds = 60
18+ const (
19+ waitForTelemetryInSeconds = 60
20+ resyncPeriodInMinutes = 15
21+ )
1822
1923// Version is populated by make during build.
2024var version string
@@ -58,7 +62,15 @@ func main() {
5862 panic (err .Error ())
5963 }
6064
61- factory := informers .NewSharedInformerFactory (clientset , time .Hour * 24 )
65+ // Setting reSyncPeriod to 15 mins
66+ minResyncPeriod := resyncPeriodInMinutes * time .Minute
67+
68+ // Adding some randomness so all NPM pods will not request for info at once.
69+ factor := rand .Float64 () + 1
70+ resyncPeriod := time .Duration (float64 (minResyncPeriod .Nanoseconds ()) * factor )
71+
72+ log .Logf ("[INFO] Resync period for NPM pod is set to %d." , int (resyncPeriod / time .Minute ))
73+ factory := informers .NewSharedInformerFactory (clientset , resyncPeriod )
6274
6375 npMgr := npm .NewNetworkPolicyManager (clientset , factory , version )
6476 metrics .CreateTelemetryHandle (npMgr .GetAppVersion (), npm .GetAIMetadata ())
@@ -73,4 +85,4 @@ func main() {
7385 metrics .StartHTTP (0 )
7486
7587 select {}
76- }
88+ }
You can’t perform that action at this time.
0 commit comments