Skip to content

Commit 8411a16

Browse files
kibbles-n-bytespmorie
authored andcommitted
tweak binding setAndUpdateOrphanMitigation function (#1448)
1 parent ce28252 commit 8411a16

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

pkg/controller/controller_binding.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ func isServiceBindingFailed(binding *v1beta1.ServiceBinding) bool {
121121
return false
122122
}
123123

124-
// setAndUpdateOrphanMitigation is for setting the OrphanMitigationInProgress
125-
// status to true, setting the proper condition statuses, and persisting the
126-
// changes via updateServiceBindingStatus.
127-
func (c *controller) setAndUpdateOrphanMitigation(binding *v1beta1.ServiceBinding, toUpdate *v1beta1.ServiceBinding, instance *v1beta1.ServiceInstance, serviceClass *v1beta1.ClusterServiceClass, brokerName string, errorStr string) error {
124+
// setAndUpdateServiceBindingStartOrphanMitigation is for setting the
125+
// OrphanMitigationInProgress status to true, setting the proper condition
126+
// statuses, and persisting the changes via updateServiceBindingStatus.
127+
func (c *controller) setAndUpdateServiceBindingStartOrphanMitigation(toUpdate *v1beta1.ServiceBinding) error {
128128
s := fmt.Sprintf(
129129
`%s "%s/%s": Starting orphan mitgation`,
130-
typeSB, binding.Name, binding.Namespace,
130+
typeSB, toUpdate.Name, toUpdate.Namespace,
131131
)
132132
toUpdate.Status.OrphanMitigationInProgress = true
133133
toUpdate.Status.OperationStartTime = nil
@@ -141,7 +141,7 @@ func (c *controller) setAndUpdateOrphanMitigation(binding *v1beta1.ServiceBindin
141141
s,
142142
)
143143

144-
c.recorder.Event(binding, corev1.EventTypeWarning, errorServiceBindingOrphanMitigation, s)
144+
c.recorder.Event(toUpdate, corev1.EventTypeWarning, errorServiceBindingOrphanMitigation, s)
145145
if _, err := c.updateServiceBindingStatus(toUpdate); err != nil {
146146
return err
147147
}
@@ -449,7 +449,7 @@ func (c *controller) reconcileServiceBinding(binding *v1beta1.ServiceBinding) er
449449
errorBindCallReason,
450450
"Communication with the ServiceBroker timed out; Bind operation will not be retried: "+err.Error(),
451451
)
452-
return c.setAndUpdateOrphanMitigation(binding, toUpdate, instance, serviceClass, brokerName, netErr.Error())
452+
return c.setAndUpdateServiceBindingStartOrphanMitigation(toUpdate)
453453
} else if err != nil {
454454
if httpErr, ok := osb.IsHTTPError(err); ok {
455455
// orphan mitigation: looking for 2xx (excluding 200), 408, 5xx
@@ -463,7 +463,7 @@ func (c *controller) reconcileServiceBinding(binding *v1beta1.ServiceBinding) er
463463
errorBindCallReason,
464464
"ServiceBroker returned a failure; Bind operation will not be retried: "+err.Error(),
465465
)
466-
return c.setAndUpdateOrphanMitigation(binding, toUpdate, instance, serviceClass, brokerName, httpErr.Error())
466+
return c.setAndUpdateServiceBindingStartOrphanMitigation(toUpdate)
467467
}
468468
s := fmt.Sprintf(
469469
`Error creating ServiceBinding for ServiceInstance "%s/%s" of ClusterServiceClass (K8S: %q ExternalName: %q) at ClusterServiceBroker %q: %v`,
@@ -573,7 +573,7 @@ func (c *controller) reconcileServiceBinding(binding *v1beta1.ServiceBinding) er
573573
v1beta1.ConditionTrue,
574574
errorReconciliationRetryTimeoutReason,
575575
s)
576-
return c.setAndUpdateOrphanMitigation(binding, toUpdate, instance, serviceClass, brokerName, "too much time has elapsed")
576+
return c.setAndUpdateServiceBindingStartOrphanMitigation(toUpdate)
577577
}
578578

579579
if _, err := c.updateServiceBindingStatus(toUpdate); err != nil {

0 commit comments

Comments
 (0)