@@ -391,6 +391,7 @@ func TestAWSMachineReconciler(t *testing.T) {
391
391
secretSvc .EXPECT ().UserData (gomock .Any (), gomock .Any (), gomock .Any (), gomock .Any ()).Return (nil , nil ).Times (1 )
392
392
instance .State = infrav1 .InstanceStatePending
393
393
_ , _ = reconciler .reconcileNormal (context .Background (), ms , cs , cs , cs , cs )
394
+
394
395
g .Expect (ms .AWSMachine .Status .InstanceState ).To (PointTo (Equal (infrav1 .InstanceStatePending )))
395
396
g .Expect (ms .AWSMachine .Status .Ready ).To (Equal (false ))
396
397
g .Expect (buf .String ()).To (ContainSubstring (("EC2 instance state changed" )))
@@ -410,6 +411,7 @@ func TestAWSMachineReconciler(t *testing.T) {
410
411
secretSvc .EXPECT ().UserData (gomock .Any (), gomock .Any (), gomock .Any (), gomock .Any ()).Return (nil , nil ).Times (1 )
411
412
instance .State = infrav1 .InstanceStateRunning
412
413
_ , _ = reconciler .reconcileNormal (context .Background (), ms , cs , cs , cs , cs )
414
+
413
415
g .Expect (ms .AWSMachine .Status .InstanceState ).To (PointTo (Equal (infrav1 .InstanceStateRunning )))
414
416
g .Expect (ms .AWSMachine .Status .Ready ).To (Equal (true ))
415
417
g .Expect (buf .String ()).To (ContainSubstring (("EC2 instance state changed" )))
@@ -1081,7 +1083,7 @@ func TestAWSMachineReconciler(t *testing.T) {
1081
1083
1082
1084
instance .State = infrav1 .InstanceStateRunning
1083
1085
secretSvc .EXPECT ().Delete (gomock .Any ()).Return (nil ).Times (1 )
1084
- ec2Svc .EXPECT ().TerminateInstanceAndWait (gomock .Any ()).Return (nil ).AnyTimes ()
1086
+ ec2Svc .EXPECT ().TerminateInstance (gomock .Any ()).Return (nil ).AnyTimes ()
1085
1087
_ , _ = reconciler .reconcileDelete (ms , cs , cs , cs , cs )
1086
1088
})
1087
1089
@@ -1094,7 +1096,7 @@ func TestAWSMachineReconciler(t *testing.T) {
1094
1096
1095
1097
ms .AWSMachine .Status .FailureReason = capierrors .MachineStatusErrorPtr (capierrors .UpdateMachineError )
1096
1098
secretSvc .EXPECT ().Delete (gomock .Any ()).Return (nil ).Times (1 )
1097
- ec2Svc .EXPECT ().TerminateInstanceAndWait (gomock .Any ()).Return (nil ).AnyTimes ()
1099
+ ec2Svc .EXPECT ().TerminateInstance (gomock .Any ()).Return (nil ).AnyTimes ()
1098
1100
_ , _ = reconciler .reconcileDelete (ms , cs , cs , cs , cs )
1099
1101
})
1100
1102
t .Run ("should not attempt to delete the secret if InsecureSkipSecretsManager is set on CloudInit" , func (t * testing.T ) {
@@ -1107,7 +1109,7 @@ func TestAWSMachineReconciler(t *testing.T) {
1107
1109
ms .AWSMachine .Spec .CloudInit .InsecureSkipSecretsManager = true
1108
1110
1109
1111
secretSvc .EXPECT ().Delete (gomock .Any ()).Return (nil ).Times (0 )
1110
- ec2Svc .EXPECT ().TerminateInstanceAndWait (gomock .Any ()).Return (nil ).AnyTimes ()
1112
+ ec2Svc .EXPECT ().TerminateInstance (gomock .Any ()).Return (nil ).AnyTimes ()
1111
1113
1112
1114
_ , _ = reconciler .reconcileDelete (ms , cs , cs , cs , cs )
1113
1115
})
@@ -1167,7 +1169,7 @@ func TestAWSMachineReconciler(t *testing.T) {
1167
1169
1168
1170
instance .State = infrav1 .InstanceStateRunning
1169
1171
secretSvc .EXPECT ().Delete (gomock .Any ()).Return (nil ).Times (1 )
1170
- ec2Svc .EXPECT ().TerminateInstanceAndWait (gomock .Any ()).Return (nil ).AnyTimes ()
1172
+ ec2Svc .EXPECT ().TerminateInstance (gomock .Any ()).Return (nil ).AnyTimes ()
1171
1173
_ , _ = reconciler .reconcileDelete (ms , cs , cs , cs , cs )
1172
1174
})
1173
1175
@@ -1180,7 +1182,7 @@ func TestAWSMachineReconciler(t *testing.T) {
1180
1182
1181
1183
ms .AWSMachine .Status .FailureReason = capierrors .MachineStatusErrorPtr (capierrors .UpdateMachineError )
1182
1184
secretSvc .EXPECT ().Delete (gomock .Any ()).Return (nil ).Times (1 )
1183
- ec2Svc .EXPECT ().TerminateInstanceAndWait (gomock .Any ()).Return (nil ).AnyTimes ()
1185
+ ec2Svc .EXPECT ().TerminateInstance (gomock .Any ()).Return (nil ).AnyTimes ()
1184
1186
_ , _ = reconciler .reconcileDelete (ms , cs , cs , cs , cs )
1185
1187
})
1186
1188
})
@@ -1348,7 +1350,7 @@ func TestAWSMachineReconciler(t *testing.T) {
1348
1350
1349
1351
instance .State = infrav1 .InstanceStateRunning
1350
1352
objectStoreSvc .EXPECT ().Delete (gomock .Any ()).Return (nil ).Times (1 )
1351
- ec2Svc .EXPECT ().TerminateInstanceAndWait (gomock .Any ()).Return (nil ).AnyTimes ()
1353
+ ec2Svc .EXPECT ().TerminateInstance (gomock .Any ()).Return (nil ).AnyTimes ()
1352
1354
1353
1355
_ , _ = reconciler .reconcileDelete (ms , cs , cs , cs , cs )
1354
1356
})
@@ -1365,7 +1367,7 @@ func TestAWSMachineReconciler(t *testing.T) {
1365
1367
ms .AWSMachine .Status .FailureReason = capierrors .MachineStatusErrorPtr (capierrors .UpdateMachineError )
1366
1368
1367
1369
objectStoreSvc .EXPECT ().Delete (gomock .Any ()).Return (nil ).Times (1 )
1368
- ec2Svc .EXPECT ().TerminateInstanceAndWait (gomock .Any ()).Return (nil ).AnyTimes ()
1370
+ ec2Svc .EXPECT ().TerminateInstance (gomock .Any ()).Return (nil ).AnyTimes ()
1369
1371
1370
1372
_ , _ = reconciler .reconcileDelete (ms , cs , cs , cs , cs )
1371
1373
})
@@ -1429,7 +1431,7 @@ func TestAWSMachineReconciler(t *testing.T) {
1429
1431
1430
1432
instance .State = infrav1 .InstanceStateRunning
1431
1433
objectStoreSvc .EXPECT ().Delete (gomock .Any ()).Return (nil ).Times (1 )
1432
- ec2Svc .EXPECT ().TerminateInstanceAndWait (gomock .Any ()).Return (nil ).AnyTimes ()
1434
+ ec2Svc .EXPECT ().TerminateInstance (gomock .Any ()).Return (nil ).AnyTimes ()
1433
1435
_ , _ = reconciler .reconcileDelete (ms , cs , cs , cs , cs )
1434
1436
})
1435
1437
@@ -1444,7 +1446,7 @@ func TestAWSMachineReconciler(t *testing.T) {
1444
1446
// TODO: This seems to have no effect on the test result.
1445
1447
ms .AWSMachine .Status .FailureReason = capierrors .MachineStatusErrorPtr (capierrors .UpdateMachineError )
1446
1448
objectStoreSvc .EXPECT ().Delete (gomock .Any ()).Return (nil ).Times (1 )
1447
- ec2Svc .EXPECT ().TerminateInstanceAndWait (gomock .Any ()).Return (nil ).AnyTimes ()
1449
+ ec2Svc .EXPECT ().TerminateInstance (gomock .Any ()).Return (nil ).AnyTimes ()
1448
1450
_ , _ = reconciler .reconcileDelete (ms , cs , cs , cs , cs )
1449
1451
})
1450
1452
})
@@ -1534,9 +1536,8 @@ func TestAWSMachineReconciler(t *testing.T) {
1534
1536
_ , err := reconciler .reconcileDelete (ms , cs , cs , cs , cs )
1535
1537
g .Expect (err ).To (BeNil ())
1536
1538
g .Expect (buf .String ()).To (ContainSubstring ("EC2 instance is shutting down or already terminated" ))
1537
- g .Expect (ms .AWSMachine .Finalizers ).To (ConsistOf (metav1 .FinalizerDeleteDependents ))
1538
1539
})
1539
- t .Run ("should ignore instances in terminated down state" , func (t * testing.T ) {
1540
+ t .Run ("should ignore instances in terminated state" , func (t * testing.T ) {
1540
1541
g := NewWithT (t )
1541
1542
awsMachine := getAWSMachine ()
1542
1543
setup (t , g , awsMachine )
@@ -1553,7 +1554,7 @@ func TestAWSMachineReconciler(t *testing.T) {
1553
1554
1554
1555
_ , err := reconciler .reconcileDelete (ms , cs , cs , cs , cs )
1555
1556
g .Expect (err ).To (BeNil ())
1556
- g .Expect (buf .String ()).To (ContainSubstring ("EC2 instance is shutting down or already terminated" ))
1557
+ g .Expect (buf .String ()).To (ContainSubstring ("EC2 instance terminated successfully " ))
1557
1558
g .Expect (ms .AWSMachine .Finalizers ).To (ConsistOf (metav1 .FinalizerDeleteDependents ))
1558
1559
})
1559
1560
t .Run ("instance not shutting down yet" , func (t * testing.T ) {
@@ -1572,7 +1573,7 @@ func TestAWSMachineReconciler(t *testing.T) {
1572
1573
getRunningInstance (t , g )
1573
1574
1574
1575
expected := errors .New ("can't reach AWS to terminate machine" )
1575
- ec2Svc .EXPECT ().TerminateInstanceAndWait (gomock .Any ()).Return (expected )
1576
+ ec2Svc .EXPECT ().TerminateInstance (gomock .Any ()).Return (expected )
1576
1577
1577
1578
buf := new (bytes.Buffer )
1578
1579
klog .SetOutput (buf )
@@ -1585,7 +1586,7 @@ func TestAWSMachineReconciler(t *testing.T) {
1585
1586
t .Run ("when instance can be shut down" , func (t * testing.T ) {
1586
1587
terminateInstance := func (t * testing.T , g * WithT ) {
1587
1588
t .Helper ()
1588
- ec2Svc .EXPECT ().TerminateInstanceAndWait (gomock .Any ()).Return (nil )
1589
+ ec2Svc .EXPECT ().TerminateInstance (gomock .Any ()).Return (nil )
1589
1590
secretSvc .EXPECT ().Delete (gomock .Any ()).Return (nil ).AnyTimes ()
1590
1591
}
1591
1592
@@ -1663,7 +1664,6 @@ func TestAWSMachineReconciler(t *testing.T) {
1663
1664
1664
1665
_ , err := reconciler .reconcileDelete (ms , cs , cs , cs , cs )
1665
1666
g .Expect (err ).To (BeNil ())
1666
- g .Expect (ms .AWSMachine .Finalizers ).To (ConsistOf (metav1 .FinalizerDeleteDependents ))
1667
1667
})
1668
1668
1669
1669
t .Run ("should fail to detach control plane ELB from instance" , func (t * testing.T ) {
0 commit comments