@@ -1562,6 +1562,32 @@ func TestKubeadmControlPlaneReconciler_syncMachines(t *testing.T) {
15621562 return ! deletingMachine .DeletionTimestamp .IsZero ()
15631563 }, 30 * time .Second ).Should (BeTrue ())
15641564
1565+ // Existing machine that has a InfrastructureRef which does not exist.
1566+ nilInfraMachineMachine := & clusterv1.Machine {
1567+ TypeMeta : metav1.TypeMeta {
1568+ APIVersion : clusterv1 .GroupVersion .String (),
1569+ Kind : "Machine" ,
1570+ },
1571+ ObjectMeta : metav1.ObjectMeta {
1572+ Name : "nil-infra-machine-machine" ,
1573+ Namespace : namespace .Name ,
1574+ Labels : map [string ]string {},
1575+ Annotations : map [string ]string {},
1576+ Finalizers : []string {"testing-finalizer" },
1577+ },
1578+ Spec : clusterv1.MachineSpec {
1579+ ClusterName : testCluster .Name ,
1580+ InfrastructureRef : corev1.ObjectReference {
1581+ Namespace : namespace .Name ,
1582+ },
1583+ Bootstrap : clusterv1.Bootstrap {
1584+ DataSecretName : pointer .String ("machine-bootstrap-secret" ),
1585+ },
1586+ },
1587+ }
1588+ g .Expect (env .Create (ctx , nilInfraMachineMachine , client .FieldOwner (classicManager ))).To (Succeed ())
1589+ // Delete the machine to put it in the deleting state
1590+
15651591 kcp := & controlplanev1.KubeadmControlPlane {
15661592 TypeMeta : metav1.TypeMeta {
15671593 Kind : "KubeadmControlPlane" ,
@@ -1607,6 +1633,7 @@ func TestKubeadmControlPlaneReconciler_syncMachines(t *testing.T) {
16071633 Machines : collections.Machines {
16081634 inPlaceMutatingMachine .Name : inPlaceMutatingMachine ,
16091635 deletingMachine .Name : deletingMachine ,
1636+ nilInfraMachineMachine .Name : nilInfraMachineMachine ,
16101637 },
16111638 KubeadmConfigs : map [string ]* bootstrapv1.KubeadmConfig {
16121639 inPlaceMutatingMachine .Name : existingKubeadmConfig ,
0 commit comments