Skip to content

Commit

Permalink
Merge pull request #8992 from chrischdi/pr-capkcp-nil-fix-main
Browse files Browse the repository at this point in the history
🌱 controlplane: add a test case for syncMachines where the InfraMachine does not exist.
  • Loading branch information
k8s-ci-robot authored Jul 12, 2023
2 parents e39346e + 87f99a8 commit 6dc0819
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions controlplane/kubeadm/internal/controllers/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1562,6 +1562,32 @@ func TestKubeadmControlPlaneReconciler_syncMachines(t *testing.T) {
return !deletingMachine.DeletionTimestamp.IsZero()
}, 30*time.Second).Should(BeTrue())

// Existing machine that has a InfrastructureRef which does not exist.
nilInfraMachineMachine := &clusterv1.Machine{
TypeMeta: metav1.TypeMeta{
APIVersion: clusterv1.GroupVersion.String(),
Kind: "Machine",
},
ObjectMeta: metav1.ObjectMeta{
Name: "nil-infra-machine-machine",
Namespace: namespace.Name,
Labels: map[string]string{},
Annotations: map[string]string{},
Finalizers: []string{"testing-finalizer"},
},
Spec: clusterv1.MachineSpec{
ClusterName: testCluster.Name,
InfrastructureRef: corev1.ObjectReference{
Namespace: namespace.Name,
},
Bootstrap: clusterv1.Bootstrap{
DataSecretName: pointer.String("machine-bootstrap-secret"),
},
},
}
g.Expect(env.Create(ctx, nilInfraMachineMachine, client.FieldOwner(classicManager))).To(Succeed())
// Delete the machine to put it in the deleting state

kcp := &controlplanev1.KubeadmControlPlane{
TypeMeta: metav1.TypeMeta{
Kind: "KubeadmControlPlane",
Expand Down Expand Up @@ -1607,6 +1633,7 @@ func TestKubeadmControlPlaneReconciler_syncMachines(t *testing.T) {
Machines: collections.Machines{
inPlaceMutatingMachine.Name: inPlaceMutatingMachine,
deletingMachine.Name: deletingMachine,
nilInfraMachineMachine.Name: nilInfraMachineMachine,
},
KubeadmConfigs: map[string]*bootstrapv1.KubeadmConfig{
inPlaceMutatingMachine.Name: existingKubeadmConfig,
Expand Down

0 comments on commit 6dc0819

Please sign in to comment.