@@ -27,6 +27,7 @@ import (
27
27
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28
28
"k8s.io/apimachinery/pkg/runtime"
29
29
"k8s.io/apimachinery/pkg/types"
30
+ "k8s.io/client-go/tools/record"
30
31
"k8s.io/utils/ptr"
31
32
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
32
33
expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
@@ -60,6 +61,26 @@ func TestAzureMachinePoolMachineReconciler_Reconcile(t *testing.T) {
60
61
g .Expect (err ).NotTo (HaveOccurred ())
61
62
},
62
63
},
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
+ },
63
84
{
64
85
Name : "should successfully delete" ,
65
86
Setup : func (cb * fake.ClientBuilder , reconciler * mock_azure.MockReconcilerMockRecorder ) {
@@ -136,7 +157,7 @@ func TestAzureMachinePoolMachineReconciler_Reconcile(t *testing.T) {
136
157
137
158
c .Setup (cb , reconciler .EXPECT ())
138
159
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 ())
140
161
controller .reconcilerFactory = func (_ * scope.MachinePoolMachineScope ) (azure.Reconciler , error ) {
141
162
return reconciler , nil
142
163
}
0 commit comments