Skip to content

Commit

Permalink
[BUG] Add proper locking before modifying the ip to key map (chroma-c…
Browse files Browse the repository at this point in the history
…ore#1984)

## Description of changes

*Summarize the changes made by this PR.*
 - Improvements & Bug fixes
	 - This PR adds proper locking to the ip to key map. 
 - New functionality
	 - ...

## Test plan
*How are these changes tested?*

- [ ] Tests pass locally with `pytest` for python, `yarn test` for js,
`cargo test` for rust

## Documentation Changes
*Are all docstrings for user-facing APIs updated if required? Do we need
to make documentation changes in the [docs
repository](https://github.com/chroma-core/docs)?*
  • Loading branch information
Ishiihara authored Apr 9, 2024
1 parent 5cebb0d commit edb5e42
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions go/pkg/memberlist_manager/node_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ func (w *KubernetesWatcher) Start() error {
if err == nil {
log.Info("Kubernetes Pod Updated", zap.String("key", key), zap.String("ip", objPod.Status.PodIP))
ip := objPod.Status.PodIP
w.mu.Lock()
w.ipToKey[ip] = key
w.mu.Unlock()
w.notify(ip)
} else {
log.Error("Error while getting key from object", zap.Error(err))
Expand All @@ -111,7 +113,9 @@ func (w *KubernetesWatcher) Start() error {
log.Info("Kubernetes Pod Deleted", zap.String("ip", objPod.Status.PodIP))
ip := objPod.Status.PodIP
// The contract for GetStatus is that if the ip is not in this map, then it returns NotReady
w.mu.Lock()
delete(w.ipToKey, ip)
w.mu.Unlock()
w.notify(ip)
} else {
log.Error("Error while getting key from object", zap.Error(err))
Expand Down

0 comments on commit edb5e42

Please sign in to comment.