Skip to content

Commit 7cb4637

Browse files
Upgrade to capi 1.4 (#239)
* Add support for CAPI 1.4.1
1 parent 5f2445a commit 7cb4637

17 files changed

+199
-372
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ $(KUSTOMIZE): ## Download kustomize locally if necessary.
375375
GOBIN=$(BIN_DIR)/ $(GO_INSTALL) sigs.k8s.io/kustomize/kustomize/v4 $(KUSTOMIZE_BIN) v4.5.2
376376

377377
$(GINKGO): ## Build ginkgo.
378-
GOBIN=$(BIN_DIR)/ $(GO_INSTALL) github.com/onsi/ginkgo/v2/ginkgo $(GINKGO_BIN) v2.5.0
378+
GOBIN=$(BIN_DIR)/ $(GO_INSTALL) github.com/onsi/ginkgo/v2/ginkgo $(GINKGO_BIN) v2.9.2
379379

380380
$(GOLANGCI_LINT): ## Build golanci-lint.
381381
GOBIN=$(BIN_DIR)/ $(GO_INSTALL) github.com/golangci/golangci-lint/cmd/golangci-lint $(GOLANGCI_LINT_BIN) v1.44.0

cloud/scope/vnic_reconciler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func TestReconcileVnicAttachment(t *testing.T) {
186186
matchError: fmt.Errorf("cannot attach multiple vnics to ControlPlane machines"),
187187
testSpecificSetup: func(machineScope *MachineScope, computeClient *mock_compute.MockComputeClient) {
188188
ms.Machine.ObjectMeta.Labels = make(map[string]string)
189-
ms.Machine.ObjectMeta.Labels[clusterv1.MachineControlPlaneLabelName] = "Test"
189+
ms.Machine.ObjectMeta.Labels[clusterv1.MachineControlPlaneLabel] = "Test"
190190
},
191191
},
192192
}

config/crd/kustomization.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ patchesStrategicMerge:
2626
- patches/webhook_in_ocimachinepools.yaml
2727
- patches/webhook_in_ocimanagedclusters.yaml
2828
- patches/webhook_in_ocimanagedmachinepools.yaml
29+
- patches/webhook_in_ocimanagedcontrolplanes.yaml
2930
- patches/webhook_in_ociclusteridentities.yaml
3031
# +kubebuilder:scaffold:crdkustomizewebhookpatch
3132

@@ -37,6 +38,7 @@ patchesStrategicMerge:
3738
- patches/cainjection_in_ocimachinepools.yaml
3839
- patches/cainjection_in_ocimanagedclusters.yaml
3940
- patches/cainjection_in_ocimanagedmachinepools.yaml
41+
- patches/cainjection_in_ocimanagedcontrolplanes.yaml
4042
- patches/cainjection_in_ociclusteridentities.yaml
4143
# +kubebuilder:scaffold:crdkustomizecainjectionpatch
4244

config/manager/manager.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ spec:
3434
name: manager
3535
securityContext:
3636
allowPrivilegeEscalation: false
37+
capabilities:
38+
drop:
39+
- ALL
40+
privileged: false
41+
runAsUser: 65532
42+
runAsGroup: 65532
3743
livenessProbe:
3844
httpGet:
3945
path: /healthz
@@ -53,6 +59,10 @@ spec:
5359
key: node-role.kubernetes.io/master
5460
- effect: NoSchedule
5561
key: node-role.kubernetes.io/control-plane
62+
securityContext:
63+
runAsNonRoot: true
64+
seccompProfile:
65+
type: RuntimeDefault
5666
affinity:
5767
nodeAffinity:
5868
preferredDuringSchedulingIgnoredDuringExecution:

controllers/ocimachine_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func (r *OCIMachineReconciler) OCIClusterToOCIMachines(ctx context.Context) hand
212212
return result
213213
}
214214

215-
labels := map[string]string{clusterv1.ClusterLabelName: cluster.Name}
215+
labels := map[string]string{clusterv1.ClusterNameLabel: cluster.Name}
216216
machineList := &clusterv1.MachineList{}
217217
if err := r.List(ctx, machineList, client.InNamespace(c.Namespace), client.MatchingLabels(labels)); err != nil {
218218
log.Error(err, "failed to list Machines")

controllers/ocimachine_controller_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ func TestNormalReconciliationFunction(t *testing.T) {
264264
conditionAssertion: []conditionAssertion{{infrastructurev1beta2.InstanceReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityError, infrastructurev1beta2.InstanceIPAddressNotFound}},
265265
testSpecificSetup: func(machineScope *scope.MachineScope, computeClient *mock_compute.MockComputeClient, vcnClient *mock_vcn.MockClient, nlbclient *mock_nlb.MockNetworkLoadBalancerClient) {
266266
machineScope.Machine.ObjectMeta.Labels = make(map[string]string)
267-
machineScope.Machine.ObjectMeta.Labels[clusterv1.MachineControlPlaneLabelName] = "true"
267+
machineScope.Machine.ObjectMeta.Labels[clusterv1.MachineControlPlaneLabel] = "true"
268268
computeClient.EXPECT().GetInstance(gomock.Any(), gomock.Eq(core.GetInstanceRequest{
269269
InstanceId: common.String("test"),
270270
})).
@@ -287,7 +287,7 @@ func TestNormalReconciliationFunction(t *testing.T) {
287287
errorExpected: false,
288288
testSpecificSetup: func(machineScope *scope.MachineScope, computeClient *mock_compute.MockComputeClient, vcnClient *mock_vcn.MockClient, nlbClient *mock_nlb.MockNetworkLoadBalancerClient) {
289289
machineScope.Machine.ObjectMeta.Labels = make(map[string]string)
290-
machineScope.Machine.ObjectMeta.Labels[clusterv1.MachineControlPlaneLabelName] = "true"
290+
machineScope.Machine.ObjectMeta.Labels[clusterv1.MachineControlPlaneLabel] = "true"
291291
computeClient.EXPECT().GetInstance(gomock.Any(), gomock.Eq(core.GetInstanceRequest{
292292
InstanceId: common.String("test"),
293293
})).
@@ -344,7 +344,7 @@ func TestNormalReconciliationFunction(t *testing.T) {
344344
errorExpected: false,
345345
testSpecificSetup: func(machineScope *scope.MachineScope, computeClient *mock_compute.MockComputeClient, vcnClient *mock_vcn.MockClient, nlbClient *mock_nlb.MockNetworkLoadBalancerClient) {
346346
machineScope.Machine.ObjectMeta.Labels = make(map[string]string)
347-
machineScope.Machine.ObjectMeta.Labels[clusterv1.MachineControlPlaneLabelName] = "true"
347+
machineScope.Machine.ObjectMeta.Labels[clusterv1.MachineControlPlaneLabel] = "true"
348348
computeClient.EXPECT().GetInstance(gomock.Any(), gomock.Eq(core.GetInstanceRequest{
349349
InstanceId: common.String("test"),
350350
})).
@@ -425,7 +425,7 @@ func TestNormalReconciliationFunction(t *testing.T) {
425425
Address: "1.1.1.1",
426426
},
427427
}
428-
machineScope.Machine.ObjectMeta.Labels[clusterv1.MachineControlPlaneLabelName] = "true"
428+
machineScope.Machine.ObjectMeta.Labels[clusterv1.MachineControlPlaneLabel] = "true"
429429
computeClient.EXPECT().GetInstance(gomock.Any(), gomock.Eq(core.GetInstanceRequest{
430430
InstanceId: common.String("test"),
431431
})).
@@ -478,7 +478,7 @@ func TestNormalReconciliationFunction(t *testing.T) {
478478
errorExpected: true,
479479
testSpecificSetup: func(machineScope *scope.MachineScope, computeClient *mock_compute.MockComputeClient, vcnClient *mock_vcn.MockClient, nlbClient *mock_nlb.MockNetworkLoadBalancerClient) {
480480
machineScope.Machine.ObjectMeta.Labels = make(map[string]string)
481-
machineScope.Machine.ObjectMeta.Labels[clusterv1.MachineControlPlaneLabelName] = "true"
481+
machineScope.Machine.ObjectMeta.Labels[clusterv1.MachineControlPlaneLabel] = "true"
482482
computeClient.EXPECT().GetInstance(gomock.Any(), gomock.Eq(core.GetInstanceRequest{
483483
InstanceId: common.String("test"),
484484
})).
@@ -751,7 +751,7 @@ func TestMachineReconciliationDeletionNormal(t *testing.T) {
751751
conditionAssertion: []conditionAssertion{{infrastructurev1beta2.InstanceReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityInfo, infrastructurev1beta2.InstanceTerminatingReason}},
752752
testSpecificSetup: func(machineScope *scope.MachineScope, computeClient *mock_compute.MockComputeClient, vcnClient *mock_vcn.MockClient, nlbClient *mock_nlb.MockNetworkLoadBalancerClient) {
753753
machineScope.Machine.ObjectMeta.Labels = make(map[string]string)
754-
machineScope.Machine.ObjectMeta.Labels[clusterv1.MachineControlPlaneLabelName] = "true"
754+
machineScope.Machine.ObjectMeta.Labels[clusterv1.MachineControlPlaneLabel] = "true"
755755
computeClient.EXPECT().GetInstance(gomock.Any(), gomock.Eq(core.GetInstanceRequest{
756756
InstanceId: common.String("test"),
757757
})).
@@ -814,7 +814,7 @@ func TestMachineReconciliationDeletionNormal(t *testing.T) {
814814
conditionAssertion: []conditionAssertion{{infrastructurev1beta2.InstanceReadyCondition, corev1.ConditionFalse, clusterv1.ConditionSeverityInfo, infrastructurev1beta2.InstanceNotFoundReason}},
815815
testSpecificSetup: func(machineScope *scope.MachineScope, computeClient *mock_compute.MockComputeClient, vcnClient *mock_vcn.MockClient, nlbClient *mock_nlb.MockNetworkLoadBalancerClient) {
816816
machineScope.Machine.ObjectMeta.Labels = make(map[string]string)
817-
machineScope.Machine.ObjectMeta.Labels[clusterv1.MachineControlPlaneLabelName] = "true"
817+
machineScope.Machine.ObjectMeta.Labels[clusterv1.MachineControlPlaneLabel] = "true"
818818
computeClient.EXPECT().GetInstance(gomock.Any(), gomock.Eq(core.GetInstanceRequest{
819819
InstanceId: common.String("test"),
820820
})).
@@ -918,7 +918,7 @@ func getOciMachine() *infrastructurev1beta2.OCIMachine {
918918
Namespace: "test",
919919
UID: "uid",
920920
Labels: map[string]string{
921-
clusterv1.ClusterLabelName: "test-cluster",
921+
clusterv1.ClusterNameLabel: "test-cluster",
922922
},
923923
OwnerReferences: []metav1.OwnerReference{
924924
{

exp/controllers/ocimachinepool_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func getOCIMachinePool() *infrav2exp.OCIMachinePool {
151151
Namespace: "test",
152152
UID: "uid",
153153
Labels: map[string]string{
154-
clusterv1.ClusterLabelName: "test-cluster",
154+
clusterv1.ClusterNameLabel: "test-cluster",
155155
},
156156
OwnerReferences: []metav1.OwnerReference{
157157
{

exp/controllers/ocimanaged_machinepool_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func managedClusterToManagedMachinePoolMapFunc(c client.Client, gvk schema.Group
223223

224224
managedPoolForClusterList := expclusterv1.MachinePoolList{}
225225
if err := c.List(
226-
ctx, &managedPoolForClusterList, client.InNamespace(cluster.Namespace), client.MatchingLabels{clusterv1.ClusterLabelName: cluster.Name},
226+
ctx, &managedPoolForClusterList, client.InNamespace(cluster.Namespace), client.MatchingLabels{clusterv1.ClusterNameLabel: cluster.Name},
227227
); err != nil {
228228
log.Error(err, "couldn't list pools for cluster")
229229
return nil

exp/controllers/ocimanaged_machinepool_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ func getOCIManagedMachinePool() *infrav2exp.OCIManagedMachinePool {
611611
Namespace: "test",
612612
UID: "uid",
613613
Labels: map[string]string{
614-
clusterv1.ClusterLabelName: "test-cluster",
614+
clusterv1.ClusterNameLabel: "test-cluster",
615615
},
616616
OwnerReferences: []metav1.OwnerReference{
617617
{

exp/controllers/ocimanagedcluster_controlplane_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ func getOCIManagedControlPlane() *infrav2exp.OCIManagedControlPlane {
629629
Namespace: "test",
630630
UID: "uid",
631631
Labels: map[string]string{
632-
clusterv1.ClusterLabelName: "test-cluster",
632+
clusterv1.ClusterNameLabel: "test-cluster",
633633
},
634634
OwnerReferences: []metav1.OwnerReference{
635635
{

0 commit comments

Comments
 (0)