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

[backport][v2.10] Prevent the cluster status from becoming active prematurely #875

Open
wants to merge 1 commit into
base: release-v2.10
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions controller/aks-cluster-config-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,10 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, config *aksv1.
// check tags for update
if config.Spec.Tags != nil {
if !reflect.DeepEqual(config.Spec.Tags, upstreamSpec.Tags) {
// If status is not updating, then enqueue the update ( to re-enter the onChange handler )
if config.Status.Phase != aksConfigUpdatingPhase {
return h.enqueueUpdate(config)
}
logrus.Infof("Updating tags for cluster [%s (id: %s)]", config.Spec.ClusterName, config.Name)
logrus.Debugf("config: %v; upstream: %v", config.Spec.Tags, upstreamSpec.Tags)
tags := armcontainerservice.TagsObject{
Expand Down Expand Up @@ -849,6 +853,10 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, config *aksv1.
}

if updateAksCluster {
// If status is not updating, then enqueue the update ( to re-enter the onChange handler )
if config.Status.Phase != aksConfigUpdatingPhase {
return h.enqueueUpdate(config)
}
resourceGroupExists, err := aks.ExistsResourceGroup(ctx, h.azureClients.resourceGroupsClient, config.Spec.ResourceGroup)
if err != nil && strings.Contains(err.Error(), "unauthorized") {
logrus.Infof("User does not have permissions to access resource group [%s]: %s", config.Spec.ResourceGroup, err)
Expand Down Expand Up @@ -969,6 +977,10 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, config *aksv1.
}

if updateNodePool {
// If status is not updating, then enqueue the update ( to re-enter the onChange handler )
if config.Status.Phase != aksConfigUpdatingPhase {
return h.enqueueUpdate(config)
}
err = aks.CreateOrUpdateAgentPool(ctx, h.azureClients.agentPoolsClient, &config.Spec, np)
if err != nil {
return config, fmt.Errorf("failed to update cluster [%s (id: %s)]: %v", config.Spec.ClusterName, config.Name, err)
Expand All @@ -992,6 +1004,10 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, config *aksv1.
return config, fmt.Errorf("cannot remove node pool [%s] with mode System from cluster [%s (id: %s)]", npName, config.Spec.ClusterName, config.Name)
}
}
// If status is not updating, then enqueue the update ( to re-enter the onChange handler )
if config.Status.Phase != aksConfigUpdatingPhase {
return h.enqueueUpdate(config)
}
logrus.Infof("Removing node pool [%s] from cluster [%s (id: %s)]", npName, config.Spec.ClusterName, config.Name)
err = aks.RemoveAgentPool(ctx, h.azureClients.agentPoolsClient, &config.Spec, upstreamNodePools[npName])
if err != nil {
Expand Down
Loading