@@ -27,6 +27,7 @@ import (
2727 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2828 "k8s.io/apimachinery/pkg/runtime"
2929 "k8s.io/apimachinery/pkg/types"
30+ "k8s.io/client-go/tools/record"
3031 "k8s.io/utils/ptr"
3132 clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
3233 expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
@@ -60,6 +61,26 @@ func TestAzureMachinePoolMachineReconciler_Reconcile(t *testing.T) {
6061 g .Expect (err ).NotTo (HaveOccurred ())
6162 },
6263 },
64+ {
65+ Name : "should not set failure properties if VMSS VM has state Failed" ,
66+ Setup : func (cb * fake.ClientBuilder , reconciler * mock_azure.MockReconcilerMockRecorder ) {
67+ objects := getReadyMachinePoolMachineClusterObjects (false , ptr .To (infrav1 .Failed ))
68+ reconciler .Reconcile (gomock2 .AContext ()).Return (nil )
69+ cb .WithObjects (objects ... )
70+ },
71+ Verify : func (g * WithT , c client.Client , result ctrl.Result , err error ) {
72+ g .Expect (err ).NotTo (HaveOccurred ())
73+
74+ ampm := & infrav1exp.AzureMachinePoolMachine {}
75+ err = c .Get (context .Background (), types.NamespacedName {
76+ Name : "ampm1" ,
77+ Namespace : "default" ,
78+ }, ampm )
79+ g .Expect (err ).NotTo (HaveOccurred ())
80+ g .Expect (ampm .Status .FailureReason ).To (BeNil ())
81+ g .Expect (ampm .Status .FailureMessage ).To (BeNil ())
82+ },
83+ },
6384 {
6485 Name : "should successfully delete" ,
6586 Setup : func (cb * fake.ClientBuilder , reconciler * mock_azure.MockReconcilerMockRecorder ) {
@@ -136,7 +157,7 @@ func TestAzureMachinePoolMachineReconciler_Reconcile(t *testing.T) {
136157
137158 c .Setup (cb , reconciler .EXPECT ())
138159 cl := cb .Build ()
139- controller := NewAzureMachinePoolMachineController (cl , nil , reconcilerutils.Timeouts {}, "foo" , azure .NewCredentialCache ())
160+ controller := NewAzureMachinePoolMachineController (cl , record . NewFakeRecorder ( 1 ) , reconcilerutils.Timeouts {}, "foo" , azure .NewCredentialCache ())
140161 controller .reconcilerFactory = func (_ * scope.MachinePoolMachineScope ) (azure.Reconciler , error ) {
141162 return reconciler , nil
142163 }
0 commit comments