code: func (cache *schedulerCache) UpdateNodeInfoSnapshot(nodeSnapshot *NodeInfoSnapshot) error {
  	cache.mu.Lock()
  	defer cache.mu.Unlock()
  	balancedVolumesEnabled := utilfeature.DefaultFeatureGate.Enabled(features.BalanceAttachedNodeVolumes)
  
  	// Get the last generation of the the snapshot.
  	snapshotGeneration := nodeSnapshot.Generation
  
  	// Start from the head of the NodeInfo doubly linked list and update snapshot
  	// of NodeInfos updated after the last snapshot.
  	for node := cache.headNode; node != nil; node = node.next {
  		if node.info.GetGeneration() <= snapshotGeneration {
  			// all the nodes are updated before the existing snapshot. We are done.
  			break
  		}
  		if balancedVolumesEnabled && node.info.TransientInfo != nil {
  			// Transient scheduler info is reset here.
  			node.info.TransientInfo.ResetTransientSchedulerInfo()
  		}
  		if np := node.info.Node(); np != nil {
  			nodeSnapshot.NodeInfoMap[np.Name] = node.info.Clone()
  		}
  	}
  	// Update the snapshot generation with the latest NodeInfo generation.
  	if cache.headNode != nil {
  		nodeSnapshot.Generation = cache.headNode.info.GetGeneration()
  	}
  
  	if len(nodeSnapshot.NodeInfoMap) > len(cache.nodes) {
  		for name := range nodeSnapshot.NodeInfoMap {
  			if _, ok := cache.nodes[name]; !ok {
  				delete(nodeSnapshot.NodeInfoMap, name)
  			}
  		}
  	}
  	return nil
  }
docs: // UpdateNodeInfoSnapshot takes a snapshot of cached NodeInfo map. This is called at
  // beginning of every scheduling cycle.
  // This function tracks generation number of NodeInfo and updates only the
  // entries of an existing snapshot that have changed after the snapshot was taken.