Skip to content

Commit 0f9248e

Browse files
authored
Merge pull request #2980 from panslava/replace-polling
replace 5s poll with WaitForCacheSync
2 parents df4f157 + 39f2b13 commit 0f9248e

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

pkg/multiproject/controller/controller.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import (
66
"fmt"
77
"math/rand"
88
"runtime/debug"
9-
"time"
109

11-
"k8s.io/apimachinery/pkg/util/wait"
1210
"k8s.io/client-go/tools/cache"
1311
providerconfig "k8s.io/ingress-gce/pkg/apis/providerconfig/v1"
1412
"k8s.io/ingress-gce/pkg/utils"
@@ -81,12 +79,10 @@ func (pcc *ProviderConfigController) Run() {
8179
cancel()
8280
}()
8381

84-
err := wait.PollUntilContextCancel(ctx, 5*time.Second, true, func(ctx context.Context) (bool, error) {
85-
pcc.logger.Info("Waiting for initial cache sync before starting ProviderConfig Controller")
86-
return pcc.hasSynced(), nil
87-
})
88-
if err != nil {
89-
pcc.logger.Error(err, "Failed to wait for initial cache sync before starting ProviderConfig Controller")
82+
pcc.logger.Info("Waiting for initial cache sync before starting ProviderConfig Controller")
83+
ok := cache.WaitForCacheSync(ctx.Done(), pcc.hasSynced)
84+
if !ok {
85+
pcc.logger.Error(nil, "Failed to wait for initial cache sync before starting ProviderConfig Controller")
9086
}
9187

9288
pcc.logger.Info("Started ProviderConfig Controller", "numWorkers", pcc.numWorkers)

0 commit comments

Comments
 (0)