From 460836285d41deb70acbba04a7b98dfb28614b1a Mon Sep 17 00:00:00 2001 From: peaaceChoi Date: Fri, 3 Mar 2023 04:53:50 +0000 Subject: [PATCH 1/2] Delete unused return param --- cluster-autoscaler/core/utils/utils.go | 4 ++-- .../nodeinfosprovider/mixed_nodeinfos_processor.go | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/cluster-autoscaler/core/utils/utils.go b/cluster-autoscaler/core/utils/utils.go index 5f35692acf1e..0a957f7b0e2b 100644 --- a/cluster-autoscaler/core/utils/utils.go +++ b/cluster-autoscaler/core/utils/utils.go @@ -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 diff --git a/cluster-autoscaler/processors/nodeinfosprovider/mixed_nodeinfos_processor.go b/cluster-autoscaler/processors/nodeinfosprovider/mixed_nodeinfos_processor.go index 86df41475ab5..68411d011ac6 100644 --- a/cluster-autoscaler/processors/nodeinfosprovider/mixed_nodeinfos_processor.go +++ b/cluster-autoscaler/processors/nodeinfosprovider/mixed_nodeinfos_processor.go @@ -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,10 +132,9 @@ 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 continue } + result[id] = utils.DeepCopyNodeInfo(cacheItem.NodeInfo) } } From 82e880418178cf81c00acc2884d214786beb30dd Mon Sep 17 00:00:00 2001 From: peaaceChoi Date: Fri, 3 Mar 2023 06:26:38 +0000 Subject: [PATCH 2/2] Fix continue condition --- .../processors/nodeinfosprovider/mixed_nodeinfos_processor.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cluster-autoscaler/processors/nodeinfosprovider/mixed_nodeinfos_processor.go b/cluster-autoscaler/processors/nodeinfosprovider/mixed_nodeinfos_processor.go index 68411d011ac6..2e8f0a800c62 100644 --- a/cluster-autoscaler/processors/nodeinfosprovider/mixed_nodeinfos_processor.go +++ b/cluster-autoscaler/processors/nodeinfosprovider/mixed_nodeinfos_processor.go @@ -132,9 +132,10 @@ func (p *MixedTemplateNodeInfoProvider) Process(ctx *context.AutoscalingContext, if cacheItem, found := p.nodeInfoCache[id]; found { if p.isCacheItemExpired(cacheItem.added) { delete(p.nodeInfoCache, id) + } else { + result[id] = utils.DeepCopyNodeInfo(cacheItem.NodeInfo) continue } - result[id] = utils.DeepCopyNodeInfo(cacheItem.NodeInfo) } }