Skip to content

Commit

Permalink
Merge pull request #3772 from k8s-infra-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…3766-to-release-1.9

[release-1.9] fix bug preventing AKS autoscaling from being disabled
  • Loading branch information
k8s-ci-robot authored Jul 27, 2023
2 parents 15ebbf3 + 46ad58c commit 9002211
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion azure/scope/managedmachinepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func buildAgentPoolSpec(managedControlPlane *infrav1.AzureManagedControlPlane,
}

if managedMachinePool.Spec.Scaling != nil {
agentPoolSpec.EnableAutoScaling = pointer.Bool(true)
agentPoolSpec.EnableAutoScaling = true
agentPoolSpec.MaxCount = managedMachinePool.Spec.Scaling.MaxSize
agentPoolSpec.MinCount = managedMachinePool.Spec.Scaling.MinSize
}
Expand Down
2 changes: 1 addition & 1 deletion azure/scope/managedmachinepool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestManagedMachinePoolScope_Autoscaling(t *testing.T) {
Mode: "User",
Cluster: "cluster1",
Replicas: 1,
EnableAutoScaling: pointer.Bool(true),
EnableAutoScaling: true,
MinCount: pointer.Int32(2),
MaxCount: pointer.Int32(10),
VnetSubnetID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups//providers/Microsoft.Network/virtualNetworks//subnets/",
Expand Down
8 changes: 4 additions & 4 deletions azure/services/agentpools/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ type AgentPoolSpec struct {
NodeTaints []string `json:"nodeTaints,omitempty"`

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

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

Expand Down Expand Up @@ -339,7 +339,7 @@ func (s *AgentPoolSpec) Parameters(ctx context.Context, existing interface{}) (p
ManagedClusterAgentPoolProfileProperties: &containerservice.ManagedClusterAgentPoolProfileProperties{
AvailabilityZones: availabilityZones,
Count: &s.Replicas,
EnableAutoScaling: s.EnableAutoScaling,
EnableAutoScaling: pointer.Bool(s.EnableAutoScaling),
EnableUltraSSD: s.EnableUltraSSD,
KubeletConfig: kubeletConfig,
KubeletDiskType: containerservice.KubeletDiskType(pointer.StringDeref((*string)(s.KubeletDiskType), "")),
Expand Down
4 changes: 2 additions & 2 deletions azure/services/agentpools/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func fakeAgentPool(changes ...func(*AgentPoolSpec)) AgentPoolSpec {
ResourceGroup: "fake-rg",
Cluster: "fake-cluster",
AvailabilityZones: []string{"fake-zone"},
EnableAutoScaling: pointer.Bool(true),
EnableAutoScaling: true,
EnableUltraSSD: pointer.Bool(true),
KubeletDiskType: (*infrav1.KubeletDiskType)(pointer.String("fake-kubelet-disk-type")),
MaxCount: pointer.Int32(5),
Expand Down Expand Up @@ -72,7 +72,7 @@ func withReplicas(replicas int32) func(*AgentPoolSpec) {

func withAutoscaling(enabled bool) func(*AgentPoolSpec) {
return func(pool *AgentPoolSpec) {
pool.EnableAutoScaling = pointer.Bool(enabled)
pool.EnableAutoScaling = enabled
}
}

Expand Down
2 changes: 2 additions & 0 deletions azure/services/managedclusters/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ func getSampleManagedCluster() containerservice.ManagedCluster {
Tags: map[string]*string{
"test-tag": pointer.String("test-value"),
},
EnableAutoScaling: pointer.Bool(false),
},
{
Name: pointer.String("test-agentpool-1"),
Expand All @@ -241,6 +242,7 @@ func getSampleManagedCluster() containerservice.ManagedCluster {
Tags: map[string]*string{
"test-tag": pointer.String("test-value"),
},
EnableAutoScaling: pointer.Bool(false),
},
},
LinuxProfile: &containerservice.LinuxProfile{
Expand Down
2 changes: 1 addition & 1 deletion controllers/azuremanagedmachinepool_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func fakeAgentPool(changes ...func(*agentpools.AgentPoolSpec)) agentpools.AgentP
ResourceGroup: "fake-rg",
Cluster: "fake-cluster",
AvailabilityZones: []string{"fake-zone"},
EnableAutoScaling: pointer.Bool(true),
EnableAutoScaling: true,
EnableUltraSSD: pointer.Bool(true),
KubeletDiskType: (*infrav1.KubeletDiskType)(pointer.String("fake-kubelet-disk-type")),
MaxCount: pointer.Int32(5),
Expand Down

0 comments on commit 9002211

Please sign in to comment.