Skip to content

Commit 420c741

Browse files
authored
Merge pull request #5057 from mboersma/capi-one-eight-oh
Bump CAPI to v1.8.1
2 parents 2e3a57b + 57b3d4c commit 420c741

17 files changed

+242
-239
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ create-management-cluster: $(KUSTOMIZE) $(ENVSUBST) $(KUBECTL) $(KIND) ## Create
312312
./hack/create-custom-cloud-provider-config.sh
313313

314314
# Deploy CAPI
315-
timeout --foreground 300 bash -c "until curl --retry $(CURL_RETRIES) -sSL https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.7.5/cluster-api-components.yaml | $(ENVSUBST) | $(KUBECTL) apply -f -; do sleep 5; done"
315+
timeout --foreground 300 bash -c "until curl --retry $(CURL_RETRIES) -sSL https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.8.1/cluster-api-components.yaml | $(ENVSUBST) | $(KUBECTL) apply -f -; do sleep 5; done"
316316

317317
# Deploy CAAPH
318318
timeout --foreground 300 bash -c "until curl --retry $(CURL_RETRIES) -sSL https://github.com/kubernetes-sigs/cluster-api-addon-provider-helm/releases/download/v0.2.5/addon-components.yaml | $(ENVSUBST) | $(KUBECTL) apply -f -; do sleep 5; done"

Tiltfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ settings = {
2020
"deploy_cert_manager": True,
2121
"preload_images_for_kind": True,
2222
"kind_cluster_name": "capz",
23-
"capi_version": "v1.7.5",
23+
"capi_version": "v1.8.1",
2424
"caaph_version": "v0.2.5",
2525
"cert_manager_version": "v1.15.2",
2626
"kubernetes_version": "v1.28.3",

api/v1beta1/azuremanagedcluster_webhook_test.go

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
. "github.com/onsi/gomega"
2323
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2424
utilfeature "k8s.io/component-base/featuregate/testing"
25+
"k8s.io/utils/ptr"
2526
"sigs.k8s.io/cluster-api-provider-azure/feature"
2627
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2728
capifeature "sigs.k8s.io/cluster-api/feature"
@@ -135,27 +136,29 @@ func TestAzureManagedCluster_ValidateCreate(t *testing.T) {
135136

136137
func TestAzureManagedCluster_ValidateCreateFailure(t *testing.T) {
137138
tests := []struct {
138-
name string
139-
amc *AzureManagedCluster
140-
deferFunc func()
141-
expectError bool
139+
name string
140+
amc *AzureManagedCluster
141+
featureGateEnabled *bool
142+
expectError bool
142143
}{
143144
{
144-
name: "feature gate explicitly disabled",
145-
amc: getKnownValidAzureManagedCluster(),
146-
deferFunc: utilfeature.SetFeatureGateDuringTest(t, feature.Gates, capifeature.MachinePool, false),
147-
expectError: true,
145+
name: "feature gate explicitly disabled",
146+
amc: getKnownValidAzureManagedCluster(),
147+
featureGateEnabled: ptr.To(false),
148+
expectError: true,
148149
},
149150
{
150-
name: "feature gate implicitly enabled",
151-
amc: getKnownValidAzureManagedCluster(),
152-
deferFunc: func() {},
153-
expectError: false,
151+
name: "feature gate implicitly enabled",
152+
amc: getKnownValidAzureManagedCluster(),
153+
featureGateEnabled: nil,
154+
expectError: false,
154155
},
155156
}
156157
for _, tc := range tests {
157158
t.Run(tc.name, func(t *testing.T) {
158-
defer tc.deferFunc()
159+
if tc.featureGateEnabled != nil {
160+
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, capifeature.MachinePool, *tc.featureGateEnabled)()
161+
}
159162
g := NewWithT(t)
160163
_, err := tc.amc.ValidateCreate()
161164
if tc.expectError {

api/v1beta1/azuremanagedcontrolplane_webhook_test.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,29 +1662,31 @@ func TestAzureManagedControlPlane_ValidateCreate(t *testing.T) {
16621662

16631663
func TestAzureManagedControlPlane_ValidateCreateFailure(t *testing.T) {
16641664
tests := []struct {
1665-
name string
1666-
amcp *AzureManagedControlPlane
1667-
deferFunc func()
1668-
expectError bool
1665+
name string
1666+
amcp *AzureManagedControlPlane
1667+
featureGateEnabled *bool
1668+
expectError bool
16691669
}{
16701670
{
1671-
name: "feature gate explicitly disabled",
1672-
amcp: getKnownValidAzureManagedControlPlane(),
1673-
deferFunc: utilfeature.SetFeatureGateDuringTest(t, feature.Gates, capifeature.MachinePool, false),
1674-
expectError: true,
1671+
name: "feature gate explicitly disabled",
1672+
amcp: getKnownValidAzureManagedControlPlane(),
1673+
featureGateEnabled: ptr.To(false),
1674+
expectError: true,
16751675
},
16761676
{
1677-
name: "feature gate implicitly enabled",
1678-
amcp: getKnownValidAzureManagedControlPlane(),
1679-
deferFunc: func() {},
1680-
expectError: false,
1677+
name: "feature gate implicitly enabled",
1678+
amcp: getKnownValidAzureManagedControlPlane(),
1679+
featureGateEnabled: nil,
1680+
expectError: false,
16811681
},
16821682
}
16831683
client := mockClient{ReturnError: false}
16841684
for _, tc := range tests {
16851685
t.Run(tc.name, func(t *testing.T) {
16861686
g := NewWithT(t)
1687-
defer tc.deferFunc()
1687+
if tc.featureGateEnabled != nil {
1688+
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, capifeature.MachinePool, *tc.featureGateEnabled)()
1689+
}
16881690
mcpw := &azureManagedControlPlaneWebhook{
16891691
Client: client,
16901692
}

api/v1beta1/azuremanagedmachinepool_webhook_test.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,27 +1307,29 @@ func TestAzureManagedMachinePool_ValidateCreate(t *testing.T) {
13071307

13081308
func TestAzureManagedMachinePool_ValidateCreateFailure(t *testing.T) {
13091309
tests := []struct {
1310-
name string
1311-
ammp *AzureManagedMachinePool
1312-
deferFunc func()
1313-
expectError bool
1310+
name string
1311+
ammp *AzureManagedMachinePool
1312+
featureGateEnabled *bool
1313+
expectError bool
13141314
}{
13151315
{
1316-
name: "feature gate explicitly disabled",
1317-
ammp: getKnownValidAzureManagedMachinePool(),
1318-
deferFunc: utilfeature.SetFeatureGateDuringTest(t, feature.Gates, capifeature.MachinePool, false),
1319-
expectError: true,
1316+
name: "feature gate explicitly disabled",
1317+
ammp: getKnownValidAzureManagedMachinePool(),
1318+
featureGateEnabled: ptr.To(false),
1319+
expectError: true,
13201320
},
13211321
{
1322-
name: "feature gate implicitly enabled",
1323-
ammp: getKnownValidAzureManagedMachinePool(),
1324-
deferFunc: func() {},
1325-
expectError: false,
1322+
name: "feature gate implicitly enabled",
1323+
ammp: getKnownValidAzureManagedMachinePool(),
1324+
featureGateEnabled: nil,
1325+
expectError: false,
13261326
},
13271327
}
13281328
for _, tc := range tests {
13291329
t.Run(tc.name, func(t *testing.T) {
1330-
defer tc.deferFunc()
1330+
if tc.featureGateEnabled != nil {
1331+
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, capifeature.MachinePool, *tc.featureGateEnabled)()
1332+
}
13311333
g := NewWithT(t)
13321334
mw := &azureManagedMachinePoolWebhook{}
13331335
_, err := mw.ValidateCreate(context.Background(), tc.ammp)

config/crd/bases/infrastructure.cluster.x-k8s.io_azureclusteridentities.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,13 @@ spec:
105105
items:
106106
type: string
107107
type: array
108+
x-kubernetes-list-type: atomic
108109
required:
109110
- key
110111
- operator
111112
type: object
112113
type: array
114+
x-kubernetes-list-type: atomic
113115
matchLabels:
114116
additionalProperties:
115117
type: string

controllers/azureasomanagedmachinepool_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ func (r *AzureASOManagedMachinePoolReconciler) SetupWithManager(ctx context.Cont
9191
).
9292
Watches(
9393
&expv1.MachinePool{},
94-
handler.EnqueueRequestsFromMapFunc(utilexp.MachinePoolToInfrastructureMapFunc(
95-
infrav1alpha.GroupVersion.WithKind(infrav1alpha.AzureASOManagedMachinePoolKind), log),
94+
handler.EnqueueRequestsFromMapFunc(utilexp.MachinePoolToInfrastructureMapFunc(ctx,
95+
infrav1alpha.GroupVersion.WithKind(infrav1alpha.AzureASOManagedMachinePoolKind)),
9696
),
9797
builder.WithPredicates(
9898
predicates.ResourceHasFilterLabel(log, r.WatchFilterValue),

controllers/azurejson_machinetemplate_controller.go

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ import (
3838
"sigs.k8s.io/cluster-api/util/annotations"
3939
"sigs.k8s.io/cluster-api/util/predicates"
4040
ctrl "sigs.k8s.io/controller-runtime"
41+
"sigs.k8s.io/controller-runtime/pkg/builder"
4142
"sigs.k8s.io/controller-runtime/pkg/client"
4243
"sigs.k8s.io/controller-runtime/pkg/controller"
4344
"sigs.k8s.io/controller-runtime/pkg/handler"
4445
"sigs.k8s.io/controller-runtime/pkg/reconcile"
45-
"sigs.k8s.io/controller-runtime/pkg/source"
4646
)
4747

4848
// AzureJSONTemplateReconciler reconciles Azure json secrets for AzureMachineTemplate objects.
@@ -65,29 +65,22 @@ func (r *AzureJSONTemplateReconciler) SetupWithManager(ctx context.Context, mgr
6565
return errors.Wrap(err, "failed to create mapper for Cluster to AzureMachineTemplates")
6666
}
6767

68-
c, err := ctrl.NewControllerManagedBy(mgr).
68+
return ctrl.NewControllerManagedBy(mgr).
6969
WithOptions(options).
7070
For(&infrav1.AzureMachineTemplate{}).
7171
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(log, r.WatchFilterValue)).
7272
Owns(&corev1.Secret{}).
73-
Build(r)
74-
75-
if err != nil {
76-
return errors.Wrap(err, "failed to create controller")
77-
}
78-
79-
// Add a watch on Clusters to requeue when the infraRef is set. This is needed because the infraRef is not initially
80-
// set in Clusters created from a ClusterClass.
81-
if err := c.Watch(
82-
source.Kind(mgr.GetCache(), &clusterv1.Cluster{}),
83-
handler.EnqueueRequestsFromMapFunc(azureMachineTemplateMapper),
84-
predicates.ClusterUnpausedAndInfrastructureReady(log),
85-
predicates.ResourceNotPausedAndHasFilterLabel(log, r.WatchFilterValue),
86-
); err != nil {
87-
return errors.Wrap(err, "failed adding a watch for Clusters")
88-
}
89-
90-
return nil
73+
// Add a watch on Clusters to requeue when the infraRef is set. This is needed because the infraRef is not initially
74+
// set in Clusters created from a ClusterClass.
75+
Watches(
76+
&clusterv1.Cluster{},
77+
handler.EnqueueRequestsFromMapFunc(azureMachineTemplateMapper),
78+
builder.WithPredicates(
79+
predicates.ClusterUnpausedAndInfrastructureReady(log),
80+
predicates.ResourceNotPausedAndHasFilterLabel(log, r.WatchFilterValue),
81+
),
82+
).
83+
Complete(r)
9184
}
9285

9386
// Reconcile reconciles Azure json secrets for Azure machine templates.

controllers/resource_reconciler.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
apierrors "k8s.io/apimachinery/pkg/api/errors"
2727
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2828
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
29-
"k8s.io/apimachinery/pkg/runtime"
3029
"k8s.io/apimachinery/pkg/runtime/schema"
3130
"k8s.io/klog/v2"
3231
infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1"
@@ -48,7 +47,7 @@ type ResourceReconciler struct {
4847
}
4948

5049
type watcher interface {
51-
Watch(log logr.Logger, obj runtime.Object, handler handler.EventHandler, p ...predicate.Predicate) error
50+
Watch(log logr.Logger, obj client.Object, handler handler.EventHandler, p ...predicate.Predicate) error
5251
}
5352

5453
type resourceStatusObject interface {

controllers/resource_reconciler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ type FakeWatcher struct {
5555
watching map[string]struct{}
5656
}
5757

58-
func (w *FakeWatcher) Watch(_ logr.Logger, obj runtime.Object, _ handler.EventHandler, _ ...predicate.Predicate) error {
58+
func (w *FakeWatcher) Watch(_ logr.Logger, obj client.Object, _ handler.EventHandler, _ ...predicate.Predicate) error {
5959
if w.watching == nil {
6060
w.watching = make(map[string]struct{})
6161
}

0 commit comments

Comments
 (0)