Skip to content

Commit 9002211

Browse files
authored
Merge pull request #3772 from k8s-infra-cherrypick-robot/cherry-pick-3766-to-release-1.9
[release-1.9] fix bug preventing AKS autoscaling from being disabled
2 parents 15ebbf3 + 46ad58c commit 9002211

File tree

6 files changed

+11
-9
lines changed

6 files changed

+11
-9
lines changed

azure/scope/managedmachinepool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ func buildAgentPoolSpec(managedControlPlane *infrav1.AzureManagedControlPlane,
207207
}
208208

209209
if managedMachinePool.Spec.Scaling != nil {
210-
agentPoolSpec.EnableAutoScaling = pointer.Bool(true)
210+
agentPoolSpec.EnableAutoScaling = true
211211
agentPoolSpec.MaxCount = managedMachinePool.Spec.Scaling.MaxSize
212212
agentPoolSpec.MinCount = managedMachinePool.Spec.Scaling.MinSize
213213
}

azure/scope/managedmachinepool_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func TestManagedMachinePoolScope_Autoscaling(t *testing.T) {
108108
Mode: "User",
109109
Cluster: "cluster1",
110110
Replicas: 1,
111-
EnableAutoScaling: pointer.Bool(true),
111+
EnableAutoScaling: true,
112112
MinCount: pointer.Int32(2),
113113
MaxCount: pointer.Int32(10),
114114
VnetSubnetID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups//providers/Microsoft.Network/virtualNetworks//subnets/",

azure/services/agentpools/spec.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ type AgentPoolSpec struct {
100100
NodeTaints []string `json:"nodeTaints,omitempty"`
101101

102102
// EnableAutoScaling - Whether to enable auto-scaler
103-
EnableAutoScaling *bool `json:"enableAutoScaling,omitempty"`
103+
EnableAutoScaling bool `json:"enableAutoScaling,omitempty"`
104104

105105
// AvailabilityZones represents the Availability zones for nodes in the AgentPool.
106106
AvailabilityZones []string
@@ -202,7 +202,7 @@ func (s *AgentPoolSpec) Parameters(ctx context.Context, existing interface{}) (p
202202
Count: &s.Replicas,
203203
OrchestratorVersion: s.Version,
204204
Mode: containerservice.AgentPoolMode(s.Mode),
205-
EnableAutoScaling: s.EnableAutoScaling,
205+
EnableAutoScaling: pointer.Bool(s.EnableAutoScaling),
206206
MinCount: s.MinCount,
207207
MaxCount: s.MaxCount,
208208
NodeLabels: s.NodeLabels,
@@ -233,7 +233,7 @@ func (s *AgentPoolSpec) Parameters(ctx context.Context, existing interface{}) (p
233233
// When autoscaling is set, the count of the nodes differ based on the autoscaler and should not depend on the
234234
// count present in MachinePool or AzureManagedMachinePool, hence we should not make an update API call based
235235
// on difference in count.
236-
if pointer.BoolDeref(s.EnableAutoScaling, false) {
236+
if s.EnableAutoScaling {
237237
normalizedProfile.Count = existingProfile.Count
238238
}
239239

@@ -339,7 +339,7 @@ func (s *AgentPoolSpec) Parameters(ctx context.Context, existing interface{}) (p
339339
ManagedClusterAgentPoolProfileProperties: &containerservice.ManagedClusterAgentPoolProfileProperties{
340340
AvailabilityZones: availabilityZones,
341341
Count: &s.Replicas,
342-
EnableAutoScaling: s.EnableAutoScaling,
342+
EnableAutoScaling: pointer.Bool(s.EnableAutoScaling),
343343
EnableUltraSSD: s.EnableUltraSSD,
344344
KubeletConfig: kubeletConfig,
345345
KubeletDiskType: containerservice.KubeletDiskType(pointer.StringDeref((*string)(s.KubeletDiskType), "")),

azure/services/agentpools/spec_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func fakeAgentPool(changes ...func(*AgentPoolSpec)) AgentPoolSpec {
3737
ResourceGroup: "fake-rg",
3838
Cluster: "fake-cluster",
3939
AvailabilityZones: []string{"fake-zone"},
40-
EnableAutoScaling: pointer.Bool(true),
40+
EnableAutoScaling: true,
4141
EnableUltraSSD: pointer.Bool(true),
4242
KubeletDiskType: (*infrav1.KubeletDiskType)(pointer.String("fake-kubelet-disk-type")),
4343
MaxCount: pointer.Int32(5),
@@ -72,7 +72,7 @@ func withReplicas(replicas int32) func(*AgentPoolSpec) {
7272

7373
func withAutoscaling(enabled bool) func(*AgentPoolSpec) {
7474
return func(pool *AgentPoolSpec) {
75-
pool.EnableAutoScaling = pointer.Bool(enabled)
75+
pool.EnableAutoScaling = enabled
7676
}
7777
}
7878

azure/services/managedclusters/spec_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ func getSampleManagedCluster() containerservice.ManagedCluster {
226226
Tags: map[string]*string{
227227
"test-tag": pointer.String("test-value"),
228228
},
229+
EnableAutoScaling: pointer.Bool(false),
229230
},
230231
{
231232
Name: pointer.String("test-agentpool-1"),
@@ -241,6 +242,7 @@ func getSampleManagedCluster() containerservice.ManagedCluster {
241242
Tags: map[string]*string{
242243
"test-tag": pointer.String("test-value"),
243244
},
245+
EnableAutoScaling: pointer.Bool(false),
244246
},
245247
},
246248
LinuxProfile: &containerservice.LinuxProfile{

controllers/azuremanagedmachinepool_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func fakeAgentPool(changes ...func(*agentpools.AgentPoolSpec)) agentpools.AgentP
263263
ResourceGroup: "fake-rg",
264264
Cluster: "fake-cluster",
265265
AvailabilityZones: []string{"fake-zone"},
266-
EnableAutoScaling: pointer.Bool(true),
266+
EnableAutoScaling: true,
267267
EnableUltraSSD: pointer.Bool(true),
268268
KubeletDiskType: (*infrav1.KubeletDiskType)(pointer.String("fake-kubelet-disk-type")),
269269
MaxCount: pointer.Int32(5),

0 commit comments

Comments
 (0)