Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.8] Fix for updating imported clusters #302

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions controller/aks-cluster-config-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,12 +754,16 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, config *aksv1.
}
}

// build ClusterSpec for imported clusters from upstream config,
// otherwise ConfigSpec will be null
importedClusterSpec := upstreamSpec.DeepCopy()
updateAksCluster := false
// check Kubernetes version for update
if config.Spec.KubernetesVersion != nil {
if to.String(config.Spec.KubernetesVersion) != to.String(upstreamSpec.KubernetesVersion) {
logrus.Infof("Updating kubernetes version for cluster [%s]", config.Spec.ClusterName)
updateAksCluster = true
importedClusterSpec.KubernetesVersion = config.Spec.KubernetesVersion
}
}

Expand All @@ -768,6 +772,7 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, config *aksv1.
if !reflect.DeepEqual(config.Spec.AuthorizedIPRanges, upstreamSpec.AuthorizedIPRanges) {
logrus.Infof("Updating authorized IP ranges for cluster [%s]", config.Spec.ClusterName)
updateAksCluster = true
importedClusterSpec.AuthorizedIPRanges = config.Spec.AuthorizedIPRanges
}
}

Expand All @@ -776,6 +781,7 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, config *aksv1.
if to.Bool(config.Spec.HTTPApplicationRouting) != to.Bool(upstreamSpec.HTTPApplicationRouting) {
logrus.Infof("Updating HTTP application routing for cluster [%s]", config.Spec.ClusterName)
updateAksCluster = true
importedClusterSpec.HTTPApplicationRouting = config.Spec.HTTPApplicationRouting
}
}

Expand All @@ -784,6 +790,9 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, config *aksv1.
if to.Bool(config.Spec.Monitoring) != to.Bool(upstreamSpec.Monitoring) {
logrus.Infof("Updating monitoring addon for cluster [%s]", config.Spec.ClusterName)
updateAksCluster = true
importedClusterSpec.Monitoring = config.Spec.Monitoring
importedClusterSpec.LogAnalyticsWorkspaceGroup = config.Spec.LogAnalyticsWorkspaceGroup
importedClusterSpec.LogAnalyticsWorkspaceName = config.Spec.LogAnalyticsWorkspaceName
}
}

Expand All @@ -803,6 +812,12 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, config *aksv1.

upstreamNodePools, _ := utils.BuildNodePoolMap(upstreamSpec.NodePools, config.Spec.ClusterName)
clusterSpecCopy := config.Spec.DeepCopy()
if config.Spec.Imported {
clusterSpecCopy = importedClusterSpec
clusterSpecCopy.ResourceGroup = config.Spec.ResourceGroup
clusterSpecCopy.ResourceLocation = config.Spec.ResourceLocation
clusterSpecCopy.ClusterName = config.Spec.ClusterName
}
clusterSpecCopy.NodePools = make([]aksv1.AKSNodePool, 0, len(config.Spec.NodePools))
for _, n := range config.Spec.NodePools {
if _, ok := upstreamNodePools[*n.Name]; ok {
Expand Down