Skip to content

Commit 8776548

Browse files
authored
Merge pull request #818 from alexeldeib/ace/mc
🐛 normalize version in managed control plane
2 parents 47524f2 + 38303cf commit 8776548

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

config/crd/bases/exp.infrastructure.cluster.x-k8s.io_azuremanagedcontrolplanes.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ spec:
107107
version:
108108
description: Version defines the desired Kubernetes version.
109109
minLength: 2
110-
pattern: ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)([-0-9a-zA-Z_\.+]*)?$
111110
type: string
112111
required:
113112
- defaultPoolRef

exp/api/v1alpha3/azuremanagedcontrolplane_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
type AzureManagedControlPlaneSpec struct {
2727
// Version defines the desired Kubernetes version.
2828
// +kubebuilder:validation:MinLength:=2
29-
// +kubebuilder:validation:Pattern:=^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)([-0-9a-zA-Z_\.+]*)?$
3029
Version string `json:"version"`
3130

3231
// ResourceGroup is the name of the Azure resource group for this AKS Cluster.

exp/controllers/azuremanagedmachinepool_reconciler.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package controllers
1919
import (
2020
"context"
2121
"fmt"
22+
"strings"
2223

2324
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2020-06-01/compute"
2425
"github.com/pkg/errors"
@@ -54,13 +55,20 @@ func newAzureManagedMachinePoolReconciler(scope *scope.ManagedControlPlaneScope)
5455
// Reconcile reconciles all the services in pre determined order
5556
func (r *azureManagedMachinePoolReconciler) Reconcile(ctx context.Context, scope *scope.ManagedControlPlaneScope) error {
5657
scope.Logger.Info("reconciling machine pool")
58+
59+
var normalizedVersion *string
60+
if scope.MachinePool.Spec.Template.Spec.Version != nil {
61+
v := strings.TrimPrefix(*scope.MachinePool.Spec.Template.Spec.Version, "v")
62+
normalizedVersion = &v
63+
}
64+
5765
agentPoolSpec := &agentpools.Spec{
5866
Name: scope.InfraMachinePool.Name,
5967
ResourceGroup: scope.ControlPlane.Spec.ResourceGroup,
6068
Cluster: scope.ControlPlane.Name,
6169
SKU: scope.InfraMachinePool.Spec.SKU,
6270
Replicas: 1,
63-
Version: scope.MachinePool.Spec.Template.Spec.Version,
71+
Version: normalizedVersion,
6472
}
6573

6674
if scope.InfraMachinePool.Spec.OSDiskSizeGB != nil {

exp/controllers/helpers.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ func AzureManagedClusterToAzureManagedControlPlaneMapper(c client.Client, log lo
174174
return nil
175175
}
176176

177+
if cluster == nil {
178+
log.Error(err, "cluster has not set owner ref yet")
179+
return nil
180+
}
181+
177182
ref := cluster.Spec.ControlPlaneRef
178183
if ref == nil || ref.Name == "" {
179184
return nil

0 commit comments

Comments
 (0)