You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@yunikorn.apache.org by GitBox <gi...@apache.org> on 2021/09/17 09:39:30 UTC

[GitHub] [incubator-yunikorn-k8shim] kingamarton commented on a change in pull request #303: [YUNIKORN-848] Scheduler occasionally crashed due to concurrent r/w map error.

kingamarton commented on a change in pull request #303:
URL: https://github.com/apache/incubator-yunikorn-k8shim/pull/303#discussion_r710909399



##########
File path: pkg/cache/external/scheduler_cache.go
##########
@@ -65,6 +65,16 @@ func (cache *SchedulerCache) GetNodesInfoMap() map[string]*schedulernode.NodeInf
 	return cache.nodesMap
 }
 
+func (cache *SchedulerCache) GetNodesInfoMapCopy() map[string]*schedulernode.NodeInfo {
+	cache.lock.RLock()
+	defer cache.lock.RUnlock()
+	copyOfMap := make(map[string]*schedulernode.NodeInfo, len(cache.nodesMap))
+	for k, v := range cache.nodesMap {
+		copyOfMap[k] = v.Clone()

Review comment:
       Do we need to clone the NodeInfo here? I think it is enough to just pass it: copyOfMap[k] = v




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@yunikorn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org