Skip to content

Commit

Permalink
fix: [2.4] Store default value if ErrKeyNotFound is returned (#37691)…
Browse files Browse the repository at this point in the history
… (#37705)

Cherry-pick from master
pr: #37691
Related to #37690

Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia authored Nov 15, 2024
1 parent 5d5f899 commit e222289
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/config/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ func (m *Manager) CASCachedValue(key string, origin string, value interface{}) b
m.cacheMutex.Lock()
defer m.cacheMutex.Unlock()
current, err := m.GetConfig(key)
if err != nil && !errors.Is(err, ErrKeyNotFound) {
if errors.Is(err, ErrKeyNotFound) {
m.configCache[key] = value
return true
}
if err != nil {
return false
}
if current != origin {
Expand Down

0 comments on commit e222289

Please sign in to comment.