Skip to content

Commit

Permalink
fix (#166)
Browse files Browse the repository at this point in the history
add tests for no last operation
  • Loading branch information
kerenlahav authored May 9, 2022
1 parent a7823e8 commit e778f90
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
9 changes: 6 additions & 3 deletions controllers/servicebinding_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,13 @@ func (r *ServiceBindingReconciler) Reconcile(ctx context.Context, req ctrl.Reque
// Recovery - restore binding from SM
log.Info(fmt.Sprintf("found existing smBinding in SM with id %s, updating status", binding.ID))

if !(binding.LastOperation.Type == smTypes.CREATE && binding.LastOperation.State != smTypes.SUCCEEDED) {
// store secret unless binding is still being created or failed during creation
if binding.Credentials != nil {
if err := r.storeBindingSecret(ctx, serviceBinding, binding); err != nil {
return r.handleSecretError(ctx, binding.LastOperation.Type, err, serviceBinding)
operationType := smTypes.CREATE
if binding.LastOperation != nil {
operationType = binding.LastOperation.Type
}
return r.handleSecretError(ctx, operationType, err, serviceBinding)
}
}
r.resyncBindingStatus(serviceBinding, binding, serviceInstance.Status.InstanceID)
Expand Down
3 changes: 0 additions & 3 deletions controllers/servicebinding_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -920,9 +920,6 @@ var _ = Describe("ServiceBinding controller", func() {
ServiceBindings: []smclientTypes.ServiceBinding{*smBinding},
}, nil)
})
JustAfterEach(func() {
fakeClient.StatusReturns(&smclientTypes.Operation{ResourceID: fakeBindingID, State: string(smTypes.SUCCEEDED)}, nil)
})
It("should resync successfully", func() {
var err error
createdBinding, err = createBindingWithoutAssertionsAndWait(context.Background(), bindingName, bindingTestNamespace, instanceName, "fake-binding-external-name", false)
Expand Down

0 comments on commit e778f90

Please sign in to comment.