Skip to content

Commit 9d1c610

Browse files
committed
[Tests] Update cluster-api provider to use machineTemplate.status.nodeInfo for architecture-aware autoscale from zero
kubernetes-sigs/cluster-api#11962 introduced the nodeInfo field for MachineTemplates. Providers can reconcile this field in the status subresource to inform the autoscaler about the architecture and operating system that the MachineTemplate's nodes will run. Previously, we have been implementing this behavior in the cluster autoscaler by leveraging the labels capacity annotation and, as a fallback, default values set in environment variables at cluster-autoscaler deployment time. With this commit, the cluster autoscaler computes the future architecture of a node with the following priority order: - Labels set in existing nodes for not-autoscale-from-zero cases - Labels set in the labels capacity annotation of machine template, machine set, and machine deployment. - Values in the status.nodeSystemInfo of MachineTemplates - Generic/default labels set in the environment of the cluster autoscaler
1 parent ed43258 commit 9d1c610

File tree

5 files changed

+213
-97
lines changed

5 files changed

+213
-97
lines changed

cluster-autoscaler/cloudprovider/clusterapi/clusterapi_autodiscovery_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,17 +204,17 @@ func Test_allowedByAutoDiscoverySpec(t *testing.T) {
204204
shouldMatch bool
205205
}{{
206206
name: "no clustername, namespace, or label selector specified should match any MachineSet",
207-
testSpec: createTestSpec(RandomString(6), RandomString(6), RandomString(6), 1, false, nil, nil),
207+
testSpec: createTestSpec(RandomString(6), RandomString(6), RandomString(6), 1, false, nil, nil, nil),
208208
autoDiscoveryConfig: &clusterAPIAutoDiscoveryConfig{labelSelector: labels.NewSelector()},
209209
shouldMatch: true,
210210
}, {
211211
name: "no clustername, namespace, or label selector specified should match any MachineDeployment",
212-
testSpec: createTestSpec(RandomString(6), RandomString(6), RandomString(6), 1, true, nil, nil),
212+
testSpec: createTestSpec(RandomString(6), RandomString(6), RandomString(6), 1, true, nil, nil, nil),
213213
autoDiscoveryConfig: &clusterAPIAutoDiscoveryConfig{labelSelector: labels.NewSelector()},
214214
shouldMatch: true,
215215
}, {
216216
name: "clustername specified does not match MachineSet, namespace matches, no labels specified",
217-
testSpec: createTestSpec("default", RandomString(6), RandomString(6), 1, false, nil, nil),
217+
testSpec: createTestSpec("default", RandomString(6), RandomString(6), 1, false, nil, nil, nil),
218218
autoDiscoveryConfig: &clusterAPIAutoDiscoveryConfig{
219219
clusterName: "foo",
220220
namespace: "default",
@@ -223,7 +223,7 @@ func Test_allowedByAutoDiscoverySpec(t *testing.T) {
223223
shouldMatch: false,
224224
}, {
225225
name: "clustername specified does not match MachineDeployment, namespace matches, no labels specified",
226-
testSpec: createTestSpec("default", RandomString(6), RandomString(6), 1, true, nil, nil),
226+
testSpec: createTestSpec("default", RandomString(6), RandomString(6), 1, true, nil, nil, nil),
227227
autoDiscoveryConfig: &clusterAPIAutoDiscoveryConfig{
228228
clusterName: "foo",
229229
namespace: "default",
@@ -232,7 +232,7 @@ func Test_allowedByAutoDiscoverySpec(t *testing.T) {
232232
shouldMatch: false,
233233
}, {
234234
name: "namespace specified does not match MachineSet, clusterName matches, no labels specified",
235-
testSpec: createTestSpec(RandomString(6), "foo", RandomString(6), 1, false, nil, nil),
235+
testSpec: createTestSpec(RandomString(6), "foo", RandomString(6), 1, false, nil, nil, nil),
236236
autoDiscoveryConfig: &clusterAPIAutoDiscoveryConfig{
237237
clusterName: "foo",
238238
namespace: "default",
@@ -241,7 +241,7 @@ func Test_allowedByAutoDiscoverySpec(t *testing.T) {
241241
shouldMatch: false,
242242
}, {
243243
name: "clustername specified does not match MachineDeployment, namespace matches, no labels specified",
244-
testSpec: createTestSpec(RandomString(6), "foo", RandomString(6), 1, true, nil, nil),
244+
testSpec: createTestSpec(RandomString(6), "foo", RandomString(6), 1, true, nil, nil, nil),
245245
autoDiscoveryConfig: &clusterAPIAutoDiscoveryConfig{
246246
clusterName: "foo",
247247
namespace: "default",
@@ -250,7 +250,7 @@ func Test_allowedByAutoDiscoverySpec(t *testing.T) {
250250
shouldMatch: false,
251251
}, {
252252
name: "namespace and clusterName matches MachineSet, no labels specified",
253-
testSpec: createTestSpec("default", "foo", RandomString(6), 1, false, nil, nil),
253+
testSpec: createTestSpec("default", "foo", RandomString(6), 1, false, nil, nil, nil),
254254
autoDiscoveryConfig: &clusterAPIAutoDiscoveryConfig{
255255
clusterName: "foo",
256256
namespace: "default",
@@ -259,7 +259,7 @@ func Test_allowedByAutoDiscoverySpec(t *testing.T) {
259259
shouldMatch: true,
260260
}, {
261261
name: "namespace and clusterName matches MachineDeployment, no labels specified",
262-
testSpec: createTestSpec("default", "foo", RandomString(6), 1, true, nil, nil),
262+
testSpec: createTestSpec("default", "foo", RandomString(6), 1, true, nil, nil, nil),
263263
autoDiscoveryConfig: &clusterAPIAutoDiscoveryConfig{
264264
clusterName: "foo",
265265
namespace: "default",
@@ -268,7 +268,7 @@ func Test_allowedByAutoDiscoverySpec(t *testing.T) {
268268
shouldMatch: true,
269269
}, {
270270
name: "namespace and clusterName matches MachineSet, does not match label selector",
271-
testSpec: createTestSpec("default", "foo", RandomString(6), 1, false, nil, nil),
271+
testSpec: createTestSpec("default", "foo", RandomString(6), 1, false, nil, nil, nil),
272272
autoDiscoveryConfig: &clusterAPIAutoDiscoveryConfig{
273273
clusterName: "foo",
274274
namespace: "default",
@@ -277,7 +277,7 @@ func Test_allowedByAutoDiscoverySpec(t *testing.T) {
277277
shouldMatch: false,
278278
}, {
279279
name: "namespace and clusterName matches MachineDeployment, does not match label selector",
280-
testSpec: createTestSpec("default", "foo", RandomString(6), 1, true, nil, nil),
280+
testSpec: createTestSpec("default", "foo", RandomString(6), 1, true, nil, nil, nil),
281281
autoDiscoveryConfig: &clusterAPIAutoDiscoveryConfig{
282282
clusterName: "foo",
283283
namespace: "default",
@@ -286,7 +286,7 @@ func Test_allowedByAutoDiscoverySpec(t *testing.T) {
286286
shouldMatch: false,
287287
}, {
288288
name: "namespace, clusterName, and label selector matches MachineSet",
289-
testSpec: createTestSpec("default", "foo", RandomString(6), 1, false, nil, nil),
289+
testSpec: createTestSpec("default", "foo", RandomString(6), 1, false, nil, nil, nil),
290290
additionalLabels: map[string]string{"color": "green"},
291291
autoDiscoveryConfig: &clusterAPIAutoDiscoveryConfig{
292292
clusterName: "foo",
@@ -296,7 +296,7 @@ func Test_allowedByAutoDiscoverySpec(t *testing.T) {
296296
shouldMatch: true,
297297
}, {
298298
name: "namespace, clusterName, and label selector matches MachineDeployment",
299-
testSpec: createTestSpec("default", "foo", RandomString(6), 1, true, nil, nil),
299+
testSpec: createTestSpec("default", "foo", RandomString(6), 1, true, nil, nil, nil),
300300
additionalLabels: map[string]string{"color": "green"},
301301
autoDiscoveryConfig: &clusterAPIAutoDiscoveryConfig{
302302
clusterName: "foo",

0 commit comments

Comments
 (0)