Slide 30
Slide 30 text
CloudProviderNodeInstancesCache Refresh loop
以下の処理を2分毎に実⾏してるだけ
// Refresh refreshes cache.
func (cache *CloudProviderNodeInstancesCache) Refresh() {
klog.Infof("Start refreshing cloud provider node instances cache")
refreshStart := time.Now()
nodeGroups := cache.cloudProvider.NodeGroups()
cache.removeEntriesForNonExistingNodeGroupsLocked(nodeGroups)
for _, nodeGroup := range nodeGroups {
nodeGroupInstances, err := nodeGroup.Nodes()
if err != nil {
klog.Errorf("Failed to get cloud provider node instance for node group %v, error %v",
nodeGroup.Id(), err)
}
cache.updateCacheEntryLocked(nodeGroup,
&cloudProviderNodeInstancesCacheEntry{nodeGroupInstances, time.Now()})
}
klog.Infof("Refresh cloud provider node instances cache finished, refresh took %v",
time.Now().Sub(refreshStart))
}
https://github.com/kubernetes/autoscaler/blob/cluster-autoscaler-1.20.2/cluster-autoscaler/clusterstate/utils/node_instances_cache.go#L154-L176