Skip to content

Commit

Permalink
Clear out current operation when starting reconciliation of a delete (o…
Browse files Browse the repository at this point in the history
  • Loading branch information
staebler authored and arschles committed Nov 16, 2017
1 parent 8cca70a commit 66421d5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
7 changes: 5 additions & 2 deletions pkg/controller/controller_binding.go
Expand Up @@ -672,8 +672,11 @@ func (c *controller) reconcileServiceBindingDelete(binding *v1beta1.ServiceBindi
}
} else {
if toUpdate.Status.CurrentOperation != v1beta1.ServiceBindingOperationUnbind {
// Cancel any pending orphan mitigation since the resource is being deleted
toUpdate.Status.OrphanMitigationInProgress = false
// Cancel any in-progress operation or pending orphan mitigation since the resource is being deleted.
// Do not update the reconciled generation since the operation was aborted and not finished.
currentReconciledGeneration := toUpdate.Status.ReconciledGeneration
clearServiceBindingCurrentOperation(toUpdate)
toUpdate.Status.ReconciledGeneration = currentReconciledGeneration

toUpdate, err = c.recordStartOfServiceBindingOperation(toUpdate, v1beta1.ServiceBindingOperationUnbind)
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions pkg/controller/controller_binding_test.go
Expand Up @@ -2681,9 +2681,10 @@ func TestReconcileServiceBindingDeleteDuringOngoingOperation(t *testing.T) {
SecretName: testServiceBindingSecretName,
},
Status: v1beta1.ServiceBindingStatus{
CurrentOperation: v1beta1.ServiceBindingOperationBind,
OperationStartTime: &startTime,
UnbindStatus: v1beta1.ServiceBindingUnbindStatusRequired,
CurrentOperation: v1beta1.ServiceBindingOperationBind,
OperationStartTime: &startTime,
InProgressProperties: &v1beta1.ServiceBindingPropertiesState{},
UnbindStatus: v1beta1.ServiceBindingUnbindStatusRequired,
},
}

Expand Down
7 changes: 5 additions & 2 deletions pkg/controller/controller_instance.go
Expand Up @@ -408,8 +408,11 @@ func (c *controller) reconcileServiceInstanceDelete(instance *v1beta1.ServiceIns
}
} else {
if toUpdate.Status.CurrentOperation != v1beta1.ServiceInstanceOperationDeprovision {
// Cancel any pending orphan mitigation since the resource is being deleted
toUpdate.Status.OrphanMitigationInProgress = false
// Cancel any in-progress operation or pending orphan mitigation since the resource is being deleted.
// Do not update the reconciled generation since the operation was aborted and not finished.
currentReconciledGeneration := toUpdate.Status.ReconciledGeneration
clearServiceInstanceCurrentOperation(toUpdate)
toUpdate.Status.ReconciledGeneration = currentReconciledGeneration

toUpdate, err = c.recordStartOfServiceInstanceOperation(toUpdate, v1beta1.ServiceInstanceOperationDeprovision)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/controller_instance_test.go
Expand Up @@ -4911,6 +4911,7 @@ func TestReconcileServiceInstanceDeleteDuringOngoingOperation(t *testing.T) {
instance.Status.CurrentOperation = v1beta1.ServiceInstanceOperationProvision
startTime := metav1.NewTime(time.Now().Add(-1 * time.Hour))
instance.Status.OperationStartTime = &startTime
instance.Status.InProgressProperties = &v1beta1.ServiceInstancePropertiesState{}

fakeCatalogClient.AddReactor("get", "serviceinstances", func(action clientgotesting.Action) (bool, runtime.Object, error) {
return true, instance, nil
Expand Down

0 comments on commit 66421d5

Please sign in to comment.