Skip to content

Commit

Permalink
Cache not to be used to form node-template during scale from zero (#119
Browse files Browse the repository at this point in the history
…) (#127)
  • Loading branch information
himanshu-kun authored Jun 23, 2022
1 parent 5a2a791 commit 18bc9ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions cluster-autoscaler/core/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ func GetNodeInfosForGroups(nodes []*apiv1.Node, nodeInfoCache map[string]*schedu
continue
}

// No good template, check cache of previously running nodes.
if nodeInfoCache != nil {
// No good template, check cache of previously running nodes(only when nodeGrp min size is not zero. This is to avoid scenarios where nodeGrp instanceType is updated,
// but still cached old nodeTemplate is used)
if nodeInfoCache != nil && nodeGroup.MinSize() != 0 {
if nodeInfo, found := nodeInfoCache[id]; found {
if nodeInfoCopy, err := deepCopyNodeInfo(nodeInfo); err == nil {
result[id] = nodeInfoCopy
Expand Down
4 changes: 3 additions & 1 deletion cluster-autoscaler/core/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ func TestGetNodeInfosForGroupsCache(t *testing.T) {
assertEqualNodeCapacities(t, ready2, info.Node())
info, found = res["ng4"]
assert.True(t, found)
assertEqualNodeCapacities(t, ready6, info.Node())
/* The below line is commented , as now the nodeTemplate is not formed from previously ready node of nodegrp
if nodeGrp has min size 0 */
// assertEqualNodeCapacities(t, ready6, info.Node())
}

func assertEqualNodeCapacities(t *testing.T, expected, actual *apiv1.Node) {
Expand Down

0 comments on commit 18bc9ca

Please sign in to comment.