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

Implement instances last operation #3628

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zabanov-lab
Copy link
Contributor

Previously we were setting the ProvisioningFailedCondition to true if the broker returned error on provision, no matter the error. The problem with doing this is that the error can be recoverable, such as the network flaking, but the instance is sent to a state from which it cannot recover (When the ProvisioningFailedCondition is set the reconciler gives up early in the reconciliation loop).

This change fixes the problem described above by defining a new UnrecoverableError type in the osbapi client. The controller would then set the ProvisioningFailedCondition only if the error it received is an UnrecoverableError.

Also LastOperation field is added in CFServiceInstance and there is a logic implemented in the controllers about the different states and this last operation information is propagated to the presenter logic

According to the OSBAPI spec unrecoverable perovision error codes are 400, 409 and 422.

Is there a related GitHub Issue?

#3536

What is this change about?

Implement instances last operation

Does this PR introduce a breaking change?

No

@zabanov-lab zabanov-lab force-pushed the issues/3536-managed-service-last-operation-attempt-2 branch from 402ac26 to 6e7b8dd Compare November 25, 2024 12:59
georgethebeatle and others added 2 commits November 25, 2024 14:14
Previously we were setting the ProvisioningFailedCondition to true if
the broker returned error on provision, no matter the error. The problem
with doing this is that the error can be recoverable, such as the
network flaking, but the instance is sent to a state from which it
cannot recover (When the ProvisioningFailedCondition is set the
reconciler gives up early in the reconciliation loop).

This change fixes the problem described above by defining a new
UnrecoverableError type in the osbapi client. The controller would then set the
ProvisioningFailedCondition only if the error it received is an
UnrecoverableError.

Also LastOperation field is added in CFServiceInstance and there is a
logic implemented in the controllers about the different states and this
last operation information is propagated to the presenter logic

According to the OSBAPI spec unrecoverable perovision error codes are
400, 409 and 422.

Co-authored-by: Danail Branekov <[email protected]>
Co-authored-by: Danail Branekov <[email protected]>
@zabanov-lab zabanov-lab force-pushed the issues/3536-managed-service-last-operation-attempt-2 branch from 6e7b8dd to b275ca1 Compare November 25, 2024 14:58
Copy link
Member

@georgethebeatle georgethebeatle left a comment

Choose a reason for hiding this comment

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

LGTM with minor comments

@@ -36,6 +37,11 @@ var _ = Describe("Service Instance", func() {
Labels: map[string]string{
"foo": "bar",
},
LastOperation: korifiv1alpha1.LastOperation{
Copy link
Member

Choose a reason for hiding this comment

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

Presenters and handlers are not supposed to reference kubernetes types directly. We can move this type to model/services/instances.go so that both the presenter and the CRD can reference it from there.

})
})

When("polling the initial instance last operation", func() {
Copy link
Member

Choose a reason for hiding this comment

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

The OSBAPI broker will never return initial state, see spec. This makes the whole When redundant.

cfServiceInstance.Status.LastOperation = korifiv1alpha1.LastOperation{
Type: "create",
State: "failed",
}
return ctrl.Result{}, k8s.NewNotReadyError().WithCause(err).WithReason("SecretInvalid")
Copy link
Member

Choose a reason for hiding this comment

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

We should not requeue this error as an invalid secret can only be fiexed by the client. We should return NewNotReadyError. ... .WithNoRequeue. As this is hard to test and the test's value is arguable we can skip the test in this case.

return ctrl.Result{}, k8s.NewNotReadyError().WithCause(err).WithReason("SecretInvalid")
}

log.V(1).Info("credentials secret", "name", credentialsSecret.Name, "version", credentialsSecret.ResourceVersion)
cfServiceInstance.Status.Credentials = corev1.LocalObjectReference{Name: credentialsSecret.Name}

if cfServiceInstance.Status.CredentialsObservedVersion == "" {
Copy link
Member

Choose a reason for hiding this comment

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

We should extract these two conditionals in a helper function that returns last operation to tidy up the main loop.

@@ -46,6 +46,13 @@ var _ = Describe("CFServiceInstance", func() {
},
}
Expect(adminClient.Create(ctx, instance)).To(Succeed())

Expect(k8s.Patch(ctx, adminClient, instance, func() {
Copy link
Member

Choose a reason for hiding this comment

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

No need to set last operation here - the controller will do this in the reconciliation loop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants