Skip to content

Commit

Permalink
fix: avoid to unlock unlocked mutex durning setup
Browse files Browse the repository at this point in the history
Signed-off-by: niejiangang <niejiangang@harmonycloud.cn>
  • Loading branch information
NeJan2020 committed Nov 27, 2023
1 parent 9a6f9a0 commit 11e51b6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions collector/pkg/metadata/kubernetes/initk8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,17 @@ func RUnlockMetadataCache() {
MetaDataCache.pMut.RUnlock()
MetaDataCache.cMut.RUnlock()
}

func RLockForSetup() {
MetaDataCache.cMut.RLock()
MetaDataCache.pMut.RLock()
MetaDataCache.sMut.RLock()
podDeleteQueueMut.Lock()
}

func RUnlockForSetup() {
podDeleteQueueMut.Unlock()
MetaDataCache.sMut.RUnlock()
MetaDataCache.pMut.RUnlock()
MetaDataCache.cMut.RUnlock()
}
4 changes: 2 additions & 2 deletions collector/pkg/metadata/kubernetes/k8scache.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ func (c *K8sMetaDataCache) GetNodeNameByIp(ip string) (string, bool) {
}

func SetupCache(cache *K8sMetaDataCache, nodeMap *NodeMap, serviceMap *ServiceMap, rsMap *ReplicaSetMap) {
RLockMetadataCache()
defer RUnlockMetadataCache()
RLockDurningSetup()
defer RUnlockDurningSetup()
if cache != nil {
if cache.ContainerIdInfo != nil {
// Recalculate local cacheMap
Expand Down

0 comments on commit 11e51b6

Please sign in to comment.