Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
handle instance deletion that occurs during async provisioning (#1587)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay Boyd committed Jan 31, 2018
1 parent f358b99 commit 06ef7d2
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/controller/controller_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ func (c *controller) reconcileServiceInstanceDelete(instance *v1beta1.ServiceIns
}

glog.V(4).Info(pcb.Message("Processing deleting event"))

instance = instance.DeepCopy()

// We don't want to delete the instance if there are any bindings associated.
Expand Down Expand Up @@ -1430,8 +1429,16 @@ func (c *controller) processProvisionSuccess(instance *v1beta1.ServiceInstance,
setServiceInstanceDashboardURL(instance, dashboardURL)
setServiceInstanceCondition(instance, v1beta1.ServiceInstanceConditionReady, v1beta1.ConditionTrue, successProvisionReason, successProvisionMessage)
instance.Status.ExternalProperties = instance.Status.InProgressProperties
currentReconciledGeneration := instance.Status.ReconciledGeneration
clearServiceInstanceCurrentOperation(instance)

if instance.DeletionTimestamp != nil {
// A request to delete the Instance was received during provisioning, don't bump
// ReconciledGeneration as that will prevent processing the delete.
glog.V(4).Infof("Not updating ReconciledGeneration after instance provisioning because there is a deletion pending.")
instance.Status.ReconciledGeneration = currentReconciledGeneration
}

if _, err := c.updateServiceInstanceStatus(instance); err != nil {
return err
}
Expand Down
43 changes: 43 additions & 0 deletions test/integration/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,49 @@ func TestAsyncProvisionWithMultiplePolls(t *testing.T) {
})
}

func TestServiceInstanceDeleteWithAsyncOperationInProgress(t *testing.T) {
ct := controllerTest{
t: t,
broker: getTestBroker(),
instance: getTestInstance(),
skipVerifyingInstanceSuccess: true,
setup: func(ct *controllerTest) {
ct.osbClient.ProvisionReaction.(*fakeosb.ProvisionReaction).Response.Async = true
ct.osbClient.PollLastOperationReaction = &fakeosb.PollLastOperationReaction{
Response: &osb.LastOperationResponse{
State: osb.StateInProgress,
},
}
},
}
ct.run(func(ct *controllerTest) {
if err := util.WaitForInstanceCondition(ct.client, ct.instance.Namespace, ct.instance.Name,
v1beta1.ServiceInstanceCondition{
Type: v1beta1.ServiceInstanceConditionReady,
Status: v1beta1.ConditionFalse,
Reason: "Provisioning",
}); err != nil {
t.Fatalf("error waiting for instance to be provisioning asynchronously: %v", err)
}

if err := ct.client.ServiceInstances(ct.instance.Namespace).Delete(ct.instance.Name, &metav1.DeleteOptions{}); err != nil {
t.Fatalf("failed to delete instance: %v", err)
}
ct.osbClient.PollLastOperationReaction = &fakeosb.PollLastOperationReaction{
Response: &osb.LastOperationResponse{
State: osb.StateSucceeded,
},
}
if err := util.WaitForInstanceToNotExist(ct.client, ct.instance.Namespace, ct.instance.Name); err != nil {
t.Fatalf("error waiting for instance to not exist: %v", err)
}

// We deleted the instance above, clear it so test cleanup doesn't fail
// attempting to delete the instance again.
ct.instance = nil
})
}

func getUpdateInstanceResponseByPollCountReactions(numOfResponses int, stateProgressions []fakeosb.UpdateInstanceReaction) fakeosb.DynamicUpdateInstanceReaction {
numberOfPolls := 0
numberOfStates := len(stateProgressions)
Expand Down

0 comments on commit 06ef7d2

Please sign in to comment.