@@ -1247,51 +1247,8 @@ func (c *controller) pollServiceInstance(instance *v1beta1.ServiceInstance) erro
1247
1247
glog .V (4 ).Info (pcb .Message (s ))
1248
1248
c .recorder .Event (instance , corev1 .EventTypeWarning , errorPollingLastOperationReason , s )
1249
1249
1250
- if ! time .Now ().Before (instance .Status .OperationStartTime .Time .Add (c .reconciliationRetryDuration )) {
1251
- clone , err := api .Scheme .DeepCopy (instance )
1252
- if err != nil {
1253
- return err
1254
- }
1255
- toUpdate := clone .(* v1beta1.ServiceInstance )
1256
- s := "Stopping reconciliation retries because too much time has elapsed"
1257
- glog .Info (pcb .Message (s ))
1258
- c .recorder .Event (instance , corev1 .EventTypeWarning , errorReconciliationRetryTimeoutReason , s )
1259
-
1260
- if mitigatingOrphan {
1261
- setServiceInstanceCondition (
1262
- toUpdate ,
1263
- v1beta1 .ServiceInstanceConditionReady ,
1264
- v1beta1 .ConditionUnknown ,
1265
- errorOrphanMitigationFailedReason ,
1266
- "Orphan mitigation failed: " + s )
1267
- } else if deleting || provisioning {
1268
- setServiceInstanceCondition (toUpdate ,
1269
- v1beta1 .ServiceInstanceConditionFailed ,
1270
- v1beta1 .ConditionTrue ,
1271
- errorReconciliationRetryTimeoutReason ,
1272
- s )
1273
- } else {
1274
- setServiceInstanceCondition (toUpdate ,
1275
- v1beta1 .ServiceInstanceConditionReady ,
1276
- v1beta1 .ConditionFalse ,
1277
- errorReconciliationRetryTimeoutReason ,
1278
- s )
1279
- }
1280
-
1281
- if ! provisioning {
1282
- clearServiceInstanceCurrentOperation (toUpdate )
1283
- } else {
1284
- c .setServiceInstanceStartOrphanMitigation (toUpdate )
1285
- }
1286
-
1287
- if deleting {
1288
- toUpdate .Status .DeprovisionStatus = v1beta1 .ServiceInstanceDeprovisionStatusFailed
1289
- }
1290
-
1291
- if _ , err := c .updateServiceInstanceStatus (toUpdate ); err != nil {
1292
- return err
1293
- }
1294
- return c .finishPollingServiceInstance (instance )
1250
+ if c .isReconciliationRetryDurationExceeded (instance ) {
1251
+ return c .reconciliationRetryDurationExceededFinishPollingServiceInstance (instance , mitigatingOrphan , provisioning , deleting )
1295
1252
}
1296
1253
1297
1254
return c .continuePollingServiceInstance (instance )
@@ -1589,55 +1546,73 @@ func (c *controller) pollServiceInstance(instance *v1beta1.ServiceInstance) erro
1589
1546
1590
1547
default :
1591
1548
glog .Warning (pcb .Messagef ("Got invalid state in LastOperationResponse: %q" , response .State ))
1592
- if ! time .Now ().Before (instance .Status .OperationStartTime .Time .Add (c .reconciliationRetryDuration )) {
1593
- clone , err := api .Scheme .DeepCopy (instance )
1594
- if err != nil {
1595
- return err
1596
- }
1597
- toUpdate := clone .(* v1beta1.ServiceInstance )
1598
- s := "Stopping reconciliation retries on ServiceInstance because too much time has elapsed"
1599
- glog .Info (pcb .Message (s ))
1600
- c .recorder .Event (instance , corev1 .EventTypeWarning , errorReconciliationRetryTimeoutReason , s )
1549
+ if c .isReconciliationRetryDurationExceeded (instance ) {
1550
+ return c .reconciliationRetryDurationExceededFinishPollingServiceInstance (instance , mitigatingOrphan , provisioning , deleting )
1551
+ }
1552
+ return fmt .Errorf (`Got invalid state in LastOperationResponse: %q` , response .State )
1553
+ }
1554
+ return nil
1555
+ }
1601
1556
1602
- if mitigatingOrphan {
1603
- setServiceInstanceCondition (
1604
- toUpdate ,
1605
- v1beta1 .ServiceInstanceConditionReady ,
1606
- v1beta1 .ConditionUnknown ,
1607
- errorOrphanMitigationFailedReason ,
1608
- "Orphan mitigation failed: " + s )
1609
- } else if deleting || provisioning {
1610
- setServiceInstanceCondition (toUpdate ,
1611
- v1beta1 .ServiceInstanceConditionFailed ,
1612
- v1beta1 .ConditionTrue ,
1613
- errorReconciliationRetryTimeoutReason ,
1614
- s )
1615
- } else {
1616
- setServiceInstanceCondition (toUpdate ,
1617
- v1beta1 .ServiceInstanceConditionReady ,
1618
- v1beta1 .ConditionFalse ,
1619
- errorReconciliationRetryTimeoutReason ,
1620
- s )
1621
- }
1557
+ // isReconciliationRetryDurationExceeded tests if the current Operation State time has
1558
+ // elapsed the reconciliationRetryDuration time period
1559
+ func (c * controller ) isReconciliationRetryDurationExceeded (instance * v1beta1.ServiceInstance ) bool {
1560
+ if time .Now ().After (instance .Status .OperationStartTime .Time .Add (c .reconciliationRetryDuration )) {
1561
+ return true
1562
+ }
1563
+ return false
1564
+ }
1622
1565
1623
- if ! provisioning {
1624
- clearServiceInstanceCurrentOperation ( toUpdate )
1625
- } else {
1626
- c . setServiceInstanceStartOrphanMitigation ( toUpdate )
1627
- }
1566
+ // reconciliationRetryDurationExceededFinishPollingServiceInstance marks the instance as
1567
+ // failed from time expired based on current state and then prepares the
1568
+ // instance for removal from reconciliation
1569
+ func ( c * controller ) reconciliationRetryDurationExceededFinishPollingServiceInstance ( instance * v1beta1. ServiceInstance , mitigatingOrphan , provisioning , deleting bool ) error {
1570
+ pcb := pretty . NewContextBuilder ( pretty . ServiceInstance , instance . Namespace , instance . Name )
1628
1571
1629
- if deleting {
1630
- toUpdate .Status .DeprovisionStatus = v1beta1 .ServiceInstanceDeprovisionStatusFailed
1631
- }
1572
+ clone , err := api .Scheme .DeepCopy (instance )
1573
+ if err != nil {
1574
+ return err
1575
+ }
1576
+ toUpdate := clone .(* v1beta1.ServiceInstance )
1577
+ s := "Stopping reconciliation retries on ServiceInstance because too much time has elapsed"
1578
+ glog .Info (pcb .Message (s ))
1579
+ c .recorder .Event (instance , corev1 .EventTypeWarning , errorReconciliationRetryTimeoutReason , s )
1632
1580
1633
- if _ , err := c .updateServiceInstanceStatus (toUpdate ); err != nil {
1634
- return err
1635
- }
1636
- return c .finishPollingServiceInstance (instance )
1637
- }
1638
- return fmt .Errorf (`Got invalid state in LastOperationResponse: %q` , response .State )
1581
+ if mitigatingOrphan {
1582
+ setServiceInstanceCondition (
1583
+ toUpdate ,
1584
+ v1beta1 .ServiceInstanceConditionReady ,
1585
+ v1beta1 .ConditionUnknown ,
1586
+ errorOrphanMitigationFailedReason ,
1587
+ "Orphan mitigation failed: " + s )
1588
+ } else if deleting || provisioning {
1589
+ setServiceInstanceCondition (toUpdate ,
1590
+ v1beta1 .ServiceInstanceConditionFailed ,
1591
+ v1beta1 .ConditionTrue ,
1592
+ errorReconciliationRetryTimeoutReason ,
1593
+ s )
1594
+ } else {
1595
+ setServiceInstanceCondition (toUpdate ,
1596
+ v1beta1 .ServiceInstanceConditionReady ,
1597
+ v1beta1 .ConditionFalse ,
1598
+ errorReconciliationRetryTimeoutReason ,
1599
+ s )
1639
1600
}
1640
- return nil
1601
+
1602
+ if ! provisioning {
1603
+ clearServiceInstanceCurrentOperation (toUpdate )
1604
+ } else {
1605
+ c .setServiceInstanceStartOrphanMitigation (toUpdate )
1606
+ }
1607
+
1608
+ if deleting {
1609
+ toUpdate .Status .DeprovisionStatus = v1beta1 .ServiceInstanceDeprovisionStatusFailed
1610
+ }
1611
+
1612
+ if _ , err := c .updateServiceInstanceStatus (toUpdate ); err != nil {
1613
+ return err
1614
+ }
1615
+ return c .finishPollingServiceInstance (instance )
1641
1616
}
1642
1617
1643
1618
// resolveReferences checks to see if ClusterServiceClassRef and/or ClusterServicePlanRef are
0 commit comments