Skip to content

Commit

Permalink
fix managed cluster diff so aks added fields are omitted
Browse files Browse the repository at this point in the history
  • Loading branch information
devigned committed Oct 27, 2021
1 parent e56a316 commit 345fdb6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions azure/services/managedclusters/managedclusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ func (s *Service) Reconcile(ctx context.Context) error {
Name: containerservice.ManagedClusterSKUNameBasic,
Tier: tierName,
}
} else {
// Add the default sku so that the diff will match if no sku is specified by the spec.
managedCluster.Sku = &containerservice.ManagedClusterSKU{
Name: containerservice.ManagedClusterSKUNameBasic,
Tier: containerservice.ManagedClusterSKUTierFree,
}
}

if managedClusterSpec.LoadBalancerProfile != nil {
Expand Down Expand Up @@ -303,6 +309,16 @@ func (s *Service) Reconcile(ctx context.Context) error {
return errors.New(msg)
}

// Normalize the LoadBalancerProfile so the diff below doesn't get thrown off by AKS added properties.
if managedCluster.NetworkProfile.LoadBalancerProfile == nil {
// If our LoadBalancerProfile generated by the spec is nil, then don't worry about what AKS has added.
existingMC.NetworkProfile.LoadBalancerProfile = nil
} else {
// If our LoadBalancerProfile generated by the spec is not nil, then remove the effective outbound IPs from
// AKS.
existingMC.NetworkProfile.LoadBalancerProfile.EffectiveOutboundIPs = nil
}

diff := computeDiffOfNormalizedClusters(managedCluster, existingMC)
if diff != "" {
klog.V(2).Infof("Update required (+new -old):\n%s", diff)
Expand Down

0 comments on commit 345fdb6

Please sign in to comment.