@@ -20,10 +20,6 @@ import (
2020 "context"
2121 "encoding/base64"
2222 "fmt"
23- "net"
24- "sort"
25- "time"
26-
2723 asocontainerservicev1 "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20231001"
2824 asocontainerservicev1preview "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20231102preview"
2925 asocontainerservicev1hub "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20240901/storage"
@@ -33,8 +29,10 @@ import (
3329 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3430 "k8s.io/apimachinery/pkg/runtime"
3531 "k8s.io/utils/ptr"
32+ "net"
3633 "sigs.k8s.io/cluster-api/util/secret"
3734 "sigs.k8s.io/controller-runtime/pkg/conversion"
35+ "sort"
3836
3937 infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
4038 "sigs.k8s.io/cluster-api-provider-azure/azure"
@@ -762,57 +760,59 @@ func (s *ManagedClusterSpec) Parameters(ctx context.Context, existingObj genrunt
762760
763761 managedCluster .Spec .AgentPoolProfiles = prevAgentPoolProfiles
764762
765- if existingObj != nil {
766- hub := & asocontainerservicev1hub.ManagedCluster {}
767- if err := existingObj .(conversion.Convertible ).ConvertTo (hub ); err != nil {
768- return nil , err
769- }
770- existingMC := hub
771-
772- ps := * existingMC .Status .ProvisioningState
773- if ps != string (infrav1 .Canceled ) && ps != string (infrav1 .Failed ) && ps != string (infrav1 .Succeeded ) {
774- return nil , azure .WithTransientError (errors .Errorf ("Unable to update existing managed cluster in non-terminal state. Managed cluster must be in one of the following provisioning states: Canceled, Failed, or Succeeded. Actual state: %s" , ps ), 20 * time .Second )
775- }
776-
777- if managedCluster .Spec .AddonProfiles == nil && existingMC .Spec .AddonProfiles != nil {
778- managedCluster .Spec .AddonProfiles = map [string ]asocontainerservicev1hub.ManagedClusterAddonProfile {}
779- }
780-
781- for key , item := range existingMC .Spec .AddonProfiles {
782- if managedCluster .Spec .AddonProfiles == nil {
783- managedCluster .Spec .AddonProfiles = map [string ]asocontainerservicev1hub.ManagedClusterAddonProfile {}
784- }
785-
786- if _ , ok := managedCluster .Spec .AddonProfiles [key ]; ! ok {
787- addonProfile := asocontainerservicev1hub.ManagedClusterAddonProfile {
788- Enabled : item .Enabled ,
789- }
790- if item .Config != nil {
791- addonProfile .Config = item .Config
792- }
793- managedCluster .Spec .AddonProfiles [key ] = addonProfile
794- }
795- }
796-
797- // Normalize the LoadBalancerProfile so the diff below doesn't get thrown off by AKS added properties.
798- if managedCluster .Spec .NetworkProfile .LoadBalancerProfile == nil {
799- // If our LoadBalancerProfile generated by the spec is nil, then don't worry about what AKS has added.
800- existingMC .Spec .NetworkProfile .LoadBalancerProfile = nil
801- } else {
802- // If our LoadBalancerProfile generated by the spec is not nil, then remove the effective outbound IPs from
803- // AKS.
804- existingMC .Spec .NetworkProfile .LoadBalancerProfile .EffectiveOutboundIPs = nil
805- }
806-
807- // Avoid changing agent pool profiles through AMCP and just use the existing agent pool profiles
808- // AgentPool changes are managed through AMMP.
809- managedCluster .Spec .AgentPoolProfiles = existingMC .Spec .AgentPoolProfiles
810-
811- diff := computeDiffOfNormalizedClusters (* managedCluster , * existingMC )
812- if diff == "" {
813- return nil , nil
814- }
815- }
763+ //if existingObj != nil {
764+ // hub := &asocontainerservicev1hub.ManagedCluster{}
765+ // if err := existingObj.(conversion.Convertible).ConvertTo(hub); err != nil {
766+ // return nil, err
767+ // }
768+ // existingMC := hub
769+ //
770+ // if existingMC.Status.ProvisioningState != nil {
771+ // ps := *existingMC.Status.ProvisioningState
772+ // if ps != string(infrav1.Canceled) && ps != string(infrav1.Failed) && ps != string(infrav1.Succeeded) {
773+ // return nil, azure.WithTransientError(errors.Errorf("Unable to update existing managed cluster in non-terminal state. Managed cluster must be in one of the following provisioning states: Canceled, Failed, or Succeeded. Actual state: %s", ps), 20*time.Second)
774+ // }
775+ // }
776+ //
777+ // if managedCluster.Spec.AddonProfiles == nil && existingMC.Spec.AddonProfiles != nil {
778+ // managedCluster.Spec.AddonProfiles = map[string]asocontainerservicev1hub.ManagedClusterAddonProfile{}
779+ // }
780+ //
781+ // for key, item := range existingMC.Spec.AddonProfiles {
782+ // if managedCluster.Spec.AddonProfiles == nil {
783+ // managedCluster.Spec.AddonProfiles = map[string]asocontainerservicev1hub.ManagedClusterAddonProfile{}
784+ // }
785+ //
786+ // if _, ok := managedCluster.Spec.AddonProfiles[key]; !ok {
787+ // addonProfile := asocontainerservicev1hub.ManagedClusterAddonProfile{
788+ // Enabled: item.Enabled,
789+ // }
790+ // if item.Config != nil {
791+ // addonProfile.Config = item.Config
792+ // }
793+ // managedCluster.Spec.AddonProfiles[key] = addonProfile
794+ // }
795+ // }
796+ //
797+ // // Normalize the LoadBalancerProfile so the diff below doesn't get thrown off by AKS added properties.
798+ // if managedCluster.Spec.NetworkProfile.LoadBalancerProfile == nil {
799+ // // If our LoadBalancerProfile generated by the spec is nil, then don't worry about what AKS has added.
800+ // existingMC.Spec.NetworkProfile.LoadBalancerProfile = nil
801+ // } else {
802+ // // If our LoadBalancerProfile generated by the spec is not nil, then remove the effective outbound IPs from
803+ // // AKS.
804+ // existingMC.Spec.NetworkProfile.LoadBalancerProfile.EffectiveOutboundIPs = nil
805+ // }
806+ //
807+ // // Avoid changing agent pool profiles through AMCP and just use the existing agent pool profiles
808+ // // AgentPool changes are managed through AMMP.
809+ // managedCluster.Spec.AgentPoolProfiles = existingMC.Spec.AgentPoolProfiles
810+ //
811+ // diff := computeDiffOfNormalizedClusters(*managedCluster, *existingMC)
812+ // if diff == "" {
813+ // return nil, nil
814+ // }
815+ //}
816816
817817 if s .Preview {
818818 prev := & asocontainerservicev1preview.ManagedCluster {}
0 commit comments