Skip to content

Commit caa85e4

Browse files
author
Evsyukov Denis
committed
fix: ensure proper locking in handleBatchConfigEvent for safe config updates
Signed-off-by: Evsyukov Denis <[email protected]>
1 parent b617ad7 commit caa85e4

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

pkg/kube_config_manager/kube_config_manager.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,12 @@ func (kcm *KubeConfigManager) handleBatchConfigEvent(obj config.Event) {
324324
return
325325
}
326326

327+
// Lock to read known checksums and update config.
328+
kcm.m.Lock()
329+
defer kcm.m.Unlock()
330+
327331
if obj.Key == "" {
328332
// Config backend was reset
329-
kcm.m.Lock()
330-
defer kcm.m.Unlock()
331333
kcm.currentConfig = config.NewConfig()
332334
kcm.configEventCh <- config.KubeConfigEvent{
333335
Type: config.KubeConfigChanged,
@@ -337,10 +339,6 @@ func (kcm *KubeConfigManager) handleBatchConfigEvent(obj config.Event) {
337339

338340
newConfig := obj.Config
339341

340-
// Lock to read known checksums and update config.
341-
kcm.m.Lock()
342-
defer kcm.m.Unlock()
343-
344342
globalChanged := kcm.isGlobalChanged(newConfig)
345343

346344
// Parse values in module sections, create new ModuleConfigs and checksums map.

0 commit comments

Comments
 (0)