Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removal of Unnecessary Operation #1396

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/broker/binding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ func TestDeprovisioningWithExistingBindings(t *testing.T) {
response = suite.CallAPI(http.MethodDelete, fmt.Sprintf("oauth/v2/service_instances/%s/service_bindings/%s?plan_id=361c511f-f939-4621-b228-d0fb79a1fe15&service_id=47c9dcbf-ff30-448e-ab36-d3bad66ba281", iid, bindingID2), "")
assert.Equal(t, http.StatusGone, response.StatusCode)

// then expect bindings to be removed
suite.AssertBindingRemoval(iid, bindingID1)
suite.AssertBindingRemoval(iid, bindingID2)
// then expect bindings to exist in database
suite.AssertBindingExists(iid, bindingID1)
suite.AssertBindingExists(iid, bindingID2)
}

func TestRemoveBindingsFromSuspended(t *testing.T) {
Expand Down
6 changes: 6 additions & 0 deletions cmd/broker/broker_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,12 @@ func (s *BrokerSuiteTest) AssertBindingRemoval(iid string, bindingID string) {
assert.True(s.t, dberr.IsNotFound(err), "bindings should be removed")
}

func (s *BrokerSuiteTest) AssertBindingExists(iid string, bindingID string) {
binding, err := s.db.Bindings().Get(iid, bindingID)
assert.NoError(s.t, err)
assert.NotNil(s.t, binding)
}

func (s *BrokerSuiteTest) LastOperation(iid string) *internal.Operation {
op, _ := s.db.Operations().GetLastOperation(iid)
return op
Expand Down
5 changes: 0 additions & 5 deletions internal/broker/bind_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ func (b *UnbindEndpoint) Unbind(ctx context.Context, instanceID, bindingID strin
instance, err := b.instancesStorage.GetByID(instanceID)
switch {
case dberr.IsNotFound(err):
err = b.bindingsStorage.Delete(instanceID, bindingID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was deliberately introduced to let the job remove orphans.

if err != nil {
b.log.Errorf("Unbind error during removal of db entity: %v", err)
return domain.UnbindSpec{}, apiresponses.NewFailureResponse(fmt.Errorf("failed to delete binding for binding %s and not existing instance %s: %v", bindingID, instanceID, err), http.StatusInternalServerError, fmt.Sprintf("failed to delete resources for binding %s and not existing instance %s: %v", bindingID, instanceID, err))
}
return domain.UnbindSpec{}, apiresponses.ErrInstanceDoesNotExist
case err != nil:
return domain.UnbindSpec{}, apiresponses.NewFailureResponse(fmt.Errorf("failed to get instance %s", instanceID), http.StatusInternalServerError, fmt.Sprintf("failed to get instance %s", instanceID))
Expand Down
Loading