Skip to content

Commit c4f007e

Browse files
authored
Reducing resync time to 15 mins (#789)
1 parent effc429 commit c4f007e

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

npm/plugin/main.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package main
44

55
import (
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.
2024
var 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+
}

0 commit comments

Comments
 (0)