use correct duration for pool refresh (#1094)
Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
This commit is contained in:
Родитель
0d2e1dc573
Коммит
b1d7723c3a
|
@ -6,7 +6,6 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/Azure/azure-container-networking/cns"
|
||||
"github.com/Azure/azure-container-networking/cns/logger"
|
||||
|
@ -25,8 +24,8 @@ type CNSConfig struct {
|
|||
InitializeFromCNI bool
|
||||
ManagedSettings ManagedSettings
|
||||
MetricsBindAddress string
|
||||
SyncHostNCTimeoutMs time.Duration
|
||||
SyncHostNCVersionIntervalMs time.Duration
|
||||
SyncHostNCTimeoutMs int
|
||||
SyncHostNCVersionIntervalMs int
|
||||
TLSCertificatePath string
|
||||
TLSEndpoint string
|
||||
TLSPort string
|
||||
|
@ -151,9 +150,9 @@ func SetCNSConfigDefaults(config *CNSConfig) {
|
|||
config.MetricsBindAddress = ":9090"
|
||||
}
|
||||
if config.SyncHostNCVersionIntervalMs == 0 {
|
||||
config.SyncHostNCVersionIntervalMs = 1000 * time.Millisecond //nolint:gomnd // default times
|
||||
config.SyncHostNCVersionIntervalMs = 1000 //nolint:gomnd // default times
|
||||
}
|
||||
if config.SyncHostNCTimeoutMs == 0 {
|
||||
config.SyncHostNCTimeoutMs = 500 * time.Millisecond //nolint:gomnd // default times
|
||||
config.SyncHostNCTimeoutMs = 500 //nolint:gomnd // default times
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Azure/azure-container-networking/common"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -188,8 +187,8 @@ func TestSetCNSConfigDefaults(t *testing.T) {
|
|||
NodeSyncIntervalInSeconds: 30,
|
||||
},
|
||||
MetricsBindAddress: ":9090",
|
||||
SyncHostNCTimeoutMs: 500 * time.Millisecond,
|
||||
SyncHostNCVersionIntervalMs: 1000 * time.Millisecond,
|
||||
SyncHostNCTimeoutMs: 500,
|
||||
SyncHostNCVersionIntervalMs: 1000,
|
||||
TelemetrySettings: TelemetrySettings{
|
||||
TelemetryBatchSizeBytes: 32768,
|
||||
TelemetryBatchIntervalInSecs: 30,
|
||||
|
|
|
@ -786,11 +786,11 @@ func InitializeMultiTenantController(ctx context.Context, httpRestService cns.HT
|
|||
logger.Printf("Starting SyncHostNCVersion")
|
||||
go func() {
|
||||
// Periodically poll vfp programmed NC version from NMAgent
|
||||
tickerChannel := time.Tick(cnsconfig.SyncHostNCVersionIntervalMs)
|
||||
tickerChannel := time.Tick(time.Duration(cnsconfig.SyncHostNCVersionIntervalMs) * time.Millisecond)
|
||||
for {
|
||||
select {
|
||||
case <-tickerChannel:
|
||||
timedCtx, cancel := context.WithTimeout(ctx, cnsconfig.SyncHostNCTimeoutMs)
|
||||
timedCtx, cancel := context.WithTimeout(ctx, time.Duration(cnsconfig.SyncHostNCVersionIntervalMs)*time.Millisecond)
|
||||
httpRestServiceImpl.SyncHostNCVersion(timedCtx, cnsconfig.ChannelMode)
|
||||
cancel()
|
||||
case <-ctx.Done():
|
||||
|
@ -895,7 +895,10 @@ func InitializeCRDState(ctx context.Context, httpRestService cns.HTTPService, cn
|
|||
scopedcli := kubecontroller.NewScopedClient(nnccli, types.NamespacedName{Namespace: "kube-system", Name: nodeName})
|
||||
|
||||
// initialize the ipam pool monitor
|
||||
poolMonitor := ipampool.NewMonitor(httpRestServiceImplementation, scopedcli, &ipampool.Options{RefreshDelay: poolIPAMRefreshRateInMilliseconds})
|
||||
poolOpts := ipampool.Options{
|
||||
RefreshDelay: poolIPAMRefreshRateInMilliseconds * time.Millisecond,
|
||||
}
|
||||
poolMonitor := ipampool.NewMonitor(httpRestServiceImplementation, scopedcli, &poolOpts)
|
||||
httpRestServiceImplementation.IPAMPoolMonitor = poolMonitor
|
||||
logger.Printf("Starting IPAM Pool Monitor")
|
||||
go func() {
|
||||
|
@ -951,11 +954,11 @@ func InitializeCRDState(ctx context.Context, httpRestService cns.HTTPService, cn
|
|||
logger.Printf("Starting SyncHostNCVersion")
|
||||
go func() {
|
||||
// Periodically poll vfp programmed NC version from NMAgent
|
||||
tickerChannel := time.Tick(cnsconfig.SyncHostNCVersionIntervalMs)
|
||||
tickerChannel := time.Tick(time.Duration(cnsconfig.SyncHostNCVersionIntervalMs) * time.Millisecond)
|
||||
for {
|
||||
select {
|
||||
case <-tickerChannel:
|
||||
timedCtx, cancel := context.WithTimeout(ctx, cnsconfig.SyncHostNCTimeoutMs)
|
||||
timedCtx, cancel := context.WithTimeout(ctx, time.Duration(cnsconfig.SyncHostNCVersionIntervalMs)*time.Millisecond)
|
||||
httpRestServiceImplementation.SyncHostNCVersion(timedCtx, cnsconfig.ChannelMode)
|
||||
cancel()
|
||||
case <-ctx.Done():
|
||||
|
|
Загрузка…
Ссылка в новой задаче