@@ -19,6 +19,7 @@ package api7ee
1919
2020import (
2121 "context"
22+ "sync/atomic"
2223 "time"
2324
2425 "github.com/api7/gopkg/pkg/log"
@@ -56,7 +57,7 @@ type api7eeProvider struct {
5657
5758 syncCh chan struct {}
5859
59- startUpSync bool
60+ startUpSync atomic. Bool
6061
6162 client * adcclient.Client
6263}
@@ -161,8 +162,8 @@ func (d *api7eeProvider) Update(ctx context.Context, tctx *provider.TranslateCon
161162 },
162163 }
163164
164- if ! d .startUpSync {
165- log .Debugw ("resource not ready , skip sync" , zap .Any ("object" , obj ))
165+ if ! d .startUpSync . Load () {
166+ log .Debugw ("startup synchronization not completed , skip sync" , zap .Any ("object" , obj ))
166167 return d .client .UpdateConfig (ctx , task )
167168 }
168169
@@ -211,13 +212,11 @@ func (d *api7eeProvider) Delete(ctx context.Context, obj client.Object) error {
211212func (d * api7eeProvider ) Start (ctx context.Context ) error {
212213 d .readier .WaitReady (ctx , 5 * time .Minute )
213214
214- // sync once
215- log .Info ("for startup sync" )
215+ log .Info ("Performing startup synchronization" )
216216 if err := d .sync (ctx ); err != nil {
217217 log .Warnw ("failed to sync for startup" , zap .Error (err ))
218218 }
219- // set startUpSync to true
220- d .startUpSync = true
219+ d .startUpSync .Store (true )
221220
222221 initalSyncDelay := d .InitSyncDelay
223222 if initalSyncDelay > 0 {
0 commit comments