Skip to content

Commit e9f77f2

Browse files
committed
fix: review
Signed-off-by: Ashing Zheng <[email protected]>
1 parent 1db4f36 commit e9f77f2

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

internal/adc/client/client.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939
)
4040

4141
type Client struct {
42-
syncMu sync.Mutex
42+
syncMu sync.RWMutex
4343
mu sync.Mutex
4444
*cache.Store
4545

@@ -97,6 +97,9 @@ func (d *Client) Update(ctx context.Context, args Task) error {
9797
}
9898
d.mu.Unlock()
9999

100+
d.syncMu.RLock()
101+
defer d.syncMu.RUnlock()
102+
100103
if len(deleteConfigs) > 0 {
101104
err := d.sync(ctx, Task{
102105
Name: args.Name,
@@ -108,6 +111,7 @@ func (d *Client) Update(ctx context.Context, args Task) error {
108111
log.Warnw("failed to sync deleted configs", zap.Error(err))
109112
}
110113
}
114+
111115
return d.sync(ctx, args)
112116
}
113117

@@ -154,6 +158,9 @@ func (d *Client) Delete(ctx context.Context, args Task) error {
154158
}
155159
d.mu.Unlock()
156160

161+
d.syncMu.RLock()
162+
defer d.syncMu.RUnlock()
163+
157164
return d.sync(ctx, Task{
158165
Labels: args.Labels,
159166
ResourceTypes: args.ResourceTypes,

internal/provider/api7ee/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,11 @@ func (d *api7eeProvider) Delete(ctx context.Context, obj client.Object) error {
212212
func (d *api7eeProvider) Start(ctx context.Context) error {
213213
d.readier.WaitReady(ctx, 5*time.Minute)
214214

215+
d.startUpSync.Store(true)
215216
log.Info("Performing startup synchronization")
216217
if err := d.sync(ctx); err != nil {
217218
log.Warnw("failed to sync for startup", zap.Error(err))
218219
}
219-
d.startUpSync.Store(true)
220220

221221
initalSyncDelay := d.InitSyncDelay
222222
if initalSyncDelay > 0 {

0 commit comments

Comments
 (0)