@@ -1562,6 +1562,32 @@ func TestKubeadmControlPlaneReconciler_syncMachines(t *testing.T) {
1562
1562
return ! deletingMachine .DeletionTimestamp .IsZero ()
1563
1563
}, 30 * time .Second ).Should (BeTrue ())
1564
1564
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
+
1565
1591
kcp := & controlplanev1.KubeadmControlPlane {
1566
1592
TypeMeta : metav1.TypeMeta {
1567
1593
Kind : "KubeadmControlPlane" ,
@@ -1607,6 +1633,7 @@ func TestKubeadmControlPlaneReconciler_syncMachines(t *testing.T) {
1607
1633
Machines : collections.Machines {
1608
1634
inPlaceMutatingMachine .Name : inPlaceMutatingMachine ,
1609
1635
deletingMachine .Name : deletingMachine ,
1636
+ nilInfraMachineMachine .Name : nilInfraMachineMachine ,
1610
1637
},
1611
1638
KubeadmConfigs : map [string ]* bootstrapv1.KubeadmConfig {
1612
1639
inPlaceMutatingMachine .Name : existingKubeadmConfig ,
0 commit comments