Skip to content

Commit

Permalink
Merge pull request #5561 from peaaceChoi/remove-deepcopynode-err
Browse files Browse the repository at this point in the history
Delete unused err  returns
k8s-ci-robot authored Mar 6, 2023
2 parents b8ec430 + 82e8804 commit 553ccf7
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cluster-autoscaler/core/utils/utils.go
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ func FilterOutNodesFromNotAutoscaledGroups(nodes []*apiv1.Node, cloudProvider cl
}

// DeepCopyNodeInfo clones the provided nodeInfo
func DeepCopyNodeInfo(nodeInfo *schedulerframework.NodeInfo) (*schedulerframework.NodeInfo, errors.AutoscalerError) {
func DeepCopyNodeInfo(nodeInfo *schedulerframework.NodeInfo) *schedulerframework.NodeInfo {
newPods := make([]*apiv1.Pod, 0)
for _, podInfo := range nodeInfo.Pods {
newPods = append(newPods, podInfo.Pod.DeepCopy())
@@ -97,7 +97,7 @@ func DeepCopyNodeInfo(nodeInfo *schedulerframework.NodeInfo) (*schedulerframewor
// Build a new node info.
newNodeInfo := schedulerframework.NewNodeInfo(newPods...)
newNodeInfo.SetNode(nodeInfo.Node().DeepCopy())
return newNodeInfo, nil
return newNodeInfo
}

// SanitizeNodeInfo modify nodeInfos generated from templates to avoid using duplicated host names
Original file line number Diff line number Diff line change
@@ -116,9 +116,8 @@ func (p *MixedTemplateNodeInfoProvider) Process(ctx *context.AutoscalingContext,
return map[string]*schedulerframework.NodeInfo{}, typedErr
}
if added && p.nodeInfoCache != nil {
if nodeInfoCopy, err := utils.DeepCopyNodeInfo(result[id]); err == nil {
p.nodeInfoCache[id] = cacheItem{NodeInfo: nodeInfoCopy, added: time.Now()}
}
nodeInfoCopy := utils.DeepCopyNodeInfo(result[id])
p.nodeInfoCache[id] = cacheItem{NodeInfo: nodeInfoCopy, added: time.Now()}
}
}
for _, nodeGroup := range ctx.CloudProvider.NodeGroups() {
@@ -133,8 +132,8 @@ func (p *MixedTemplateNodeInfoProvider) Process(ctx *context.AutoscalingContext,
if cacheItem, found := p.nodeInfoCache[id]; found {
if p.isCacheItemExpired(cacheItem.added) {
delete(p.nodeInfoCache, id)
} else if nodeInfoCopy, err := utils.DeepCopyNodeInfo(cacheItem.NodeInfo); err == nil {
result[id] = nodeInfoCopy
} else {
result[id] = utils.DeepCopyNodeInfo(cacheItem.NodeInfo)
continue
}
}

0 comments on commit 553ccf7

Please sign in to comment.