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

Correct code flow of node pools #703

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
21 changes: 11 additions & 10 deletions controller/aks-cluster-config-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -843,18 +843,19 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, config *aksv1.
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 {
clusterSpecCopy.NodePools = append(clusterSpecCopy.NodePools, n)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you changing logic for provisioned clusters by Rancher? In results of this change non-imported clusters won't be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loop iterating over config.NodePools checks if that NodePool is present in upstreamNodePools, which means that no new pool can be added or deleted. This logic seems confusing. Changing this only for Imported cluster seems logical

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updates for NodePools need to work for both rancher managed clusters and imported one. Your change will break this and only imported cluster will be updated.


clusterSpecCopy.NodePools = make([]aksv1.AKSNodePool, 0, len(config.Spec.NodePools))
for _, n := range config.Spec.NodePools {
if _, ok := upstreamNodePools[*n.Name]; ok {
clusterSpecCopy.NodePools = append(clusterSpecCopy.NodePools, n)
}
}
err = aks.UpdateCluster(ctx, &h.azureClients.credentials, h.azureClients.clustersClient, h.azureClients.workplacesClient, clusterSpecCopy, config.Status.Phase)
if err != nil {
return config, fmt.Errorf("failed to update cluster: %v", err)
}
return h.enqueueUpdate(config)
}
err = aks.UpdateCluster(ctx, &h.azureClients.credentials, h.azureClients.clustersClient, h.azureClients.workplacesClient, clusterSpecCopy, config.Status.Phase)
if err != nil {
return config, fmt.Errorf("failed to update cluster: %v", err)
}
return h.enqueueUpdate(config)
}

if config.Spec.NodePools != nil {
Expand Down
Loading