Skip to content

Commit

Permalink
Merge pull request #3631 from mboersma/cp-3612-to-release-1.9
Browse files Browse the repository at this point in the history
[release-1.9] Update CAPI to v1.4.3
  • Loading branch information
k8s-ci-robot authored Jun 20, 2023
2 parents 9b94e27 + 4652e64 commit f42caa3
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 52 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ create-management-cluster: $(KUSTOMIZE) $(ENVSUBST) $(KUBECTL) $(KIND) ## Create
./hack/create-custom-cloud-provider-config.sh

# Deploy CAPI
curl --retry $(CURL_RETRIES) -sSL https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.4.2/cluster-api-components.yaml | $(ENVSUBST) | $(KUBECTL) apply -f -
curl --retry $(CURL_RETRIES) -sSL https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.4.3/cluster-api-components.yaml | $(ENVSUBST) | $(KUBECTL) apply -f -

# Deploy CAPZ
$(KIND) load docker-image $(CONTROLLER_IMG)-$(ARCH):$(TAG) --name=$(KIND_CLUSTER_NAME)
Expand Down
4 changes: 2 additions & 2 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ settings = {
"deploy_cert_manager": True,
"preload_images_for_kind": True,
"kind_cluster_name": "capz",
"capi_version": "v1.4.2",
"cert_manager_version": "v1.11.1",
"capi_version": "v1.4.3",
"cert_manager_version": "v1.12.1",
"kubernetes_version": "v1.24.6",
"aks_kubernetes_version": "v1.24.6",
"flatcar_version": "3374.2.1",
Expand Down
13 changes: 4 additions & 9 deletions azure/scope/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import (
"sigs.k8s.io/cluster-api-provider-azure/util/futures"
"sigs.k8s.io/cluster-api-provider-azure/util/tele"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/controllers/noderefutil"
capierrors "sigs.k8s.io/cluster-api/errors"
"sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/cluster-api/util/conditions"
Expand Down Expand Up @@ -451,22 +450,18 @@ func (m *MachineScope) Role() string {
return infrav1.Node
}

// GetVMID returns the AzureMachine instance id by parsing Spec.FakeProviderID.
// GetVMID returns the AzureMachine instance id by parsing the scope's providerID.
func (m *MachineScope) GetVMID() string {
parsed, err := noderefutil.NewProviderID(m.ProviderID())
resourceID, err := azure.ParseResourceID(m.ProviderID())
if err != nil {
return ""
}
return parsed.ID()
return resourceID.Name
}

// ProviderID returns the AzureMachine providerID from the spec.
func (m *MachineScope) ProviderID() string {
parsed, err := noderefutil.NewProviderID(pointer.StringDeref(m.AzureMachine.Spec.ProviderID, ""))
if err != nil {
return ""
}
return parsed.String()
return pointer.StringDeref(m.AzureMachine.Spec.ProviderID, "")
}

// AvailabilitySetSpec returns the availability set spec for this machine if available.
Expand Down
32 changes: 16 additions & 16 deletions azure/scope/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestMachineScope_Name(t *testing.T) {
Name: "machine-with-a-long-name",
},
Spec: infrav1.AzureMachineSpec{
ProviderID: pointer.String("azure://compute/virtual-machines/machine-name"),
ProviderID: pointer.String("azure:///subscriptions/1234-5678/resourceGroups/my-cluster/providers/Microsoft.Compute/virtualMachines/machine-name"),
OSDisk: infrav1.OSDisk{
OSType: "Windows",
},
Expand Down Expand Up @@ -164,7 +164,7 @@ func TestMachineScope_GetVMID(t *testing.T) {
Name: "not-this-name",
},
Spec: infrav1.AzureMachineSpec{
ProviderID: pointer.String("azure://compute/virtual-machines/machine-name"),
ProviderID: pointer.String("azure:///subscriptions/1234-5678/resourceGroups/my-cluster/providers/Microsoft.Compute/virtualMachines/machine-name"),
},
},
},
Expand Down Expand Up @@ -209,21 +209,21 @@ func TestMachineScope_ProviderID(t *testing.T) {
Name: "not-this-name",
},
Spec: infrav1.AzureMachineSpec{
ProviderID: pointer.String("azure://compute/virtual-machines/machine-name"),
ProviderID: pointer.String("azure:///subscriptions/1234-5678/resourceGroups/my-cluster/providers/Microsoft.Compute/virtualMachines/machine-name"),
},
},
},
want: "azure://compute/virtual-machines/machine-name",
want: "azure:///subscriptions/1234-5678/resourceGroups/my-cluster/providers/Microsoft.Compute/virtualMachines/machine-name",
},
{
name: "returns empty if provider ID is invalid",
name: "returns empty if provider ID is empty",
machineScope: MachineScope{
AzureMachine: &infrav1.AzureMachine{
ObjectMeta: metav1.ObjectMeta{
Name: "machine-name",
},
Spec: infrav1.AzureMachineSpec{
ProviderID: pointer.String("foo"),
ProviderID: pointer.String(""),
},
},
},
Expand Down Expand Up @@ -1725,7 +1725,7 @@ func TestMachineScope_NICSpecs(t *testing.T) {
Name: "machine",
},
Spec: infrav1.AzureMachineSpec{
ProviderID: pointer.String("azure://compute/virtual-machines/machine-name"),
ProviderID: pointer.String("azure:///subscriptions/1234-5678/resourceGroups/my-cluster/providers/Microsoft.Compute/virtualMachines/machine-name"),
NetworkInterfaces: []infrav1.NetworkInterface{{
SubnetName: "subnet1",
PrivateIPConfigs: 1,
Expand Down Expand Up @@ -1829,7 +1829,7 @@ func TestMachineScope_NICSpecs(t *testing.T) {
Name: "machine",
},
Spec: infrav1.AzureMachineSpec{
ProviderID: pointer.String("azure://compute/virtual-machines/machine-name"),
ProviderID: pointer.String("azure:///subscriptions/1234-5678/resourceGroups/my-cluster/providers/Microsoft.Compute/virtualMachines/machine-name"),
NetworkInterfaces: []infrav1.NetworkInterface{{
SubnetName: "subnet1",
PrivateIPConfigs: 1,
Expand Down Expand Up @@ -1945,7 +1945,7 @@ func TestMachineScope_NICSpecs(t *testing.T) {
Name: "machine",
},
Spec: infrav1.AzureMachineSpec{
ProviderID: pointer.String("azure://compute/virtual-machines/machine-name"),
ProviderID: pointer.String("azure:///subscriptions/1234-5678/resourceGroups/my-cluster/providers/Microsoft.Compute/virtualMachines/machine-name"),
NetworkInterfaces: []infrav1.NetworkInterface{{
SubnetName: "subnet1",
PrivateIPConfigs: 1,
Expand Down Expand Up @@ -2049,7 +2049,7 @@ func TestMachineScope_NICSpecs(t *testing.T) {
Name: "machine",
},
Spec: infrav1.AzureMachineSpec{
ProviderID: pointer.String("azure://compute/virtual-machines/machine-name"),
ProviderID: pointer.String("azure:///subscriptions/1234-5678/resourceGroups/my-cluster/providers/Microsoft.Compute/virtualMachines/machine-name"),
NetworkInterfaces: []infrav1.NetworkInterface{{
SubnetName: "subnet1",
PrivateIPConfigs: 1,
Expand Down Expand Up @@ -2160,7 +2160,7 @@ func TestMachineScope_NICSpecs(t *testing.T) {
Name: "machine",
},
Spec: infrav1.AzureMachineSpec{
ProviderID: pointer.String("azure://compute/virtual-machines/machine-name"),
ProviderID: pointer.String("azure:///subscriptions/1234-5678/resourceGroups/my-cluster/providers/Microsoft.Compute/virtualMachines/machine-name"),
NetworkInterfaces: []infrav1.NetworkInterface{{
SubnetName: "subnet1",
PrivateIPConfigs: 1,
Expand Down Expand Up @@ -2267,7 +2267,7 @@ func TestMachineScope_NICSpecs(t *testing.T) {
Name: "machine",
},
Spec: infrav1.AzureMachineSpec{
ProviderID: pointer.String("azure://compute/virtual-machines/machine-name"),
ProviderID: pointer.String("azure:///subscriptions/1234-5678/resourceGroups/my-cluster/providers/Microsoft.Compute/virtualMachines/machine-name"),
NetworkInterfaces: []infrav1.NetworkInterface{{
SubnetName: "subnet1",
PrivateIPConfigs: 1,
Expand Down Expand Up @@ -2374,7 +2374,7 @@ func TestMachineScope_NICSpecs(t *testing.T) {
Name: "machine",
},
Spec: infrav1.AzureMachineSpec{
ProviderID: pointer.String("azure://compute/virtual-machines/machine-name"),
ProviderID: pointer.String("azure:///subscriptions/1234-5678/resourceGroups/my-cluster/providers/Microsoft.Compute/virtualMachines/machine-name"),
NetworkInterfaces: []infrav1.NetworkInterface{{
SubnetName: "subnet1",
PrivateIPConfigs: 1,
Expand Down Expand Up @@ -2482,7 +2482,7 @@ func TestMachineScope_NICSpecs(t *testing.T) {
Name: "machine",
},
Spec: infrav1.AzureMachineSpec{
ProviderID: pointer.String("azure://compute/virtual-machines/machine-name"),
ProviderID: pointer.String("azure:///subscriptions/1234-5678/resourceGroups/my-cluster/providers/Microsoft.Compute/virtualMachines/machine-name"),
NetworkInterfaces: []infrav1.NetworkInterface{
{
SubnetName: "subnet1",
Expand Down Expand Up @@ -2619,7 +2619,7 @@ func TestMachineScope_NICSpecs(t *testing.T) {
Name: "machine",
},
Spec: infrav1.AzureMachineSpec{
ProviderID: pointer.String("azure://compute/virtual-machines/machine-name"),
ProviderID: pointer.String("azure:///subscriptions/1234-5678/resourceGroups/my-cluster/providers/Microsoft.Compute/virtualMachines/machine-name"),
AllocatePublicIP: true,
NetworkInterfaces: []infrav1.NetworkInterface{
{
Expand Down Expand Up @@ -2757,7 +2757,7 @@ func TestMachineScope_NICSpecs(t *testing.T) {
Name: "machine",
},
Spec: infrav1.AzureMachineSpec{
ProviderID: pointer.String("azure://compute/virtual-machines/machine-name"),
ProviderID: pointer.String("azure:///subscriptions/1234-5678/resourceGroups/my-cluster/providers/Microsoft.Compute/virtualMachines/machine-name"),
NetworkInterfaces: []infrav1.NetworkInterface{
{
SubnetName: "subnet1",
Expand Down
7 changes: 3 additions & 4 deletions azure/scope/machinepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
"sigs.k8s.io/cluster-api-provider-azure/util/futures"
"sigs.k8s.io/cluster-api-provider-azure/util/tele"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/controllers/noderefutil"
capierrors "sigs.k8s.io/cluster-api/errors"
expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
"sigs.k8s.io/cluster-api/util/annotations"
Expand Down Expand Up @@ -153,13 +152,13 @@ func (m *MachinePoolScope) Name() string {
return m.AzureMachinePool.Name
}

// ProviderID returns the AzureMachinePool ID by parsing Spec.FakeProviderID.
// ProviderID returns the AzureMachinePool ID by parsing Spec.ProviderID.
func (m *MachinePoolScope) ProviderID() string {
parsed, err := noderefutil.NewProviderID(m.AzureMachinePool.Spec.ProviderID)
resourceID, err := azure.ParseResourceID(m.AzureMachinePool.Spec.ProviderID)
if err != nil {
return ""
}
return parsed.ID()
return resourceID.Name
}

// SetProviderID sets the AzureMachinePool providerID in spec.
Expand Down
74 changes: 74 additions & 0 deletions azure/scope/machinepool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,80 @@ func TestMachinePoolScope_Name(t *testing.T) {
})
}
}

func TestMachinePoolScope_ProviderID(t *testing.T) {
tests := []struct {
name string
machinePoolScope MachinePoolScope
want string
}{
{
name: "valid providerID",
machinePoolScope: MachinePoolScope{
AzureMachinePool: &infrav1exp.AzureMachinePool{
Spec: infrav1exp.AzureMachinePoolSpec{
ProviderID: "azure:///subscriptions/1234/resourcegroups/my-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cloud-provider-user-identity",
},
},
},
want: "cloud-provider-user-identity",
},
{
name: "valid providerID: VMSS Flex instance",
machinePoolScope: MachinePoolScope{
AzureMachinePool: &infrav1exp.AzureMachinePool{
Spec: infrav1exp.AzureMachinePoolSpec{
ProviderID: "azure:///subscriptions/1234/resourceGroups/my-cluster/providers/Microsoft.Compute/virtualMachines/machine-0",
},
},
},
want: "machine-0",
},
{
name: "valid providerID: VMSS Uniform instance",
machinePoolScope: MachinePoolScope{
AzureMachinePool: &infrav1exp.AzureMachinePool{
Spec: infrav1exp.AzureMachinePoolSpec{
ProviderID: "azure:///subscriptions/1234/resourceGroups/my-cluster/providers/Microsoft.Compute/virtualMachineScaleSets/my-cluster-mp-0/virtualMachines/0",
},
},
},
want: "0",
},
{
name: "invalid providerID: no cloud provider",
machinePoolScope: MachinePoolScope{
AzureMachinePool: &infrav1exp.AzureMachinePool{
Spec: infrav1exp.AzureMachinePoolSpec{
ProviderID: "subscriptions/123/resourceGroups/rg/providers/Microsoft.Compute/virtualMachines/vm",
},
},
},
want: "",
},
{
name: "invalid providerID: incomplete URL",
machinePoolScope: MachinePoolScope{
AzureMachinePool: &infrav1exp.AzureMachinePool{
Spec: infrav1exp.AzureMachinePoolSpec{
ProviderID: "azure:///",
},
},
},
want: "",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := tt.machinePoolScope.ProviderID()
if got != tt.want {
t.Errorf("MachinePoolScope.ProviderID() = %v, want %v", got, tt.want)
}
})
}
}

func TestMachinePoolScope_NetworkInterfaces(t *testing.T) {
tests := []struct {
name string
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ require (
k8s.io/kubectl v0.26.1
k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5
sigs.k8s.io/cloud-provider-azure v1.26.7
sigs.k8s.io/cluster-api v1.4.2
sigs.k8s.io/cluster-api/test v1.4.2
sigs.k8s.io/cluster-api v1.4.3
sigs.k8s.io/cluster-api/test v1.4.3
sigs.k8s.io/controller-runtime v0.14.5
sigs.k8s.io/kind v0.18.0
)
Expand Down Expand Up @@ -85,7 +85,7 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
github.com/docker/cli v20.10.21+incompatible // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker v20.10.24+incompatible // indirect
github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/docker/go-connections v0.4.0 // indirect
Expand Down Expand Up @@ -224,4 +224,4 @@ require (
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.4.2
replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.4.3
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ github.com/distribution/distribution/v3 v3.0.0-20221208165359-362910506bc2 h1:aB
github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c=
github.com/docker/cli v20.10.21+incompatible h1:qVkgyYUnOLQ98LtXBrwd/duVqPT2X4SHndOuGsfwyhU=
github.com/docker/cli v20.10.21+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68=
github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v20.10.24+incompatible h1:Ugvxm7a8+Gz6vqQYQQ2W7GYq5EUPaAiuPgIfVyI3dYE=
github.com/docker/docker v20.10.24+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A=
Expand Down Expand Up @@ -1295,10 +1295,10 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
sigs.k8s.io/cloud-provider-azure v1.26.7 h1:LSVRPyxeTQZPOF7z42zNZGzL1S1N5tg28RBZVy7gea4=
sigs.k8s.io/cloud-provider-azure v1.26.7/go.mod h1:UIwr0Bk4wQb77wNL9cdT4zZw6DP2AtOQ9EKRt9c5g7Q=
sigs.k8s.io/cluster-api v1.4.2 h1:hdIz0Ms2j7YaU1qBK5yF2R8ii0GcGb3jQ7EO6i3tAN8=
sigs.k8s.io/cluster-api v1.4.2/go.mod h1:IIebZTsqyXU8CHbINV2zuMh0/wykqdr+vEXxQNeteEU=
sigs.k8s.io/cluster-api/test v1.4.2 h1:uHFtn0SFOFOxIbdahLoYo4kz84yLqCmhbVLV4vsk1gQ=
sigs.k8s.io/cluster-api/test v1.4.2/go.mod h1:/64ycj3YFMW1BGVtCtfwmlVAXGN0DFTZEkIClh68Svo=
sigs.k8s.io/cluster-api v1.4.3 h1:QSeKr3qnWPtVp+EMQZQduKoi5WDwUhAtBRreEukkcy0=
sigs.k8s.io/cluster-api v1.4.3/go.mod h1:/SeFds4NXJ+Gp2etqHyoNuO6yoxTfVq6Zmd2OGxd/qM=
sigs.k8s.io/cluster-api/test v1.4.3 h1:xXhvOLp5zBKn2Yf4PQckFwxGxFrKgkgUI74ikU5Jh/c=
sigs.k8s.io/cluster-api/test v1.4.3/go.mod h1:xGTJsJkbXMNmumhErEAH/e7GmnE2sGfm/rcOzJZSdbw=
sigs.k8s.io/controller-runtime v0.14.5 h1:6xaWFqzT5KuAQ9ufgUaj1G/+C4Y1GRkhrxl+BJ9i+5s=
sigs.k8s.io/controller-runtime v0.14.5/go.mod h1:WqIdsAY6JBsjfc/CqO0CORmNtoCtE4S6qbPc9s68h+0=
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k=
Expand Down
2 changes: 1 addition & 1 deletion hack/install-cert-manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ source "${REPO_ROOT}/hack/common-vars.sh"
make --directory="${REPO_ROOT}" "${KUBECTL##*/}"

## Install cert manager and wait for availability
"${KUBECTL}" apply -f https://github.com/jetstack/cert-manager/releases/download/v1.11.1/cert-manager.yaml
"${KUBECTL}" apply -f https://github.com/jetstack/cert-manager/releases/download/v1.12.1/cert-manager.yaml
"${KUBECTL}" wait --for=condition=Available --timeout=5m -n cert-manager deployment/cert-manager
"${KUBECTL}" wait --for=condition=Available --timeout=5m -n cert-manager deployment/cert-manager-cainjector
"${KUBECTL}" wait --for=condition=Available --timeout=5m -n cert-manager deployment/cert-manager-webhook
Expand Down
Loading

0 comments on commit f42caa3

Please sign in to comment.