Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
zabanov-lab committed Sep 25, 2024
1 parent d4b51d4 commit 359f9e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 32 deletions.
16 changes: 8 additions & 8 deletions controllers/controllers/services/instances/managed/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ func (r *Reconciler) ReconcileResource(ctx context.Context, serviceInstance *kor
return r.finalizeCFServiceInstance(ctx, serviceInstance)
}

if isReady(serviceInstance) {
return ctrl.Result{}, nil
}

if isFailed(serviceInstance) {
return ctrl.Result{}, k8s.NewNotReadyError().WithReason("ProvisioningFailed").WithNoRequeue()
}

servicePlan, err := r.getServicePlan(ctx, serviceInstance.Spec.PlanGUID)
if err != nil {
log.Error(err, "failed to get service plan")
Expand All @@ -121,14 +129,6 @@ func (r *Reconciler) ReconcileResource(ctx context.Context, serviceInstance *kor
return ctrl.Result{}, fmt.Errorf("failed to create client for broker %q: %w", serviceBroker.Name, err)
}

if isReady(serviceInstance) {
return ctrl.Result{}, nil
}

if isFailed(serviceInstance) {
return ctrl.Result{}, k8s.NewNotReadyError().WithReason("ProvisioningFailed").WithNoRequeue()
}

if !isProvisionRequested(serviceInstance) {
return r.provisionServiceInstance(ctx, osbapiClient, serviceInstance, servicePlan, serviceOffering)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,6 @@ var _ = Describe("CFServiceInstance", func() {
brokerClient.DeprovisionReturns(osbapi.ServiceInstanceOperationResponse{
Operation: "deprovision-op",
}, nil)
brokerClient.GetServiceInstanceLastOperationReturns(osbapi.LastOperationResponse{
State: "in progress",
}, nil)
})

JustBeforeEach(func() {
Expand All @@ -531,12 +528,6 @@ var _ = Describe("CFServiceInstance", func() {
}).Should(Succeed())
})

It("does not delete the service instance", func() {
Consistently(func(g Gomega) {
g.Expect(adminClient.Get(ctx, client.ObjectKeyFromObject(instance), instance)).To(Succeed())
}).Should(Succeed())
})

When("deprovision fails", func() {
BeforeEach(func() {
brokerClient.DeprovisionReturns(osbapi.ServiceInstanceOperationResponse{}, errors.New("deprovision-failed"))
Expand All @@ -553,21 +544,6 @@ var _ = Describe("CFServiceInstance", func() {
}).Should(Succeed())
})
})

When("deprovision operation completes", func() {
BeforeEach(func() {
brokerClient.GetServiceInstanceLastOperationReturns(osbapi.LastOperationResponse{
State: "succeeded",
}, nil)
})

It("deletes the instance", func() {
Eventually(func(g Gomega) {
err := adminClient.Get(ctx, client.ObjectKeyFromObject(instance), instance)
g.Expect(k8serrors.IsNotFound(err)).To(BeTrue())
}).Should(Succeed())
})
})
})

When("the service instance is user-provided", func() {
Expand Down

0 comments on commit 359f9e7

Please sign in to comment.