Skip to content

Commit f0e08c6

Browse files
committed
Coreweave UpdateNodeGroup
needs to return empty slice when nodepools autoscaling is disabled
1 parent 2e528f9 commit f0e08c6

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

cluster-autoscaler/cloudprovider/coreweave/coreweave_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (m *CoreWeaveManager) UpdateNodeGroup() ([]cloudprovider.NodeGroup, error)
122122
// If no node pools are found, return an empty slice
123123
if len(nodepools) == 0 {
124124
klog.Info("No node pools found, returning empty node groups")
125-
return nil, nil
125+
return []cloudprovider.NodeGroup{}, nil
126126
}
127127
klog.V(4).Infof("Found %d node pools", len(nodepools))
128128
m.nodeGroups = make([]cloudprovider.NodeGroup, len(nodepools))

cluster-autoscaler/cloudprovider/coreweave/coreweave_manager_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,36 @@ func TestListNodePools_EmptyList(t *testing.T) {
193193
t.Errorf("expected empty nodepools list, got %d", len(nodePools))
194194
}
195195
}
196+
197+
func TestUpdateNodeGroup_EmptyNodePools(t *testing.T) {
198+
// Create a nodepool with autoscaling disabled - this will result in empty list after filtering
199+
obj := map[string]interface{}{
200+
"apiVersion": coreWeaveGroup + "/" + coreWeaveVersion,
201+
"kind": coreWeaveResource,
202+
"metadata": map[string]interface{}{
203+
"name": "np1",
204+
"namespace": "default",
205+
"uid": "uid1",
206+
},
207+
"spec": map[string]interface{}{
208+
"minNodes": int64(1),
209+
"maxNodes": int64(5),
210+
"targetNodes": int64(3),
211+
"autoscaling": false, // Autoscaling disabled - will be filtered out
212+
},
213+
}
214+
item := unstructured.Unstructured{Object: obj}
215+
manager := makeTestManagerWithNodePools(nil, item)
216+
217+
// UpdateNodeGroup should return empty slice when all nodepools have autoscaling disabled
218+
nodeGroups, err := manager.UpdateNodeGroup()
219+
if err != nil {
220+
t.Errorf("unexpected error: %v", err)
221+
}
222+
if nodeGroups == nil {
223+
t.Error("expected empty slice, got nil")
224+
}
225+
if len(nodeGroups) != 0 {
226+
t.Errorf("expected empty node groups, got %d", len(nodeGroups))
227+
}
228+
}

0 commit comments

Comments
 (0)