@@ -1813,8 +1813,8 @@ func TestReconcileUnbindingWithClusterServiceBrokerHTTPError(t *testing.T) {
1813
1813
if err := scmeta .AddFinalizer (binding , v1beta1 .FinalizerServiceCatalog ); err != nil {
1814
1814
t .Fatalf ("Finalizer error: %v" , err )
1815
1815
}
1816
- if err := testController .reconcileServiceBinding (binding ); err ! = nil {
1817
- t .Fatalf ("reconcileServiceBinding should not have returned an error: %v" , err )
1816
+ if err := testController .reconcileServiceBinding (binding ); err = = nil {
1817
+ t .Fatalf ("reconcileServiceBinding should have returned an error" )
1818
1818
}
1819
1819
1820
1820
actions := fakeCatalogClient .Actions ()
@@ -1825,7 +1825,7 @@ func TestReconcileUnbindingWithClusterServiceBrokerHTTPError(t *testing.T) {
1825
1825
assertServiceBindingOrphanMitigationSet (t , updatedServiceBinding , false )
1826
1826
1827
1827
updatedServiceBinding = assertUpdateStatus (t , actions [1 ], binding )
1828
- assertServiceBindingRequestFailingError (t , updatedServiceBinding , v1beta1 .ServiceBindingOperationUnbind , errorUnbindCallReason , errorUnbindCallReason , binding )
1828
+ assertServiceBindingRequestRetriableError (t , updatedServiceBinding , v1beta1 .ServiceBindingOperationUnbind , errorUnbindCallReason , binding )
1829
1829
assertServiceBindingOrphanMitigationSet (t , updatedServiceBinding , false )
1830
1830
1831
1831
events := getRecordedEvents (testController )
@@ -3068,6 +3068,7 @@ func TestPollServiceBinding(t *testing.T) {
3068
3068
validateBrokerActionsFunc func (t * testing.T , actions []fakeosb.Action )
3069
3069
validateKubeActionsFunc func (t * testing.T , actions []clientgotesting.Action )
3070
3070
validateConditionsFunc func (t * testing.T , updatedBinding * v1beta1.ServiceBinding , originalBinding * v1beta1.ServiceBinding )
3071
+ shouldError bool
3071
3072
shouldFinishPolling bool
3072
3073
expectedEvents []string
3073
3074
}{
@@ -3371,7 +3372,7 @@ func TestPollServiceBinding(t *testing.T) {
3371
3372
expectedEvents : []string {corev1 .EventTypeWarning + " " + errorPollingLastOperationReason + " " + "Error polling last operation: random error" },
3372
3373
},
3373
3374
{
3374
- name : "unbind - failed" ,
3375
+ name : "unbind - failed (retries) " ,
3375
3376
binding : getTestServiceBindingAsyncUnbinding (testOperation ),
3376
3377
pollReaction : & fakeosb.PollBindingLastOperationReaction {
3377
3378
Response : & osb.LastOperationResponse {
@@ -3381,15 +3382,15 @@ func TestPollServiceBinding(t *testing.T) {
3381
3382
},
3382
3383
validateBrokerActionsFunc : validatePollBindingLastOperationAction ,
3383
3384
validateConditionsFunc : func (t * testing.T , updatedBinding * v1beta1.ServiceBinding , originalBinding * v1beta1.ServiceBinding ) {
3384
- assertServiceBindingRequestFailingError (
3385
+ assertServiceBindingRequestRetriableError (
3385
3386
t ,
3386
3387
updatedBinding ,
3387
3388
v1beta1 .ServiceBindingOperationUnbind ,
3388
3389
errorUnbindCallReason ,
3389
- errorUnbindCallReason ,
3390
3390
originalBinding ,
3391
3391
)
3392
3392
},
3393
+ shouldError : true ,
3393
3394
shouldFinishPolling : true ,
3394
3395
expectedEvents : []string {corev1 .EventTypeWarning + " " + errorUnbindCallReason + " " + "Unbind call failed: " + lastOperationDescription },
3395
3396
},
@@ -3453,6 +3454,32 @@ func TestPollServiceBinding(t *testing.T) {
3453
3454
shouldFinishPolling : true ,
3454
3455
expectedEvents : []string {corev1 .EventTypeWarning + " " + errorReconciliationRetryTimeoutReason + " " + "Stopping reconciliation retries because too much time has elapsed" },
3455
3456
},
3457
+ {
3458
+ name : "unbind - failed - retry duration exceeded" ,
3459
+ binding : getTestServiceBindingAsyncUnbindingRetryDurationExceeded (testOperation ),
3460
+ pollReaction : & fakeosb.PollBindingLastOperationReaction {
3461
+ Response : & osb.LastOperationResponse {
3462
+ State : osb .StateFailed ,
3463
+ Description : strPtr (lastOperationDescription ),
3464
+ },
3465
+ },
3466
+ validateBrokerActionsFunc : validatePollBindingLastOperationAction ,
3467
+ validateConditionsFunc : func (t * testing.T , updatedBinding * v1beta1.ServiceBinding , originalBinding * v1beta1.ServiceBinding ) {
3468
+ assertServiceBindingRequestFailingError (
3469
+ t ,
3470
+ updatedBinding ,
3471
+ v1beta1 .ServiceBindingOperationUnbind ,
3472
+ errorUnbindCallReason ,
3473
+ errorReconciliationRetryTimeoutReason ,
3474
+ originalBinding ,
3475
+ )
3476
+ },
3477
+ shouldFinishPolling : true ,
3478
+ expectedEvents : []string {
3479
+ corev1 .EventTypeWarning + " " + errorUnbindCallReason + " " + "Unbind call failed: " + lastOperationDescription ,
3480
+ corev1 .EventTypeWarning + " " + errorReconciliationRetryTimeoutReason + " " + "Stopping reconciliation retries because too much time has elapsed" ,
3481
+ },
3482
+ },
3456
3483
// Unbind as part of orphan mitigation
3457
3484
{
3458
3485
name : "orphan mitigation - succeeded" ,
@@ -3513,7 +3540,7 @@ func TestPollServiceBinding(t *testing.T) {
3513
3540
expectedEvents : []string {corev1 .EventTypeWarning + " " + errorPollingLastOperationReason + " " + "Error polling last operation: random error" },
3514
3541
},
3515
3542
{
3516
- name : "orphan mitigation - failed" ,
3543
+ name : "orphan mitigation - failed (retries) " ,
3517
3544
binding : getTestServiceBindingAsyncOrphanMitigation (testOperation ),
3518
3545
pollReaction : & fakeosb.PollBindingLastOperationReaction {
3519
3546
Response : & osb.LastOperationResponse {
@@ -3523,8 +3550,9 @@ func TestPollServiceBinding(t *testing.T) {
3523
3550
},
3524
3551
validateBrokerActionsFunc : validatePollBindingLastOperationAction ,
3525
3552
validateConditionsFunc : func (t * testing.T , updatedBinding * v1beta1.ServiceBinding , originalBinding * v1beta1.ServiceBinding ) {
3526
- assertServiceBindingOrphanMitigationFailure (t , updatedBinding , originalBinding )
3553
+ assertServiceBindingRequestRetriableOrphanMitigation (t , updatedBinding , originalBinding )
3527
3554
},
3555
+ shouldError : true ,
3528
3556
shouldFinishPolling : true ,
3529
3557
expectedEvents : []string {corev1 .EventTypeWarning + " " + errorOrphanMitigationFailedReason + " " + "Orphan mitigation failed: " + lastOperationDescription },
3530
3558
},
@@ -3574,6 +3602,25 @@ func TestPollServiceBinding(t *testing.T) {
3574
3602
shouldFinishPolling : true ,
3575
3603
expectedEvents : []string {corev1 .EventTypeWarning + " " + errorReconciliationRetryTimeoutReason + " " + "Stopping reconciliation retries because too much time has elapsed" },
3576
3604
},
3605
+ {
3606
+ name : "orphan mitigation - failed - retry duration exceeded" ,
3607
+ binding : getTestServiceBindingAsyncOrphanMitigationRetryDurationExceeded (testOperation ),
3608
+ pollReaction : & fakeosb.PollBindingLastOperationReaction {
3609
+ Response : & osb.LastOperationResponse {
3610
+ State : osb .StateFailed ,
3611
+ Description : strPtr (lastOperationDescription ),
3612
+ },
3613
+ },
3614
+ validateBrokerActionsFunc : validatePollBindingLastOperationAction ,
3615
+ validateConditionsFunc : func (t * testing.T , updatedBinding * v1beta1.ServiceBinding , originalBinding * v1beta1.ServiceBinding ) {
3616
+ assertServiceBindingAsyncOrphanMitigationRetryDurationExceeded (t , updatedBinding , originalBinding )
3617
+ },
3618
+ shouldFinishPolling : true ,
3619
+ expectedEvents : []string {
3620
+ corev1 .EventTypeWarning + " " + errorOrphanMitigationFailedReason + " " + "Orphan mitigation failed: " + lastOperationDescription ,
3621
+ corev1 .EventTypeWarning + " " + errorReconciliationRetryTimeoutReason + " " + "Stopping reconciliation retries because too much time has elapsed" ,
3622
+ },
3623
+ },
3577
3624
}
3578
3625
3579
3626
for _ , tc := range cases {
@@ -3595,7 +3642,10 @@ func TestPollServiceBinding(t *testing.T) {
3595
3642
3596
3643
bindingKey := tc .binding .Namespace + "/" + tc .binding .Name
3597
3644
3598
- if err := testController .pollServiceBinding (tc .binding ); err != nil {
3645
+ err := testController .pollServiceBinding (tc .binding )
3646
+ if tc .shouldError && err == nil {
3647
+ t .Fatalf ("expected error when polling service binding but there was none" )
3648
+ } else if ! tc .shouldError && err != nil {
3599
3649
t .Fatalf ("unexpected error when polling service binding: %v" , err )
3600
3650
}
3601
3651
0 commit comments