Skip to content

Commit

Permalink
fix version issue for auto upgraded clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
LochanRn committed Sep 28, 2023
1 parent 5a53d64 commit c74584d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion azure/services/agentpools/agentpools.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ import (
"github.com/Azure/go-autorest/autorest/to"
"github.com/google/go-cmp/cmp"
"github.com/pkg/errors"
"k8s.io/utils/ptr"
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-azure/azure"
"sigs.k8s.io/cluster-api-provider-azure/azure/converters"
"sigs.k8s.io/cluster-api-provider-azure/util/maps"
"sigs.k8s.io/cluster-api-provider-azure/util/tele"
"sigs.k8s.io/cluster-api-provider-azure/util/versions"
)

const serviceName = "agentpools"
Expand Down Expand Up @@ -105,6 +107,14 @@ func (s *Service) Reconcile(ctx context.Context) error {
log.V(2).Info(msg)
return azure.WithTransientError(errors.New(msg), 20*time.Second)
}
// Get the higher version out of the existing and new version
profileOrchestratorVersion, err := versions.GetHigherK8sVersion(
ptr.Deref(existingPool.OrchestratorVersion, ""),
ptr.Deref(profile.OrchestratorVersion, ""))

if err != nil {
return errors.Wrap(err, "error while calculating k8s version")
}

// Normalize individual agent pools to diff in case we need to update
existingProfile := containerservice.AgentPool{
Expand All @@ -122,7 +132,7 @@ func (s *Service) Reconcile(ctx context.Context) error {
normalizedProfile := containerservice.AgentPool{
ManagedClusterAgentPoolProfileProperties: &containerservice.ManagedClusterAgentPoolProfileProperties{
Count: profile.Count,
OrchestratorVersion: profile.OrchestratorVersion,
OrchestratorVersion: &profileOrchestratorVersion,
Mode: profile.Mode,
EnableAutoScaling: profile.EnableAutoScaling,
MinCount: profile.MinCount,
Expand Down

0 comments on commit c74584d

Please sign in to comment.