Skip to content

Commit e61c5e3

Browse files
committed
fix: no nodeRefs when empty providerIDList is ok
This fixes MachinePool reconciliation when an empty providerIDList is given. Previously it would always return an error in this case, preventing the MachinePool readyReplicas etc. to go to 0.
1 parent f008f26 commit e61c5e3

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

exp/internal/controllers/machinepool_controller_noderef.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ func (r *MachinePoolReconciler) getNodeReferences(ctx context.Context, c client.
221221
}
222222
}
223223

224-
if len(nodeRefs) == 0 {
224+
if len(nodeRefs) == 0 && len(providerIDList) != 0 {
225225
return getNodeReferencesResult{}, errNoAvailableNodes
226226
}
227227
return getNodeReferencesResult{nodeRefs, available, ready}, nil

exp/internal/controllers/machinepool_controller_noderef_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,15 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
128128
expected: nil,
129129
err: errNoAvailableNodes,
130130
},
131+
{
132+
name: "no provider id, no node found",
133+
providerIDList: []string{},
134+
expected: &getNodeReferencesResult{
135+
references: []corev1.ObjectReference{},
136+
available: 0,
137+
ready: 0,
138+
},
139+
},
131140
}
132141

133142
for _, test := range testCases {

0 commit comments

Comments
 (0)